oatcliは、OATリソースを管理するためのコマンドラインツールです。コマンドラインを使用したサーバーの追加やOceanBaseプロダクトのインストールなどをサポートしています。
前提条件
- OBServerサーバーの準備と設定が完了していること。詳細については、サーバーの準備および サーバーの設定を参照してください。
- OATをインストール済みであること。詳細については、OATのデプロイを参照してください。
- OATサーバーの
rootユーザー権限を持っていること。
操作手順
OATがインストールされているサーバーに接続します。
例:
OATがインストールされているサーバーに
sshを使用して接続します。C:\Users\user001>ssh admin@xxx.xxx.xxx.xxx admin@xxx.xxx.xxx.xxx's password:以下のコマンドを使用して、OATコンテナにアクセスします。
説明
以下のコマンドの実行には、
root権限が必要です。docker exec -it oat bash例:
[admin@xxx /home/admin] $sudo docker exec -it oat bash実行結果:
[root@xxx oat]#(オプション)以下のコマンドで、oatcliの使用方法を確認できます。
oatcli --helpoatcliコマンドの詳細については、oatcliを参照してください。
例:
[root@xxx oat]# oatcli --help実行結果:
Usage: oatcli [OPTIONS] COMMAND [ARGS]... Command line tool for manage OAT resources ╭─ Options ───────────────────────────────────────────────────────────────────────────────╮ │ --install-completion Install completion for the current shell. │ │ --show-completion Show completion for the current shell, to copy it or │ │ customize the installation. │ │ --help Show this message and exit. │ ╰─────────────────────────────────────────────────────────────────────────────────────────╯ ╭─ Commands ──────────────────────────────────────────────────────────────────────────────╮ │ config Config OAT API Server address, username and password │ │ create Create resource in OAT │ │ dagrun Operate dagrun and task status in OAT │ │ delete Delete resource in OAT │ │ describe Get resource detail info in OAT │ │ get Get resource info in OAT │ ╰─────────────────────────────────────────────────────────────────────────────────────────╯OAT APIを呼び出すためのOAT APIアドレス、ユーザー名、パスワードを設定します。
oatcli config set [OPTIONS]オプションの説明:
-s, --api-server TEXT:api_server、例:127.0.0.1:7000。-u, --username TEXT:ユーザー名。-p, --password TEXT:パスワード。--help:このメッセージを表示して終了します。
例:
[root@xxx oat]# oatcli config set -sxxx.xxx.xxx.1:7000 -uadmin -p******実行結果:
11:14:16 [INFO] update {'api_server': 'xxx.xxx.xxx.1:7000', 'username': 'admin', 'password': '******'} to /root/.oatcli/config.jsonデータセンター を作成します。
サーバー用のデータセンター情報を設定する方法は次のとおりです:
oatcli create idc [OPTIONS] NAME REGIONパラメータの説明:
NAME:データセンター名 [必須]。REGION:データセンターのあるリージョン [必須]。
オプションの説明:
--help:このメッセージを表示して終了します。
例:
データセンター の名前を
hz0、リージョンをhangzhouとして作成します。[root@xxx oat]# oatcli create idc hz0 hangzhou実行結果:
11:20:05 [DEBUG] Starting new HTTP connection (1): xxx.xxx.xxx.1:7000 11:20:05 [DEBUG] http://xxx.xxx.xxx.1:7000 "POST /api/v2/idcs HTTP/1.1" 201 175 ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ {'id': 2, 'name': 'hz0', 'region': 'hangzhou'} │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯認証情報 を作成します。
サーバー接続用のSSH認証情報を作成する方法は以下のとおりです。
oatcli create credential [OPTIONS] NAME AUTH_TYPE:{password|pubkey|external}パラメータの説明:
NAME:認証情報の識別名 [必須]。AUTH_TYPE:{password|pubkey|external}:認証タイプ [必須]。password:パスワード認証。pubkey:公開鍵認証。external:パスワードレス認証を設定済み。
オプションの説明:
-u, --username TEXT:[デフォルト値:root]。-p, --password TEXT:パスワード。-k, --key-file PATH:SSH秘密鍵ファイル。--help:このメッセージを表示して終了します。
例:
認証情報 の名前を
root_148、ユーザータイプをrootユーザー、認証タイプをパスワード認証として作成します。[root@xxx oat]# oatcli create credential -uroot -p****** root_148 password実行結果:
11:39:17 [DEBUG] Starting new HTTP connection (1): xxx.xxx.xxx.1:7000 11:39:17 [DEBUG] http://xxx.xxx.xxx.1:7000 "POST /api/v2/credentials HTTP/1.1" 200 309 ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ { │ │ 'id': 1, │ │ 'servers': [], │ │ 'name': 'root_148', │ │ 'authType': 'password', │ │ 'username': 'root', │ │ 'createTime': '2023-06-19T11:39:17.315921+08:00', │ │ 'updateTime': '2023-06-19T11:39:17.315969+08:00' │ │ } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯OBServerサーバーを追加します(サーバーの追加と初期化)。
oatcli create server [OPTIONS] IPS... INIT_TAG:{observer|obproduct|both}オプションの説明:
-i, --idc TEXT:データセンター名:リージョン、既に存在している必要があります [必須]。-c, --credential-name TEXT:認証情報名、既に存在している必要があります [必須]。--add-only | --no-add-only:カスタムオプション、サーバーの設定を初期化するかどうか [デフォルト値:no-add-only]。--add-only:サーバーの追加のみを行い、OSの設定操作を実行しません。--no-add-only:OSの設定操作を実行します。
--ssh-port INTEGER:SSHポート [デフォルト値:22]。--docker-root-dir TEXT:[デフォルトパス:/docker]。--admin-uid-gid TEXT:[デフォルト値:500:500]。--admin-password TEXT:パスワード。--help:このメッセージを表示して終了します。
パラメータの説明:
IPS...:サーバーのIPアドレス [必須]。INIT_TAG:{observer|obproduct|both}:サーバー用途 [必須]。observer:OBServerをインストールします。obproduct:OceanBaseプロダクトサービスをインストールします。both:OBServerとOceanBaseプロダクトサービスをインストールします。
例:
OBServerサーバー を追加します。使用する 認証情報 は
root_148、使用する データセンター名:リージョン はhz0:hangzhou、サーバー用途 はobserverに設定します。[root@xxx oat]# oatcli create server -ihz0:hangzhou -croot_148 xxx.xxx.xxx.2 observer実行結果:
13:56:05 [DEBUG] Starting new HTTP connection (1): xxx.xxx.xxx.1:7000 13:56:06 [DEBUG] http://xxx.xxx.xxx.1:7000 "GET /api/v2/credentials?name=root_148 HTTP/1.1" 200 389 13:56:06 [DEBUG] Starting new HTTP connection (1): xxx.xxx.xxx.1:7000 13:56:06 [DEBUG] http://xxx.xxx.xxx.1:7000 "GET /api/v2/idcs?name=hz0®ion=hangzhou HTTP/1.1" 200 255 13:56:06 [DEBUG] Starting new HTTP connection (1): xxx.xxx.xxx.1:7000 13:56:06 [DEBUG] http://xxx.xxx.xxx.1:7000 "POST /api/v2/servers/batchCreate HTTP/1.1" 200 788 ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ { │ │ 'contents': [ │ │ { │ │ 'id': 2, │ │ 'idcInfo': {'id': 2, 'name': 'hz0', 'region': 'hangzhou'}, │ │ 'ip': 'xxx.xxx.xxx.2', │ │ 'sshPort': 22, │ │ 'checkStatus': 'unknown', │ │ 'operateStatus': 'init', │ │ 'description': '', │ │ 'isOio': False, │ │ 'platform': {'system': '', 'node': '', 'release': '', 'version': '', 'machine': ''}, │ │ 'hardware': {'cpu': 0, 'memory': 0, 'disk': 0}, │ │ 'service': {'product': [], 'component': [], 'observer': []}, │ │ 'runtimeInfo': {'dockerRootDir': '/docker', 'adminUidGid': '500:500', 'initTag': ['observer']}, │ │ 'networkInfo': [], │ │ 'createTime': '2023-06-19T13:56:06.839271+08:00', │ │ 'updateTime': '2023-06-19T13:56:06.859580+08:00', │ │ 'relateDagrun': 5, │ │ 'credential': 1 │ │ } │ │ ], │ │ 'page': {'totalElements': 1, 'totalPages': 1, 'number': 1, 'size': 100} │ │ } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯サーバーの追加が完了したかどうかを確認します。
サーバーの詳細情報と関連するdagrun情報を確認します。
oatcli describe server [OPTIONS] IPパラメータの説明:
IP:特定のサーバーのIPアドレス [必須]。オプションの説明:
--help:このメッセージを表示して終了します。例:
[root@xxx oat]# oatcli describe server xxx.xxx.xxx.2実行結果:
14:41:01 [DEBUG] Starting new HTTP connection (1): xxx.xxx.xxx.1:7000 14:41:01 [DEBUG] http://xxx.xxx.xxx.1:7000 "GET /api/v2/servers?ip=xxx.xxx.xxx.2 HTTP/1.1" 200 1085 14:41:01 [DEBUG] Starting new HTTP connection (1): xxx.xxx.xxx.1:7000 14:41:01 [DEBUG] http://xxx.xxx.xxx.1:7000 "GET /api/v2/servers/2 HTTP/1.1" 200 998 ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ { │ │ 'id': 2, │ │ 'idcInfo': {'id': 2, 'name': 'hz0', 'region': 'hangzhou'}, │ │ 'ip': 'xxx.xxx.xxx.2', │ │ 'sshPort': 22, │ │ 'checkStatus': 'unknown', │ │ 'operateStatus': 'idle', │ │ 'description': '', │ │ 'isOio': False, │ │ 'platform': { │ │ 'system': 'Linux', │ │ 'node': 'h07g04228.sqa.eu95', │ │ 'release': '3.10.0-327.ali2010.rc7.alios7.x86_64', │ │ 'version': '#1 SMP Thu Jun 29 21:45:21 CST 2017', │ │ 'machine': 'x86_64' │ │ }, │ │ 'hardware': {'cpu': 32, 'memory': 125, 'disk': ''}, │ │ 'service': {'observer': [], 'product': [], 'component': [], 'tool': []}, │ │ 'runtimeInfo': {'dockerRootDir': '/docker', 'adminUidGid': '500:500', 'initTag': ['observer']}, │ │ 'networkInfo': [ │ │ {'nic': 'lo', 'ipWithMask': '127.0.0.1/8'}, │ │ {'nic': 'bond0', 'ipWithMask': 'xxx.xxx.xxx.2/26'}, │ │ {'nic': 'bond0', 'ipWithMask': 'xxx.xxx.xxx.3/26'}, │ │ {'nic': 'docker0', 'ipWithMask': '172.17.0.1/16'} │ │ ], │ │ 'createTime': '2023-06-19T13:56:06.839271+08:00', │ │ 'updateTime': '2023-06-19T14:35:31+08:00', │ │ 'relateDagrun': 5, │ │ 'credential': 1 │ │ } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ 14:41:01 [DEBUG] Starting new HTTP connection (1): xxx.xxx.xxx.1:7000 14:41:02 [DEBUG] http://xxx.xxx.xxx.1:7000 "GET /api/v2/dagruns/5 HTTP/1.1" 200 2727 14:41:02 [INFO] relate dagrun info: ┏━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ id ┃ innerState ┃ executeTime ┃ startTime ┃ ┡━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ check_ssh │ success │ 2023-06-19T05:56:06.842182Z │ 2023-06-19T05:56:07.970263Z │ │ create_admin_user │ success │ 2023-06-19T05:56:06.842182Z │ 2023-06-19T05:56:09.060737Z │ │ config_docker │ success │ 2023-06-19T05:56:06.842182Z │ 2023-06-19T05:56:10.319578Z │ │ config_deps │ success │ 2023-06-19T05:56:06.842182Z │ 2023-06-19T05:56:10.319575Z │ │ config_os │ success │ 2023-06-19T05:56:06.842182Z │ 2023-06-19T05:56:10.319600Z │ │ config_chrony │ success │ 2023-06-19T05:56:06.842182Z │ 2023-06-19T05:56:10.319587Z │ │ precheck │ success │ 2023-06-19T05:56:06.842182Z │ 2023-06-19T05:56:23.563900Z │ │ update_server │ success │ 2023-06-19T05:56:06.842182Z │ 2023-06-19T06:35:31.197149Z │ └───────────────────┴────────────┴─────────────────────────────┴─────────────────────────────┘OATでリソース情報を取得します。
oatcli get [OPTIONS] COMMAND [ARGS]...オプションの説明:
--help:このメッセージを表示して終了します。
コマンドの説明:
component:コンポーネント情報を取得します。credential:認証情報を取得します。idc:データセンター情報を取得します。image:イメージ情報を取得します。product:プロダクト情報を取得します。server:サーバー情報を取得します。
例:
サーバーのリスト情報を取得します。
[root@xxx oat]# oatcli get server実行結果:
14:35:50 [DEBUG] Starting new HTTP connection (1): xxx.xxx.xxx.1:7000 14:35:50 [DEBUG] http://xxx.xxx.xxx.1:7000 "GET /api/v2/servers HTTP/1.1" 200 1085 ┏━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓ ┃ id ┃ ip ┃ sshPort ┃ idcInfo ┃ description ┃ operateStatus ┃ ┡━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩ │ 2 │ xxx.xxx.xxx.2 │ 22 │ {'id': 2, 'name': 'hz0', 'region': 'hangzhou'} │ │ idle │ └────┴───────────────┴─────────┴────────────────────────────────────────────────┴─────────────┴───────────────┘
次の操作
サーバーの初期化が完了したら、必要に応じてOceanBaseクラスタをデプロイできます:
- コマンドラインを使用した2レプリカ + アービトレーションサービスのOceanBaseクラスタのデプロイ
- コマンドライン使用した1レプリカOceanBaseクラスタのデプロイ
- コマンドライン使用した3レプリカOceanBaseクラスタのデプロイ