You can use OBClient to connect to a user tenant of OceanSeek. This topic describes the prerequisites and procedure, and provides an example to help you get started.
Prerequisites
OBClient is downloaded and installed. If it is not downloaded, download the required version from OceanBase Download Center.
The client is in the allowlist of the tenant. For more information about how to query and configure a tenant allowlist, see View and set tenant allowlists.
Procedure
Connect via ODP
Run the following OBClient command to connect to OceanSeek by using OceanBase Database Proxy (ODP):
obclient -h$host -P$port -u$user_name -p****** [-c] [-A] [$database_name]
Parameter description:
-hspecifies the IP address for connecting to OceanSeek. Replace$hostwith the actual IP address of ODP used for connection.-Pspecifies the port for connecting to OceanSeek. Replace$portwith the port customized when ODP is deployed. The default value is2883.-uspecifies the tenant account for connecting to OceanSeek.$user_namecan be in any of the following formats:username@tenant_name#cluster_name,cluster_name:tenant_name:username,cluster_name-tenant_name-username, andcluster_name.tenant_name.username. The default username of the administrator of a user tenant isroot.Note
- When connecting to an OceanSeek cluster via ODP, you can use the following method to obtain the cluster name:
First, connect directly to OceanSeek. Then, use theSHOW PARAMETERS LIKE 'cluster';command to retrieve the name of the cluster. This command returns the name of the OceanSeek cluster corresponding to the value ofVALUE. - If ODP proxies multiple clusters, you must specify the cluster name when connecting. If ODP proxies only one cluster, specifying the cluster name is not required.
- When connecting to an OceanSeek cluster via ODP, you can use the following method to obtain the cluster name:
-pspecifies the account password for connecting to OceanSeek. Replace******with the actual password.Note
For security purposes, we recommend that you do not directly enter the password on the CLI, especially in an environment where the script or historical records are visible. You can skip this option and enter the password when being prompted to.
-cis optional, which specifies that comments are not ignored in the runtime environment of OBClient.Note
Hints are special comments that are not affected by the
-coption.-Ais optional, which specifies that the statistics are not automatically retrieved when you connect to OceanSeek through OBClient.$database_nameis optional, which specifies the default database to be used after the connection to OceanSeek is established. If you do not specify this option, no database is accessed after the connection is established, and you must manually select a database.
Example:
obclient -h10.10.10.1 -P2883 -uuser001@obtenant#obdemo -p****** -c -A oceanbase
Connect to OceanSeek by using ODP and SERVICE_NAME
You can also log in to OceanSeek by using the IP:PORT and SERVICE_NAME of ODP. ODP will convert SERVICE_NAME into -uuser_name@primary_tenant_name#cluster_of_primary_tenant, so that you do not need to manually change the connection string after a primary/standby switchover.
Notice
This feature depends on OceanBase Cloud Platform (OCP). OCP must be V4.3.1 or later, and OCP must have taken over the OceanSeek cluster for this feature to work properly.
The following command is used to connect to OceanSeek by using ODP and SERVICE_NAME:
obclient -h$host -P$port -u$user_name@SERVICE:$service_name -p******
Parameter description:
$host: The IP address of ODP.$port: The port number of ODP.$user_name: The username.$service_name: The service name.-pspecifies the account password for connecting to OceanSeek. Replace******with the actual password.
Example:
obclient -h10.10.10.1 -P2883 -uuser001@SERVICE:service_mysql001 -p******
Connect by using direct connection
The following command is used to connect to OceanSeek directly:
obclient -h$host -P$port -u$user_name -p****** [-c] [-A] [$database_name]
Parameter description:
-hspecifies the IP address for connecting to OceanSeek. Replace$hostwith the actual IP address of the OBServer node for direct connection.Notice
When you use the direct connection method, make sure that the tenant resources are distributed on the OBServer node you specified. Otherwise, you cannot connect to the tenant by using this OBServer node.
-Pspecifies the port for connecting to OceanSeek. Replace$portwith the port customized when OceanSeek is deployed. The default value is2881.-uspecifies the tenant account for connecting to OceanSeek. The format of$user_nameisusername@tenant_name. The default username of the administrator of a user tenant isroot.Notice
When you directly connect to OceanSeek, specify the username and tenant name in the format of
username@tenant_namefor the-uoption, and do not specify the cluster name. If you include the cluster name in-u, a connection error is returned.-pspecifies the account password for connecting to OceanSeek. Replace******with the actual password.Note
For security purposes, we recommend that you do not directly enter the password on the CLI, especially in an environment where the script or historical records are visible. You can skip this option and enter the password when being prompted to.
-cis optional, which specifies that comments are not ignored in the runtime environment of OBClient.Note
Hints are special comments that are not affected by the
-coption.-Ais optional, which specifies that the statistics are not automatically retrieved when you connect to OceanSeek through OBClient.$database_nameis optional, which specifies the default database to be used after the connection to OceanSeek is established. If you do not specify this option, no database is accessed after the connection is established, and you must manually select a database.
Example:
obclient -h10.10.10.1 -P2881 -uuser001@obtenant -p****** -c -A oceanbase
Connection example
Open a command-line terminal.
Use OBClient to connect to a user tenant of OceanSeek by using ODP.
obclient -hxxx.xx.xxx.xxx -P2883 -uroot@mysql001#test432 -p****** -A oceanbaseThe return result is as follows:
Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 16 Server version: OceanBase 4.3.2.0 (r200000272024061717-93c0ed73ebbcac6edbf7b585860b75d825935358) (Built Jun 17 2024 18:06:04) Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. obclient [oceanbase]>To exit the OBClient command line, enter
exitand press Enter, or press the shortcut key Ctrl + D.