This topic describes how to deploy OceanBase Database Proxy (ODP) by using OceanBase Deployer (obd). To do so, perform the following steps:
Prepare the installation environment
Choose a suitable version
Install ODP by using obd
Perform a check after the installation
You can also deploy ODP in the following ways:
Deploy ODP by using OceanBase Cloud Platform (OCP). For more information, see Deploy ODP by using OCP.
Deploy ODP by using the CLI. For more information, see Deploy ODP by using the CLI.
Prerequisites
Architecture: x86_64 or ARM.
Operating system: Linux Red Hat (x86_64) of version 5, 6, 7, or later.
CPU: ODP occupies about 70% of the resources of a CPU core during operation.
Memory: ODP occupies about 100 MB of memory during operation.
Disk space: The disk space is determined by your data size. We recommend that you use a disk that has 10 GB or more of space.
OceanBase cluster: At least one OceanBase cluster is required. For more information, see Overview.
(Optional) obconfigserver: If the obconfigserver is deployed, you can configure
obproxy_config_server_urlto start ODP. In this case, ODP can serve as a proxy for all clusters registered with obconfigserver.
Choose a suitable version
If you install ODP for learning purposes, install the latest version. For a production environment, we recommend that you check the new features and fixed issues of each version.
ODP is now available as an open-source project. You can find the OBProxy project under the open-source OceanBase Database project. Click Releases to view the details of each version. Each version of ODP has been tested in terms of features, stress handling, and performance, and can be used with guaranteed performance.
Procedure
Notice
The following describes the deployment of OceanBase Database on an x86-based CentOS Linux 7.9 platform by using obd V2.10.0. The procedure may be different for other obd versions or on other OS platforms.
Before you deploy ODP, we recommend that you switch to a non-root user for data security.
Step 1: Download and install obd
Choose a proper method to download and install obd. If your server has access to the Internet and allows you to add a third-party YUM repository as the software source, you can run the following commands to install obd from the official software source of OceanBase:
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
sudo yum install -y ob-deploy
source /etc/profile.d/obd.sh
If your server does have access to the Internet, download the obd installation package from OceanBase Download Center by using another server, and then transfer the installation package to your server for installation. For more information, see Install and configure obd.
Step 2: Modify the configuration file
After obd is installed, you can view the configuration files provided by obd in the /usr/obd/example/ directory and select an appropriate configuration file as needed. The configuration file used in this example is named obproxy-only-example.yaml and located in the example/obproxy/ directory.
obproxy-ce:
version: 4.3.0.0
servers:
- 10.10.10.1
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
enable_obproxy_rpc_service: true
home_path: /home/admin/obproxy
obproxy_config_server_url: http://10.10.10.1:8080/services?Action=GetObProxyConfig
# rs_list: 10.10.10.1:2881;10.10.10.2:2881;10.10.10.3:2881
enable_cluster_checkout: false
skip_proxy_sys_private_check: true
enable_strict_kernel_release: false
cluster_name: obcluster
client_session_id_version: 2 #This parameter is used to specify whether to use the new logic to generate the client session ID. The parameter type is integer. The value range is [1, 2] and the default value is 2 (use the new logic).
proxy_id: 5 #This parameter is used to set the ID for an ODP. The parameter type is integer. The default value is 0 and the value range is [0, 8191].
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 pasword, consistent with oceanbase-ce's proxyro_password, can be empty. When a depends exists, obd gets this value
| Parameter | Required? | Default value | Description |
|---|---|---|---|
| version | No | Latest version | The version of ODP to be deployed. If this parameter is not specified, obd deploys the latest version of ODP by default. |
| servers | Yes | None | The servers where ODP is to be deployed. Specify each server in the format of - name: server identifier (line feed) ip: server IP address. You can specify multiple servers. The server identifiers must be unique. You can specify unique server IP addresses in the format of - <ip> (line feed) - <ip>, where - <ip> is equivalent to - name: server IP address (line feed) ip: server IP address. |
| listen_port | Yes | 2883 | The listening port of ODP. |
| prometheus_listen_port | Yes | 2884 | The Prometheus listening port of ODP. |
| rpc_listen_port | No | 2885 | The remote procedure call (RPC) service listening port of ODP.
NoteThis parameter is available in obd V2.10.0 and later. It takes effect when the value of the |
| enable_obproxy_rpc_service | No | true | Specifies whether to enable the RPC service of ODP. The default value true indicates to enable the RPC service. The value false indicates to disable the RPC service. When the value of this parameter is false, the rpc_listen_port parameter does not take effect.
Note
|
| home_path | Yes | None | The installation path of ODP. |
| obproxy_config_server_url | No | None | The URL of the config server. After this parameter is specified, ODP can serve as a proxy for all clusters registered with the config server. If the config server is not deployed, you can also specify the rs_list parameter. |
| rs_list | No | None | The OBServer node list of the OceanBase cluster, in the ip:mysql_port;ip:mysql_port format. If ODP is configured by using the RootService list, ODP can serve as a proxy only for the configured cluster.
Notice
|
| enable_cluster_checkout | No | true | Specifies whether to verify the cluster name. If you set the value to true, ODP sends the cluster name to the OBServer node for verification during login. |
| enable_strict_kernel_release | Yes | false | Specifies whether to verify the kernel of the operating system. The value true indicates that ODP supports only Linux Red Hat of version 5, 6, or 7. The value false indicates that the Linux kernel version is not verified. In this case, ODP may be unstable. |
| cluster_name | No | None | The name of the OceanBase cluster for which ODP can serve as a proxy. If a dependency exists, obd obtains this value from the oceanbase-ce dependency. |
| client_session_id_version | No | 2 | Specifies whether to use the new logic for generating client session IDs. Valid values are 1 and 2. The value 2 specifies to use the new logic for generating client session IDs.
NoteYou can set the |
| proxy_id | No | 0 | The ID of ODP. It ensures that client session IDs generated by different ODP nodes do not conflict. The value range of proxy_id varies based on the value of client_session_id_version.
NoteYou can set the |
| obproxy_sys_password | No |
|
The password of the ODP administrator account (root@proxysys). If you do not specify this parameter in obd V2.1.0 or later, a random string is automatically generated. After deployment, you can run the obd cluster edit-config command to view the password in the configuration file. |
| observer_sys_password | No | The default value is the same as that of proxyro_password if OceanBase Database is deployed at the same time. If ODP is independently deployed, the default value varies based on the obd version as follows:
|
The password of the account (proxyro@sys) used by ODP to connect to the OceanBase cluster. This password must be the same as the value of proxyro_password configured in OceanBase Database. Otherwise, you cannot connect to the OceanBase cluster by using ODP. |
Step 3: Deploy ODP
If your server has access to the Internet, perform steps 4 and 5 directly. If your server does not have access to the Internet, download the ODP installation package from the Releases page on GitHub or OceanBase Download Center, and then copy the installation package to the local image repository as follows.
Note
For more information about the obd commands used in this step, see Cluster commands.
Run the following command to disable the remote image repository:
obd mirror disable <mirror repo name>The
mirror repo nameparameter specifies the name of the image repository to be disabled. If you set this parameter toremote, all remote image repositories are disabled.Run the following command to copy the ODP installation package to the local image repository:
obd mirror clone <path> [-f]The
pathparameter specifies the path of the RPM package. The-foption indicates--force, which is optional and is disabled by default. When this option is enabled, if an image already exists, the image is forcibly overwritten.Run the following command to get the list of RPM packages in the local image repository:
obd mirror list localRun the following command to deploy ODP:
obd cluster deploy <deploy_name> -c <deploy_config_path>In the preceding command, the
deploy_nameparameter specifies the cluster name, which can be understood as the alias of the configuration file.deploy_config_pathspecifies the path of the configuration file.Note
During online installation, after you run the
obd cluster deploycommand, obd checks whether the ODP installation package exists in the local image repository. If no, obd automatically obtains the installation package from the YUM repository.Run the following command to start ODP:
obd cluster start <deploy_name>
Step 4: Perform a check after the installation
Run the following command to view the deployment result:
obd cluster display <deploy_name> # Examples [admin@test ~]$ obd cluster display obtest Get local repositories and plugins ok Open ssh connection ok Cluster status check ok Connect to observer ok Wait for observer init ok +----------------------------------------------+ | observer | +------------+---------+------+-------+--------+ | ip | version | port | zone | status | +------------+---------+------+-------+--------+ | 10.10.10.2 | 4.3.0.0 | 2881 | zone1 | ACTIVE | | 10.10.10.3 | 4.3.0.0 | 2881 | zone2 | ACTIVE | | 10.10.10.4 | 4.3.0.0 | 2881 | zone3 | ACTIVE | +------------+---------+------+-------+--------+ obclient -h10.10.10.2 -P2881 -uroot -p****** -Doceanbase Connect to obproxy ok +----------------------------------------------+ | obproxy | +------------+------+-----------------+--------+ | ip | port | prometheus_port | status | +------------+------+-----------------+--------+ | 10.10.10.1 | 2883 | 2884 | active | +------------+------+-----------------+--------+ obclient -h10.10.10.1 -P2883 -uroot -p****** -DoceanbaseThe ODP information is returned. 2883 in the
portcolumn indicates that port 2883 provides the SQL service. This port is required in the JDBC URL.After you check the status by using the
obd cluster displaycommand, you can log in to the server that hosts the obproxy process and run theps -ef | grep obproxycommand to view the process information.[admin@test ~]# ps -ef | grep obproxy | grep -v grep admin 6868 1 0 Nov12 ? 00:02:09 bash /home/admin/obproxy/obproxyd.sh /home/admin/obproxy 10.10.10.1 2883 daemon admin 6901 1 0 Nov12 ? 00:44:11 /home/admin/obproxy/bin/obproxy --listen_port 2883You can find the
obproxyd.shandobproxyprocesses in the return information of the preceding example.obproxyis the name of the ODP process, andobproxyd.shis the daemon script of ODP. Theobproxyd.shprocess is responsible for starting the obproxy process and performs health check on the obproxy process. If theobproxyprocess does not exist,obproxyd.shproactively pulls up the process.
FAQ
Startup failed
In a Linux system, ODP uses the enable_strict_kernel_release parameter to specify whether to check the operating system version. If the operating system fails the check, the startup fails. A sample key log is as follows:
[2021-10-13 10:38:17.235062] WARN [PROXY] get_kernel_release_by_uname (ob_config_server_processor.cpp:1039) [2060][Y0-0] [lt=14] [dc=0] unknown uname release(uinfo.release="4.18.0-80.el8.x86_64", ret=-4016)
You can run the uname command to view kernel information. This option supports only the EL series and AliOS series. The check strategies are conservative, and false errors may be reported. If you encounter the preceding issue in other Linux systems, you can disable the parameter to solve the problem.
Failed to connect to OceanBase Database
ODP establishes a connection with OceanBase Database by using the proxyro user. If the proxyro user does not exist or the password of the proxyro user is inconsistent with the value of the observer_sys_password parameter of ODP, ODP fails to connect to OceanBase Database, and the following error is reported:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization packet', system error: 11
In this case, select a solution based on the situation.
Select the following solution if the
proxyrouser does not exist:Directly connect to OceanBase Database as the
root@sysuser, and create theproxyrouser in the sys tenant.create user proxyro identified by '*******'; grant select on *.* to proxyro;Select one of the following solutions if the password of the
proxyrouser is inconsistent with the value of theobserver_sys_passwordparameter of ODP:Directly connect to OceanBase Database as the
root@sysuser and change the password of theproxyrouser to the value of theobserver_sys_passwordparameter specified during ODP startup.ALTER USER proxyro IDENTIFIED BY 'password';Log in to ODP with the
root@proxysysaccount and change the password ofproxyro@sys. Then, restart ODP.alter proxyconfig set observer_sys_password = 'password';
Notice
In the preceding statement, the value of password must be the original password rather than the SHA1-hash value of the password.