You can deploy obconfigserver separately or together with OceanBase Database and OceanBase Database Proxy (ODP). This topic describes several common deployment methods.
Components
oceanbase-ce
OceanBase Database Community Edition. OceanBase Database is an enterprise-level, native distributed database independently developed by the OceanBase team. For more information, see OceanBase Database documentation.
obproxy-ce
ODP, also known as OBProxy, which is a dedicated proxy service designed for OceanBase Database. For more information, see ODP documentation.
obconfigserver
obconfigserver, which allows you to register, store, and query metadata of OceanBase Database. For more information, see ob-configserver.
Prerequisites
Make sure that the following conditions are met:
To deploy obconfigserver directly, ensure OceanBase Deployer (obd) is at least V2.3.0. Adding obconfigserver to a cluster requires obd V2.5.0 or later. We recommend that you install the latest version. For more information, see Install obd.
Note
We recommend that you download the OceanBase All in One package for deployment. The package provides all required components (except obbinlog) of the recommended versions, and the components have passed adaptation tests.
Your server can connect to the Internet, or the local image repository of obd contains the installation packages required for deployment.
You can run the
obd mirror list localcommand to query the installation packages in the local image repository. If obd is installed by using the OceanBase All in One package, the local image repository contains all installation packages required for deployment by default.When deploying an OceanBase cluster as MetaDB, you must ensure that the OBServer node machines support the AVX instruction set (this restriction applies only to x86 architecture servers). You can check if AVX is supported by running the command
lscpu | grep Flags | grep avx.
Procedure
This section describes how to deploy obconfigserver by using obd commands in different scenarios. You can select a deployment method as needed.
Deploy obconfigserver together with OceanBase Database and ODP
You can deploy obconfigserver, OceanBase Database, and ODP by using the same configuration file. After deployment, the OceanBase cluster will be registered with obconfigserver and ODP will start by using ConfigUrl. In other words, you can use ODP to connect to any clusters registered with obconfigserver.
Notice
If you use ODP to connect to OceanBase Database, make sure that the
observer_sys_passwordvalue in ODP is consistent with the password of theproxyro@sysuser in OceanBase Database. Otherwise, an error occurs during connection.Add obconfigserver to a cluster
You can run the
obd cluster component addcommand to add obconfigserver to an OceanBase cluster managed by obd. Existing ODP in the cluster will start by using the ConfigUrl of obconfigserver after this command is executed and ODP restarts.Deploy obconfigserver only
You can deploy obconfigserver separately. After the deployment, you need to register the OceanBase cluster with obconfigserver and modify the
obproxy_config_server_urlparameter of ODP. For more information, see Use obconfigserver.
Step 1: Modify the configuration file
Create a configuration file named config.yaml. The parameters for the components in the configuration file are described as follows:
User configuration
## Only need to configure when remote login is required user: username: admin # password: your password if need key_file: /home/admin/.ssh/id_rsa # port: your ssh port, default 22 # timeout: ssh connection timeout (second), default 30usernamespecifies the username of the account used to log in to the target server. Make sure that this account has the write permission onhome_path.passwordandkey_fileare used for user verification. Generally, you need to specify only one of them.Notice
After you specify the path of the key, comment out or delete the
passwordparameter if your key does not require a password. Otherwise, the value of thepasswordparameter will be taken as the password of the key and used for login, leading to a login verification failure.OceanBase Database configuration
oceanbase-ce: depends: - ob-configserver servers: - name: server1 # Please don't use hostname, only IP can be supported ip: 10.10.10.2 - name: server2 ip: 10.10.10.3 - name: server3 ip: 10.10.10.4 global: # The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field. home_path: /home/admin/observer # The directory for data storage. The default value is $home_path/store. # data_dir: /data # The directory for clog, ilog, and slog. The default value is the same as the data_dir value. # redo_dir: /redo # Please set devname as the network adaptor's name whose ip is in the setting of severs. # if set severs as "127.0.0.1", please set devname as "lo" # if current ip is 192.168.1.10, and the ip's network adaptor's name is "eth0", please use "eth0" devname: eth0 cluster_id: 1 # please set memory limit to a suitable value which is matching resource. memory_limit: 6G # The maximum running memory for an observer system_memory: 1G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G. datafile_size: 20G # Size of the data file. log_disk_size: 15G # The size of disk space used by the clog files. cpu_count: 16 scenario: htap mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started. rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started. obshell_port: 2886 production_mode: false enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true. max_syslog_file_count: 4 # The maximum number of reserved log files before enabling auto recycling. The default value is 0. # Cluster name for OceanBase Database. The default value is obcluster. When you deploy OceanBase Database and obproxy, this value must be the same as the cluster_name for obproxy. appname: test root_password: ****** # root user password proxyro_password: ****** # proxyro user password, consistent with obproxy's observer_sys_password, can be empty server1: zone: zone1 server2: zone: zone2 server3: zone: zone3For more information about the parameters in configuration files, see the Parameters section in Configuration files. The key parameters are described as follows:
depends: You must configure the oceanbase-ce component to depend on the ob-configserver component. Otherwise, your OceanBase cluster cannot be registered with obconfigserver.appname: It specifies the name of your OceanBase cluster. If you do not specify this parameter, your cluster cannot be registered with obconfigserver.scenario: If you do not specify thescenarioparameter in the configuration file when you deploy OceanBase Database V4.3.0 or later, obd provides interactive options for you to select a load type.
ODP configuration
obproxy-ce: # Set dependent components for the component. # When the associated configurations are not done, obd will automatically get the these configurations from the dependent components. depends: - oceanbase-ce - ob-configserver servers: - 10.10.10.5 global: listen_port: 2883 # External port. The default value is 2883. prometheus_listen_port: 2884 # The Prometheus port. The default value is 2884. rpc_listen_port: 2885 home_path: /home/admin/obproxy # oceanbase root server list # format: ip:mysql_port;ip:mysql_port. When a depends exists, obd gets this value from the oceanbase-ce of the depends. # rs_list: 10.10.10.1:2881;10.10.10.2:2881;10.10.10.3:2881 enable_cluster_checkout: false # observer cluster name, consistent with oceanbase-ce's appname. When a depends exists, obd gets this value from the oceanbase-ce of the depends. # cluster_name: obcluster skip_proxy_sys_private_check: true enable_strict_kernel_release: false # obproxy_sys_password: # obproxy sys user password, can be empty. When a depends exists, obd gets this value from the oceanbase-ce of the depends. # observer_sys_password: # proxyro user password, consistent with oceanbase-ce's proxyro_password, can be empty. When a depends exists, obd gets this value from the oceanbase-ce of the depends.For more information about the parameters in configuration files, see the Parameters section in Configuration files. Do not configure the
rs_listparameter. Otherwise, ODP cannot obtain information about clusters registered with obconfigserver.obconfigserver configuration
ob-configserver: servers: - 10.10.10.1 global: listen_port: 8080 # The port of ob-configserver web server_ip: 0.0.0.0 # Listen to the ob-configserver server IP. When you want to listen to the specified IP address,use it. home_path: /home/admin/ob-configserver # The working directory for prometheus. ob-configserver is started under this directory. This is a required field. ## log config # log_level: info # Log printing level of ob-configserver. The default value is `info` # log_maxsize: 30 # The total size of manager ob-configserver.Log size is measured in Megabytes.The default value is 30 # log_maxage: 7 # The days of manager expired ob-configserver.Log retention days. The default value is 7 # log_maxbackups: 10 #The number of manager expired ob-configserver.Log. The default value is 10 # log_localtime: true # Switch of ob-configserver.Log naming with localtime. The default value is true # log_compress: true # Compress ob-configserver.Log switch. The default value is true ## vip config, configserver will generate url with vip_address and port and return it to the client ## do not use some random value that can't be connected # vip_address: "10.10.10.1" # vip_port:8080 ## storage config # storage: ## database type, support sqlite3 or mysql # sqlite3: # database_type: sqlite3 # connection_url: "/home/admin/ob-configserver/.data.db?cache=shared&_fk=1" # mysql: # database_type: mysql # connection_url: "$user:$password@tcp($IP:$PORT)/$metadb?parseTime=true"For parameters that are commented out in the configuration file, their default values are used. You can also uncomment the parameters and specify other values for them. The key parameters are described as follows:
server_ip: the access allowlist of obconfigserver. The default value is0.0.0.0, which indicates that access from all IP addresses of the server where obconfigserver resides is allowed.vip_addressandvip_port: the IP address and port used for load balancing. If multiple nodes are configured inservers, load balancing is required. After you configure load balancing, specify the IP address and port used for load balancing in the configuration file.database_type: the database type. Valid values aresqlite3andmysql. The default value issqlite3. The recommended value ismysql.connection_url: the URL for connecting to the database. The value ofconnection_urlis$home_path/.data.db?cache=shared&_fk=1by default when the database type issqlite3, and can be a URL for connecting to an OceanBase database or a MySQL database when the database type ismysql. The specified database user must have the privileges to perform DDL and DML operations on the database corresponding to the URL. If OceanBase Database is used, do not useoceanbaseas the database name. Otherwise, a message prompting no privileges is displayed.
Step 2: Start obconfigserver
Deploy obconfigserver.
[admin@obtest ~]$ obd cluster deploy test -c config.yamlHere is an example of deploying the
testcluster by using theconfig.yamlconfiguration file. You must change the cluster name and configuration file name based on the actual situation.Start obconfigserver.
[admin@obtest ~]$ obd cluster start testThe output is as follows, where you can see the access address of obconfigserver.
+-----------------------------------------------------------+ | ob-configserver | +---------+------+---------------+----------+--------+------+ | server | port | vip_address | vip_port | status | pid | +---------+------+---------------+----------+--------+------+ | 0.0.0.0 | 8080 | 10.10.10.1 | 8080 | active | 6270 | +---------+------+---------------+----------+--------+------+ curl -s 'http://10.10.10.1:8080/services?Action=GetObProxyConfig' Wait for observer init ok +-------------------------------------------------+ | oceanbase-ce | +---------------+---------+------+-------+--------+ | ip | version | port | zone | status | +---------------+---------+------+-------+--------+ | 10.10.10.2 | 4.3.5.0 | 2881 | zone1 | ACTIVE | +---------------+---------+------+-------+--------+ | 10.10.10.3 | 4.3.5.0 | 2881 | zone2 | ACTIVE | +---------------+---------+------+-------+--------+ | 10.10.10.4 | 4.3.5.0 | 2881 | zone3 | ACTIVE | +---------------+---------+------+-------+--------+ obclient -h10.10.10.2 -P2881 -uroot -p'********' -Doceanbase -A +----------------------------------------------------------------+ | obproxy-ce | +------------+------+-----------------+-----------------+--------+ | ip | port | prometheus_port | rpc_listen_port | status | +------------+------+-----------------+-----------------+--------+ | 10.10.10.5 | 2883 | 2884 | 2885 | active | +------------+------+-----------------+-----------------+--------+ obclient -h10.10.10.5 -P2883 -uroot@proxysys -p'********' -Doceanbase -A
Create a configuration file.
When you add obconfigserver to an OceanBase cluster managed by obd, you only need to configure the information about the ob-configserver component in the created configuration file. Here is an example:
ob-configserver: servers: - 10.10.10.1 global: listen_port: 8080 # The port of ob-configserver web server_ip: 0.0.0.0 # Listen to the ob-configserver server IP. When you want to listen to the specified IP address,use it. home_path: /home/admin/ob-configserver # The working directory for prometheus. ob-configserver is started under this directory. This is a required field. ## log config # log_level: info # Log printing level of ob-configserver. The default value is `info` # log_maxsize: 30 # The total size of manager ob-configserver.Log size is measured in Megabytes.The default value is 30 # log_maxage: 7 # The days of manager expired ob-configserver.Log retention days. The default value is 7 # log_maxbackups: 10 #The number of manager expired ob-configserver.Log. The default value is 10 # log_localtime: true # Switch of ob-configserver.Log naming with localtime. The default value is true # log_compress: true # Compress ob-configserver.Log switch. The default value is true ## vip config, configserver will generate url with vip_address and port and return it to the client ## do not use some random value that can't be connected # vip_address: "10.10.10.1" # vip_port:8080 ## storage config # storage: ## database type, support sqlite3 or mysql # sqlite3: # database_type: sqlite3 # connection_url: "/home/admin/ob-configserver/.data.db?cache=shared&_fk=1" # mysql: # database_type: mysql # connection_url: "$user:$password@tcp($IP:$PORT)/$metadb?parseTime=true"For parameters that are commented out in the configuration file, their default values are used. You can also uncomment the parameters and specify other values for them. The key parameters are described as follows:
server_ip: the access allowlist of obconfigserver. The default value is0.0.0.0, which indicates that access from all IP addresses of the server where obconfigserver resides is allowed.vip_addressandvip_port: the IP address and port used for load balancing. If multiple nodes are configured inservers, load balancing is required. After you configure load balancing, specify the IP address and port used for load balancing in the configuration file.database_type: the database type. Valid values aresqlite3andmysql. The default value issqlite3. The recommended value ismysql.connection_url: the URL for connecting to the database. The value ofconnection_urlis$home_path/.data.db?cache=shared&_fk=1by default when the database type issqlite3, and can be a URL for connecting to an OceanBase database or a MySQL database when the database type ismysql. The specified database user must have the privileges to perform DDL and DML operations on the database corresponding to the URL. If OceanBase Database is used, do not useoceanbaseas the database name. Otherwise, a message prompting no privileges is displayed.
Run the following command to add the component:
obd cluster component add test1 -c configserver.yamlIn this example, the target OceanBase cluster is named
test1and the configuration file for adding obconfigserver is namedconfigserver.yaml. In practice, use the actual names. You can run theobd cluster listcommand to query the cluster name, which is the value of theNamecolumn in the output.The output is as follows:
Connect to ob-configserver ok +-----------------------------------------------------------------+ | ob-configserver | +---------------+------+---------------+----------+--------+------+ | server | port | vip_address | vip_port | status | pid | +---------------+------+---------------+----------+--------+------+ | 10.10.10.1 | 8080 | 10.10.10.1 | 8080 | active | 2725 | +---------------+------+---------------+----------+--------+------+ curl -s 'http://10.10.10.1:8080/services?Action=GetObProxyConfig'If ODP has been deployed in the target cluster, two cases exist:
If the version of obd is V3.2.0 or later, obd allows you to choose whether to restart the cluster in an interactive manner. You can enter
restartin the output to restart ODP by using obconfigserver.Restart `obproxy-ce,oceanbase-ce` for test to take effect. You can do it manually later or enter `restart` now:If you directly press
Enteror enter another value instead ofrestart, obd will not restart the cluster. After the process ends, ODP still starts by using the RootService list.If obd is of a version earlier than V3.2.0, an
obd cluster restartcommand is provided in the output. You only need to copy and run the command. After the command is executed, ODP will restart by using obconfigserver.obd cluster restart demo -c obproxy-ce
Create a configuration file named config-only.yaml. The parameters for the components in the configuration file are described as follows:
Configure user information.
## Only need to configure when remote login is required user: username: admin # password: your password if need key_file: /home/admin/.ssh/id_rsa # port: your ssh port, default 22 # timeout: ssh connection timeout (second), default 30usernamespecifies the username of the account used to log in to the target server. Make sure that this account has the write permission onhome_path.passwordandkey_fileare used for user verification. Generally, you need to specify only one of them.Notice
After you specify the path of the key, comment out or delete the
passwordparameter if your key does not require a password. Otherwise, the value of thepasswordparameter will be taken as the password of the key and used for login, leading to a login verification failure.Configure the ob-configserver component.
ob-configserver: servers: - 10.10.10.1 global: listen_port: 8080 # The port of ob-configserver web server_ip: 0.0.0.0 # Listen to the ob-configserver server IP. When you want to listen to the specified IP address,use it. home_path: /home/admin/ob-configserver # The working directory for prometheus. ob-configserver is started under this directory. This is a required field. ## log config # log_level: info # Log printing level of ob-configserver. The default value is `info` # log_maxsize: 30 # The total size of manager ob-configserver.Log size is measured in Megabytes.The default value is 30 # log_maxage: 7 # The days of manager expired ob-configserver.Log retention days. The default value is 7 # log_maxbackups: 10 #The number of manager expired ob-configserver.Log. The default value is 10 # log_localtime: true # Switch of ob-configserver.Log naming with localtime. The default value is true # log_compress: true # Compress ob-configserver.Log switch. The default value is true ## vip config, configserver will generate url with vip_address and port and return it to the client ## do not use some random value that can't be connected # vip_address: "10.10.10.1" # vip_port:8080 ## storage config # storage: ## database type, support sqlite3 or mysql # sqlite3: # database_type: sqlite3 # connection_url: "/home/admin/ob-configserver/.data.db?cache=shared&_fk=1" # mysql: # database_type: mysql # connection_url: "$user:$password@tcp($IP:$PORT)/$metadb?parseTime=true"For parameters that are commented out in the configuration file, their default values are used. You can also uncomment the parameters and specify other values for them. The key parameters are described as follows:
server_ip: the access allowlist of obconfigserver. The default value is0.0.0.0, which indicates that access from all IP addresses of the server where obconfigserver resides is allowed.vip_addressandvip_port: the IP address and port used for load balancing. If multiple nodes are configured inservers, load balancing is required. After you configure load balancing, specify the IP address and port used for load balancing in the configuration file.database_type: the database type. Valid values aresqlite3andmysql. The default value issqlite3. The recommended value ismysql.connection_url: the URL for connecting to the database. The value ofconnection_urlis$home_path/.data.db?cache=shared&_fk=1by default when the database type issqlite3, and can be a URL for connecting to an OceanBase database or a MySQL database when the database type ismysql. The specified database user must have the privileges to perform DDL and DML operations on the database corresponding to the URL. If OceanBase Database is used, do not useoceanbaseas the database name. Otherwise, a message prompting no privileges is displayed.
Deploy obconfigserver.
[admin@obtest ~]$ obd cluster deploy config-only -c config-only.yamlHere is an example of deploying the
config-onlycluster by using theconfig-only.yamlconfiguration file. In practice, use the actual cluster names and configuration file names.Start obconfigserver.
[admin@obtest ~]$ obd cluster start config-onlyThe output is as follows, where you can see the access address of obconfigserver.
+-----------------------------------------------------------+ | ob-configserver | +---------+------+---------------+----------+--------+------+ | server | port | vip_address | vip_port | status | pid | +---------+------+---------------+----------+--------+------+ | 0.0.0.0 | 8080 | 10.10.10.1 | 8080 | active | 6270 | +---------+------+---------------+----------+--------+------+ curl -s 'http://10.10.10.1:8080/services?Action=GetObProxyConfig'
Use obconfigserver
This section describes how to register an OceanBase cluster with obconfigserver, view registration information, start ODP, and delete a cluster registered with obconfigserver.
Register an OceanBase cluster with obconfigserver
You can register an OceanBase cluster with obconfigserver by modifying the configuration file of the cluster or by executing SQL statements. You can select either method as needed.
Notice
You must configure the
appnameparameter in the configuration file of the OceanBase cluster to be registered. Otherwise, an error is returned during a restart afterobconfig_urlis configured.The OceanBase cluster to be registered must have been started. At present, you cannot register a cluster that is not started.
Run the
obd cluster edit-configcommand to edit the configuration file of an existing cluster and configureobconfig_urlin theglobalsection of the oceanbase-ce component.Here is an example:
obconfig_url: 'http://10.10.10.1:8080/services?Action=ObRootServiceInfo&ObCluster=test1'10.10.10.1:8080: the access address of obconfigserver. The address provided here is only for reference. You must change it based on the actual situation.test1: theappnamevalue of the OceanBase cluster to be registered. The value provided here is only for reference. You must change it based on the actual situation.
Run the
obd cluster reloadcommand to restart the cluster. Here is an example of restarting thetest1cluster:obd cluster reload test1After the restart, verify whether the cluster has been successfully registered with obconfigserver by referring to View registration information in obconfigserver.
Log in as the root user to the sys tenant of the cluster to be registered.
obclient -h<IP> -P<PORT> -uroot@sys -p -c -A #example obclient -h10.10.10.4 -P4883 -uroot@sys -p -c -AHere,
IPspecifies the IP address for connecting to OceanBase Database.PORTspecifies the port for connecting to OceanBase Database, which takes the value of themysql_portparameter in the case of direct connection, or the value of thelisten_portparameter in the case of connection through ODP.For more information about how to use OBClient to connect to an OceanBase cluster, see Connect to an OceanBase Database tenant by using OBClient.
View the value of the
obconfig_urlparameter.obclient> SHOW PARAMETERS LIKE 'obconfig_url';The output is as follows, indicating that
obconfig_urlis not configured for the cluster.+-------+----------+---------------+----------+--------------+-----------+-------+--------------------------+----------+---------+---------+-------------------+---------------+-----------+ | zone | svr_type | svr_ip | svr_port | name | data_type | value | info | section | scope | source | edit_level | default_value | isdefault | +-------+----------+---------------+----------+--------------+-----------+-------+--------------------------+----------+---------+---------+-------------------+---------------+-----------+ | zone3 | observer | 10.10.10.4 | 2882 | obconfig_url | STRING | | URL for OBConfig service | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE | | 1 | | zone1 | observer | 10.10.10.2 | 2882 | obconfig_url | STRING | | URL for OBConfig service | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE | | 1 | | zone2 | observer | 10.10.10.3 | 2882 | obconfig_url | STRING | | URL for OBConfig service | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE | | 1 | +-------+----------+---------------+----------+--------------+-----------+-------+--------------------------+----------+---------+---------+-------------------+---------------+-----------+Configure
obconfig_url.alter system set obconfig_url = 'http://10.10.10.1:8080/services?Action=ObRootServiceInfo&ObCluster=test1';10.10.10.1:8080is the access address of obconfigserver.test1is theappnamevalue of the OceanBase cluster to be registered, which you can obtain by executing theSHOW PARAMETERS LIKE 'cluster';statement after connecting to the cluster. The value provided here is only for reference. You must change it based on the actual situation.Log out of the OceanBase cluster and verify whether obconfigserver can parse the information about the cluster.
curl -s 'http://10.10.10.1:8080/services?Action=ObRootServiceInfo&ObCluster=test1' |jq .Note
After you register an OceanBase cluster with obconfigserver, you can query related information in obconfigserver after a few minutes.
The output is as follows, showing that the IP addresses and ports of OBServer nodes in the cluster are successfully parsed.
{
"Code": 200,
"Message": "successful",
"Success": true,
"Data": {
"ObClusterId": 1,
"ObRegionId": 1,
"ObCluster": "test1",
"ObRegion": "test1",
"ReadonlyRsList": [],
"RsList": [
{
"address": "10.10.10.4:4882",
"role": "LEADER",
"sql_port": 4881
}
],
"Type": "PRIMARY",
"timestamp": 1692699586370950
},
"Trace": "362172a2d5de734c",
"Server": "10.10.10.1",
"Cost": 1
}
View registration information in obconfigserver
View cluster details.
obd cluster display testHere takes the
testcluster where obconfigserver is deployed as an example. You can run theobd cluster listcommand to view the actual cluster name, which is the value of theNamecolumn in the output. You must change the cluster name based on the actual situation.The output is as follows:
Connect to ob-configserver ok +-------------------------------------------------------------------+ | ob-configserver | +---------------+-------+---------------+----------+--------+-------+ | server | port | vip_address | vip_port | status | pid | +---------------+-------+---------------+----------+--------+-------+ | 10.10.10.1 | 8080 | 10.10.10.1 | 8080 | active | 13616 | +---------------+-------+---------------+----------+--------+-------+ curl -s 'http://10.10.10.1:8080/services?Action=GetObProxyConfig' Connect to observer 10.10.10.1:2881 ok Wait for observer init ok +-------------------------------------------------+ | oceanbase-ce | +---------------+---------+------+-------+--------+ | ip | version | port | zone | status | +---------------+---------+------+-------+--------+ | 10.10.10.2 | 4.3.5.0 | 2881 | zone1 | ACTIVE | | 10.10.10.3 | 4.3.5.0 | 2881 | zone2 | ACTIVE | | 10.10.10.4 | 4.3.5.0 | 2881 | zone3 | ACTIVE | +---------------+---------+------+-------+--------+ obclient -h10.10.10.1 -P2881 -uroot -p'********' -Doceanbase -A cluster unique id: 253244ab-94b9-5def-9cbd-7a46e6c19621-1953714c460-00050304 Connect to obproxy ok +-------------------------------------------------------------------+ | obproxy-ce | +---------------+------+-----------------+-----------------+--------+ | ip | port | prometheus_port | rpc_listen_port | status | +---------------+------+-----------------+-----------------+--------+ | 10.10.10.5 | 2883 | 2884 | 2885 | active | +---------------+------+-----------------+-----------------+--------+ obclient -h10.10.10.1 -P2883 -uroot@proxysys -p'********' -Doceanbase -A Trace ID: ea4340b6-f35a-11ef-a019-00163e4cf51eView the clusters registered with obconfigserver.
Copy the access information of the ob-configserver component to view the OceanBase clusters registered with obconfigserver. You can use the
jqcommand to format the JSON output in a shell. To installjq, runsudo yum install jq.curl -s 'http://10.10.10.1:8080/services?Action=GetObProxyConfig' | jq .The output is as follows.
ObRootServiceInfoUrlListcontains information about the OceanBase cluster namedtest, indicating that the cluster has been registered with obconfigserver.{ "Code": 200, "Message": "successful", "Success": true, "Data": { "ObProxyBinUrl": "http://10.10.10.1:8080/client?Action=GetObProxy", "ObProxyDatabaseInfo": { "DataBase": "***", "MetaDataBase": "http://10.10.10.1:8080/services?Action=ObRootServiceInfo&User_ID=alibaba&UID=admin&ObRegion=obdv1", "Password": "***", "User": "***" }, "ObRootServiceInfoUrlList": [ { "ObRegion": "test", "ObRootServiceInfoUrl": "http://10.10.10.1:8080/services?Action=ObRootServiceInfo&ObCluster=test" } ], "Version": "4660b4b1f237893ba1da50a302e4c3e6" }, "Trace": "07a7cac129713d00", "Server": "10.10.10.1", "Cost": 0 }View details of the OceanBase cluster.
Visit the URL provided in the
ObRootServiceInfoUrlsection of the command output to view the details of the OceanBase cluster. Here is an example:curl -s 'http://10.10.10.1:8080/services?Action=ObRootServiceInfo&ObCluster=test' | jq .The output is as follows, showing that the IP addresses and ports of OBServer nodes in the cluster are successfully parsed.
{ "Code": 200, "Message": "successful", "Success": true, "Data": { "ObClusterId": 1, "ObRegionId": 1, "ObCluster": "test", "ObRegion": "test", "ReadonlyRsList": [], "RsList": [ { "address": "10.10.10.4:2882", "role": "LEADER", "sql_port": 2881 }, { "address": "10.10.10.3:2882", "role": "FOLLOWER", "sql_port": 2881 }, { "address": "10.10.10.2:2882", "role": "FOLLOWER", "sql_port": 2881 } ], "Type": "PRIMARY", "timestamp": 1694084002271443 }, "Trace": "2b2ee036276b068e", "Server": "10.10.10.1", "Cost": 3 }
Start ODP
ODP can start by using rs_list or obproxy_config_server_url. If you configure ODP to start by using rs_list, it can connect to only an OceanBase cluster specified by rs_list. If you configure ODP to start by using obproxy_config_server_url, it can connect to all OceanBase clusters registered with obconfigserver.
To enable ODP to start by using obproxy_config_server_url, run the obd cluster edit-config command to open the configuration file and add the following content to the global section of the obproxy-ce component:
obproxy_config_server_url: http://10.10.10.1:8080/services?Action=GetObProxyConfig
In this example, 10.10.10.1:8080 is the access address of obconfigserver. You must change it based on the actual situation.
Delete the registration information of a cluster
You can run the following command to delete the registration information of a cluster from obconfigserver. Here is an example of deleting the registration information of the test1 cluster:
curl -X DELETE 'http://10.10.10.1:8080/services?Action=ObRootServiceInfo&ObCluster=test1&ObClusterId=1&version=2' |jq .
In this example, 10.10.10.1:8080 is the access address of obconfigserver, which you can obtain by running the obd cluster display command. test1 is the name of the cluster whose registration information is to be deleted, which you can obtain from the appname value in the configuration file of the cluster, or by executing the SHOW PARAMETERS LIKE 'cluster'; statement after connecting to the cluster. You can obtain the value of ObClusterId from the cluster_id value in the configuration file of the cluster, or from the cluster details by referring to View registration information in obconfigserver.
The output is as follows:
{
"Code": 200,
"Message": "successful",
"Success": true,
"Data": "success",
"Trace": "caba1209b3a00c56",
"Server": "10.10.10.1",
"Cost": 4
}
View the cluster registration information in obconfigserver again.
curl -s 'http://10.10.10.1:8080/services?Action=GetObProxyConfig' |jq .
The output is as follows, showing that the registration information about the test1 cluster disappears.
{
"Code": 200,
"Message": "successful",
"Success": true,
"Data": {
"ObProxyBinUrl": "http://10.10.10.1:8080/client?Action=GetObProxy",
"ObProxyDatabaseInfo": {
"DataBase": "***",
"MetaDataBase": "http://10.10.10.1:8080/services?Action=ObRootServiceInfo&User_ID=alibaba&UID=admin&ObRegion=obdv1",
"Password": "***",
"User": "***"
},
"ObRootServiceInfoUrlList": [
{
"ObRegion": "test",
"ObRootServiceInfoUrl": "http://10.10.10.1:8080/services?Action=ObRootServiceInfo&ObCluster=test"
}
],
"Version": "4840ade8a158753aa5b9ea69ba014fc1"
},
"Trace": "d4b4b27fae24e7b4",
"Server": "10.10.10.1",
"Cost": 1
}
FAQ
What do I do if the error prepared statement not supported is returned when obconfigserver is started?
Symptom
If OceanBase Database serves as the MetaDB, the error prepared statement not supported is returned when obconfigserver is started. The log is as follows:
2022-11-16T09:52:14.47799+08:00 ERROR [12258,] caller=cmd/main.go:36:func1: start configserver failed: start config server: create configserver schema: sql/schema: reading schema information Error 1235: while parameter _ob_enable_prepared_statement is disabled, prepared statement not supported
[10.10.10.1:2882] [2022-11-16 09:52:14.459102] [YB42AC1EC731-0005EB5F1D83A0A7] fields: args:="[]"
Possible causes
When obconfigserver is started, the Prepared Statement (PS) feature is not enabled for OceanBase Database.
Solution
You can resolve the issue in the following ways:
Method 1: Add
interpolateParams=trueto the value ofconnection_urlfor obconfigserver in the configuration file. Here is an example:connection_url: "user:password@tcp(IP:PORT)/test?parseTime=true&interpolateParams=true"Method 2: Connect to the OceanBase cluster and set the
_ob_enable_prepared_statementparameter toTrue.Check whether the
_ob_enable_prepared_statementparameter is set toTrue.obclient> select name,value,svr_ip,svr_port from oceanbase.__all_virtual_sys_parameter_stat where name='_ob_enable_prepared_statement'; +-------------------------------+-------+---------------+----------+ | name | value | svr_ip | svr_port | +-------------------------------+-------+---------------+----------+ | _ob_enable_prepared_statement | False | 10.10.10.1 | 2882 | +-------------------------------+-------+---------------+----------+ 1 row in setSet the
_ob_enable_prepared_statementparameter toTrue.obclient> alter system set _ob_enable_prepared_statement='True';
What do I do if an error is returned when I use ODP to connect to a cluster registered with obconfigserver?
Symptom
An error is returned when ODP is used to connect to a cluster registered with obconfigserver. Here is an example:
$ obclient -h10.10.10.2 -P2883 -uroot@sys#cluster -p -Doceanbase -A
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization packet', system error: 11
Possible causes
ODP cannot use the configured username and password to access the OceanBase cluster.
Solution
You can resolve the issue in the following ways:
Method 1: Run the
obd cluster edit-configcommand to view the configuration file. Check whether theproxyro_passwordparameter in the configuration file of the OceanBase cluster and theobserver_sys_passwordparameter in the configuration file of ODP are set to the same value. If not, set the two parameters to the same value and perform a restart by using the command provided in the output. After the restart, you can use ODP to connect to the cluster.Method 2: Check whether the
proxyrouser exists in the OceanBase cluster.Log in as the root user to the sys tenant of the OceanBase cluster.
obclient -h10.10.10.2 -P2881 -uroot@sys -p -Doceanbase -ACheck whether the
proxyrouser exists in the cluster.select user,password from mysql.user;Take the following actions based on the return result:
If the
proxyrouser does not exist in the cluster, run the following command to create theproxyrouser and set the password to the value of theobserver_sys_passwordparameter in the configuration file of ODP:create user 'proxyro' identified by '*****';If the
proxyrouser exists in the cluster, run the following command to change the password of theproxyrouser to the value of theobserver_sys_passwordparameter in the configuration file of ODP:alter user 'proxyro' identified by '*****';