Initialize an OBServer node using oatcli

2025-12-04 03:43:01  Updated

oatcli is a command-line tool for managing OAT resources. You can use it to add servers and install OceanBase products.

Prerequisites

  • You have prepared an OBServer node and completed the relevant configuration. For more information, see Prepare the servers and Configure the servers.
  • You have installed OAT. For more information, see Deploy OAT.
  • You have the root user permissions on the OAT server.

Procedure

  1. Connect to the server where OAT is installed.

    Here is an example:

    Use ssh to connect to the server where OAT is installed.

    C:\Users\user001>ssh admin@xxx.xxx.xxx.xxx
    admin@xxx.xxx.xxx.xxx's password:
    
  2. Run the following command to enter the OAT container.

    Note

    To run the following command, you need to obtain the root privileges.

    docker exec -it oat bash
    

    Here is an example:

    [admin@xxx /home/admin]
    $sudo docker exec -it oat bash
    

    The return result is as follows:

    [root@xxx oat]#
    
  3. (Optional) Run the following command to view the usage of oat-cli.

    oatcli --help
    

    For more information about oat-cli commands, see oat-cli.

    Here is an example:

    [root@xxx oat]# oatcli --help
    

    The return result is as follows:

    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                                                  │
    ╰─────────────────────────────────────────────────────────────────────────────────────────╯
    
  4. Set the OAT API address, username, and password to call the OAT API.

    oatcli config set [OPTIONS]
    

    The options are described as follows:

    • -s, --api-server TEXT: the API server address, for example: 127.0.0.1:7000.
    • -u, --username TEXT: the username.
    • -p, --password TEXT: the password.
    • --help: display this message and exit.

    Here is an example:

    [root@xxx oat]# oatcli config set -sxxx.xxx.xxx.1:7000 -uadmin -p******
    

    The return result is as follows:

    11:14:16 [INFO] update {'api_server': 'xxx.xxx.xxx.1:7000', 'username': 'admin', 'password': '******'} to /root/.oatcli/config.json
    
  5. Create a DC.

    Create the DC information for a server as follows:

    oatcli create idc [OPTIONS] NAME REGION
    

    The parameters are described as follows:

    • NAME: the name of the DC [required].
    • REGION: the region where the DC is located [required].

    The options are described as follows:

    • --help: display this message and exit.

    Here is an example:

    Create a DC named hz0 in the hangzhou region.

    [root@xxx oat]# oatcli create idc hz0 hangzhou
    

    The return result is as follows:

    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'}                                                                           │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
    
  6. Create a credential.

    Create an SSH credential for connecting to a server as follows:

    oatcli create credential [OPTIONS] NAME AUTH_TYPE:{password|pubkey|external}
    

    The parameters are described as follows:

    • NAME: the name of the credential [required].

    • AUTH_TYPE:{password|pubkey|external}: the authentication type [required].

      • password: password authentication.
      • pubkey: public key authentication.
      • external: password-free authentication has been configured.

    The options are described as follows:

    • -u, --username TEXT: [default value: root].
    • -p, --password TEXT: the password.
    • -k, --key-file PATH: the path of the private SSH key file.
    • --help: display this message and exit.

    Here is an example:

    Create a credential named root_148, set the user type to root, and set the authentication type to password authentication.

    [root@xxx oat]# oatcli create credential -uroot -p****** root_148 password
    

    The return result is as follows:

    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'                                                                     │
    │ }                                                                                                                        │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
    
  7. Add an OBServer node (add and initialize the server).

    oatcli create server [OPTIONS] IPS... INIT_TAG:{observer|obproduct|both}
    

    The options are described as follows:

    • -i, --idc TEXT: the name of the DC:region, which must already exist [required].

    • -c, --credential-name TEXT: the name of the credential, which must already exist [required].

    • --add-only | --no-add-only: specifies whether to initialize the server after it is added [default value: --no-add-only].

      • --add-only: adds the server without performing operating system configuration.
      • --no-add-only: performs operating system configuration.
    • --ssh-port INTEGER: the SSH port [default value: 22].

    • --docker-root-dir TEXT: [default path: /docker].

    • --admin-uid-gid TEXT: [default value: 500:500].

    • --admin-password TEXT: the password.

    • --help: display this message and exit.

    The parameters are described as follows:

    • IPS...: the IP addresses of the server [required].

    • INIT_TAG:{observer|obproduct|both}: the purpose of the server [required].

      • observer: OBServer is installed.
      • obproduct: OceanBase product service is installed.
      • both: Both OBServer and OceanBase product service are installed.

    Here is an example:

    Add an OBServer node named hz0-1, use the credential root_148, use the DC:region hz0:hangzhou, and set the purpose to observer.

    [root@xxx oat]# oatcli create server -ihz0:hangzhou -croot_148 xxx.xxx.xxx.2 observer
    

    The return result is as follows:

    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&region=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}                                                                          │
    │ }                                                                                                                                                    │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
    
  8. Check whether the server has been added.

    View the details of the server and the relevant dagrun information.

    oatcli describe server [OPTIONS] IP
    

    The parameters are described as follows:

    IP: the IP address of the server [required].

    The options are described as follows:

    --help: display this message and exit.

    Here is an example:

    [root@xxx oat]# oatcli describe server xxx.xxx.xxx.2
    

    The return result is as follows:

    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 │
    └───────────────────┴────────────┴─────────────────────────────┴─────────────────────────────┘
    
  9. Obtain resource information in OAT.

    oatcli get [OPTIONS] COMMAND [ARGS]...
    

    The options are described as follows:

    • --help: display this message and exit.

    The commands are described as follows:

    • component: get component information.
    • credential: get credential information.
    • idc: get DC information.
    • image: get image information.
    • product: get product information.
    • server: get server information.

    Here is an example:

    Obtain the server list information.

    [root@xxx oat]# oatcli get server
    

    The return result is as follows:

    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          │
    └────┴───────────────┴─────────┴────────────────────────────────────────────────┴─────────────┴───────────────┘
    

Next steps

After the server is initialized, you can deploy an OceanBase cluster in one of the following ways:

References

Contact Us