cli¶
리눅스 콘솔에서 사용가능한 명령어(Command Line Interface)를 제공한다.
$ m2 ver
productVer: 1.0.0/1988
settingVer: 3344
license: trial, WineSOFT, 20220620150000Z-20220721145959Z
functions: dims,mp3edit,mp4edit
hostname: cache-05
admin: admin@exmaple.com
managementServer: myKafka
m2 ver
m2 버전
m2 가동/멈춤¶
m2는 initd
에 m2
, m2core
, m2rt
3개의 서비스를 등록한다.
m2
서비스는 m2core
, m2rt
등을 모두 관장하는 메인 서비스이다.
$ m2 stop
$ m2 start
$ m2 restart
m2 stop
m2 서비스를 중단한다.
m2 start
m2 서비스를 시작한다.
m2 restart
m2 서비스를 중단 후 시작한다.
service m2core¶
$ service m2core stop
$ service m2core start
$ service m2core restart
service m2rt¶
$ service m2rt stop
$ service m2rt start
$ service m2rt restart
m2 deploy¶
deploy
명령은 서비스 형상을 관리한다.
$ m2 deploy local
{result}
$ m2 deploy backup
{result}
$ m2 deploy history
{result}
$ m2 deploy restore [hash-id]
{result}
m2 deploy local
수정된
/usr/local/m2/setting.json
로컬설정을 서비스에 반영한다.m2 deploy backup
현재 로딩된 설정을 S3에 백업한다.
m2 deploy history
과거 로딩된 설정의 목록을 조회한다.
# m2 deploy history ID DATE TIME TYPE SIZE HASH VERSION 1 2023-11-01 12:12:12 loaded 8042 20231101_121212_01c82da90b6a79f5b6db9c55df5346f6 1.4.2
m2 deploy restore [hash-id]
과거 설정으로 되돌린다. [hash-id]는
m2 deploy history
명령으로 확인할 수 있다.See also
라이선스 교체 (무중단 CLI)¶
deploy
대상을 license
로 지정하면 무중단으로 라이선스를 교체할 수 있다.
$ m2 deploy license {local-path}
Please review your changes.
-------------------------------------------------------------
{
"SerialNumber": {
"_asis_": "KR12345678",
"_tobe_": "KR87654321"
},
...
}
-------------------------------------------------------------
Deploy? (y/n)
실패 메시지는 라이선스 교체 (무중단 API) 와 동일하다.
m2 install¶
install
명령은 M2 패키지를 재설치한다.
주로 최신버전 업데이트 용도로 사용한다.
$ m2 install
Starting install M2 v1.0.5 (latest)
[1/5] Download M2 package v1.0.5...
[2/5] Unarchive package...
[3/5] Install package...
[4/5] Checkout repository ...
[5/5] Starting M2 service...
Done.
$ m2 install
v1.0.5 is the current(latest) version.
$ m2 install 1.0.4
Starting install M2 v1.0.4
[1/5] Download M2 package v1.0.4...
[2/5] Unarchive package...
[3/5] Install package...
[4/5] Checkout repository ...
[5/5] Starting M2 service...
Done.
$ m2 install 1.0.4
v1.0.4 is the current version.
$ m2 install 1.1.0
v1.1.0 is not available
m2 install
최신 버전의 M2를 재설치한다.
m2 install {version}
특정 버전의 M2를 재설치한다.
m2 get¶
각종 정보를 열람한다.
m2 get setting alpha
¶
로딩된 setting.json
을 열람한다.
Note
설정은 2가지로 형태로 구분된다.
running (기본)
서비스에 반영된 설정artifact
설정 리로드가 요청 되었지만 재시작이 필요한 설정목록 등의 변경등으로 서비스에 반영되지 않은 형상 (재가동시 반영된다.)
$ m2 get setting
$ m2 get setting running
$ m2 get setting artifact
{
"meta": {
...
},
"env": {
...
},
"functions": {
...
},
"hosting[]": [
...
]
}
setting
키워드는 setting.json
설정트리와 대응된다.
$ m2 get setting.meta
{
"meta": {
"defaultHosting": "qa.winesoft.co.kr",
"version": "1.1.0/1",
"group": "",
"branch": "",
"admin": "",
"setting": {
"history": {
"retention": {
"days": 60,
"count": 100,
"size": 10
}
}
}
}
}
특정 가상호스트만 열람하고 싶다면 setting.hosting[...]
을 이용해 다음과 같이 표현한다.
setting.hosting[example.com]
가상호스트name
설정을 명시한다.setting.hosting[name=example.com]
가상호스트name
설정을 명시한다.setting.hosting[0]
설정된 인덱스 번호를 명시한다.
$ m2 get setting.hosting[example.com]
{
"hosting": [
{
"name": "example.com",
...
}
]
}
m2 get license¶
연동 중인 라이선스 정보를 열람한다.
$ m2 get license
{
"status": "OK",
"version": "1.1.2",
"result": {
"Name": "WineSOFT",
"Type": "Site",
"SerialNumber": "KR200039605",
"Status": "Available",
"AllowedFeatures": "ALL",
"Validity": {
"NotBefore": "20200409150000Z",
"NotAfter": "20230410145959Z",
"RemainDays": 123
}
}
}
m2 get hosting¶
서비스 중인 가상호스트 정보를 간략히 요약한다.
$ m2 get hosting
{
"status": "OK",
"version": "1.1.2",
"result": [
{
"name": "foo.com",
"origin": [ "192.168.0.10", "192.168.0.11" ],
"functions": [ "dims", "pagedesk", "pagemixed" ]
},
{
"name": "bar.com",
"origin": [ "internal.bar.com" ],
"functions": [ "dims", "aws_s3" ]
}
]
}
m2 get https¶
로딩된 인증서 서비스의 유효성을 테스트한다.
$ m2 get https
{
"status": "OK",
"version": "1.1.2",
"result": [
{
"name": "example.com",
"enable": true,
"https": [
{
"cert": "/usr/ssl/example.com/cert.pem",
"key": "/usr/ssl/example.com/certkey.pem",
"ca": "/usr/ssl/example.com/CA.pem"
}
]
},
{
"name": "foo.com",
"enable": false,
"error": "Unable to find valid certification path",
"https": [
{
"cert": "/usr/ssl/example.com/cert.pem",
"key": "/usr/ssl/example.com/certkey.pem",
"ca": "/usr/ssl/example.com/CA.pem"
}
]
}
]
}
m2 get discover¶
같은 서비스 환경에 있는 노드를 조회한다.
$ m2 get discover
{
"status": "OK",
"version": "1.4.8",
"result": [
{
"address": "192.168.0.70",
"advertisement": {
"signature": "WINESOFT_M2FW",
"name": "M2Live",
"version": "1.4.8",
"buildNumber": "3",
"settingHash": "1c4f5776f592a44e6894cc24e4efc33c"
},
"lastSeen": 1716788891214
}
]
}
m2 cluster¶
클러스터의 주목적은 트래픽 수평 Hash
부하분산과 설정 동기화이다.
cluster 기능이 활성화되어 있어야 한다.
Peer To Peer 방식으로 동작하기 떄문에 어느 노드에서나 동작한다.
클러스터가 구성된 상태라도 개별 노드의 형상변경 m2 deploy 는 유효하다.
모든 변경은 아래 시나리오로 동작한다.
클러스터 모든 멤버로 명령어 전달
READY
상태모든 멤버가
READY
상태가 아니라면 실패와 디버그 정보 출력모든 멤버가
READY
상태라면 명령어 실행
DISABLED
상태의 노드가 존재할 경우 명령어는 성공할 수 없다.
ref-cli-cluster-remove 후 명령어를 수행해야 한다.
Warning
모든 명령어 수행시 상태확인 결과가 제공된다. 올바른 작업의 결과가 출력되는지 반드시 확인해야 한다.
상태확인¶
클러스터의 동작상태를 확인한다.
$ m2 cluster status
================================================================================
NAME | IP | STATUS | VERSION | SETTING
--------------------------------------------------------------------------------
node01 | 10.0.0.1 | ACTIVE | v2.3.1 | a93f7c1e2bb5d91a
node02 | 10.0.0.2 | ACTIVE | v2.3.1 | a93f7c1e2bb5d91a
node03 | 10.0.0.3 | DRAINING | v2.3.0 | 5e7faed1109d3abc
node04 | 10.0.0.4 | DISABLED | - | -
================================================================================
NAME
클러스터 멤버의 이름. 명시적으로 추가된 이름이 없다면 hostname을 사용한다.
IP
클러스터 멤버의 IP 주소
STATUS
멤버의 상태
ACTIVE
: 정상동작DRAINING
: 트래픽 분배만 중단된 상태. 해당노드를 작업하기 전 트래픽 배제의 목적으로 사용된다.DISABLED
: 통신불가
VERSION
솔루션버전
SETTING
설정형상의 고유값
트래픽 배제¶
멤버로 유입되는 트래픽을 차단한다.
Warning
형상을 변경하지 않는다. 임시로 배제된다.
$ m2 cluster drain --ip 10.0.0.3
$ m2 cluster drain --nodename node03
[↓] Node 'node03' is now in DRAINING state (excluded from traffic).
...상태확인 결과...
배제된 노드의 상태는 DRAINING
으로 설정된다.

트래픽 복구¶
트래픽 배제 된 노드의 트래픽을 복구(다시 유입)한다.
Warning
형상을 변경하지 않는다. 임시로 배제된다.
$ m2 cluster undrain --ip 10.0.0.3
$ m2 cluster undrain --nodename node03
[↑] Node 'node03' is now ACTIVE and receiving traffic.
...상태확인 결과...
복구된 노드의 상태는 ACTIVE
로 설정된다.

설정 동기화¶
특정노드의 설정을 전체 클러스터로 복제한다.
Warning
git형상 동기화가 구성된 경우 conflict가 발생할 수 있어 거부된다.
$ m2 cluster sync --from node02
[→] Syncing configuration from node02 to all members...
[✓] node01 updated (config hash: a93f7c1e)
[✓] node03 updated (config hash: a93f7c1e)
[✓] node04 updated (config hash: a93f7c1e)
[✔] Sync completed: 3/3 nodes updated successfully.
...상태확인 결과...
--from
복제할 소스 노드를 IP또는 노드이름으로 지정한다.