ODP forwards user-initiated data access requests to the correct OBServer node. When the backend OBServer node returns the requested data, ODP forwards the data back to the client. This topic describes how to deploy ODP by using the RPM package.
You can also deploy ODP by using the following methods:
Deploy ODP by using OCP. For more information, see Deploy ODP by using OCP.
Deploy ODP by using obd. For more information, see Deploy ODP by using obd
Notice
After ODP is deployed on a server, it provides proxy services for OceanBase Database by exposing an
ip:port. You can access OceanBase Database through thisip:portin the same way as you access a MySQL database. We recommend that you deploy ODP on an OBServer node.We recommend that you deploy only one ODP service on a server and use port 2883. If you deploy multiple ODP services on the same server, you must specify different ports and different configuration file paths for the services. You can also use port 3306, 1521, or any other port.
The IP addresses in the examples in this topic have been desensitized. When you use the corresponding commands, replace the IP addresses with those of your server.
Environment preparation
Platform: X86_64, ARM
Operating system: Linux Redhat 5u|6u|7u x86-64 or later
CPU: After ODP is started, the CPU usage is about 0.7 C.
Memory: After ODP is started, the memory usage is about 100 MB.
Disk space: There is no special requirement for the disk size. The disk size is determined based on the data size. We recommend that you use a disk of 10 GB or larger.
Install ODP
Run the following commands as the root user to grant write permissions to the sudoers file:
# Grant write permissions to the sudoers file. chmod u+w /etc/sudoers echo 'admin ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers # Revoke write permissions from the sudoers file. chmod u-w /etc/sudoersRun the following commands to install the ODP RPM package:
-bash-4.2$ cd $rpm_dir -bash-4.2$ sudo rpm -ivh $rpm_nameHere,
$rpm_dirindicates the directory where the RPM package is stored, and$rpm_nameindicates the name of the RPM package.Note
You can contact technical support to obtain the latest ODP RPM package. Alternatively, you can search for OceanBase Database Proxy on the OceanBase Software Download Center page and download the corresponding ODP RPM package based on your requirements.
The default installation directory for the Enterprise Edition of ODP is
/opt/taobao/install, and the default installation directory for the Community Edition of ODP is/home/admin.
Here is an example:
-bash-4.2$ sudo rpm -ivh obproxy-4.0.0-20221103165243.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:obproxy-4.0.0-20221103165243.el7 ################################# [100%](Optional) Create a symbolic link to ODP
Creating a symbolic link to ODP can hide the version information and make future operations easier. Here, we use the Enterprise Edition of ODP as an example to demonstrate how to create a symbolic link.
-bash-4.2$ cd /opt/taobao/install -bash-4.2$ sudo ln -s obproxy-4.0.0 obproxy -bash-4.2$ ll total 8 drwxr-xr-x 9 root root 4096 Sep 26 15:24 ajdk-8.3.6-b129 lrwxrwxrwx 1 root root 13 Nov 14 12:03 obproxy -> obproxy-4.0.0 drwxr-xr-x 4 admin admin 4096 Nov 14 11:59 obproxy-4.0.0 # Change the owner and group of obproxy to admin. -bash-4.2$ sudo chown -R admin:admin obproxy -bash-4.2$ ll total 8 drwxr-xr-x 9 root root 4096 Sep 26 15:24 ajdk-8.3.6-b129 lrwxrwxrwx 1 admin admin 13 Nov 14 12:03 obproxy -> obproxy-4.0.0 drwxr-xr-x 4 admin admin 4096 Nov 14 11:59 obproxy-4.0.0
Initialize ODP
ODP needs to communicate with the backend OBServer node. Therefore, you must create a user (proxyro) and a password for ODP under the sys tenant in the OceanBase cluster. When you start ODP later, you can set the proxy parameter to specify the proxy user.
Description
A proxyro user is an ODP user that is used to access OceanBase clusters. Each OceanBase cluster corresponds to one proxyro user account.
You can check whether the proxyro user exists in the cluster by referencing the following procedure:
Log in to the cluster by using an IP direct connection.
obclient -h10.10.10.1 -uroot@sys -P2881 -p -c -ARun the following command to view users in the SYS tenant:
obclient> select user,password from mysql.user;If the output result contains the proxyro user, you can directly run Start ODP. If the output result does not contain the proxyro user, run the following command to create it:
Create the proxyro user.
Here is a sample:
obclient> CREATE USER proxyro IDENTIFIED BY '******'; Query OK, 0 rows affected obclient> GRANT SELECT ON *.* TO proxyro; Query OK, 0 rows affected obclient> SHOW GRANTS FOR proxyro; +----------------------------------+ | Grants for proxyro@% | +----------------------------------+ | GRANT SELECT ON *.* TO 'proxyro' | +----------------------------------+ 1 row in set
Start ODP
You can start the ODP process in the following two ways:
Specify the
-rparameter in the startup command to specify the RootServer information of the OceanBase cluster.This method does not require additional configuration and is generally used during the development and debugging stages. After starting ODP by using this method, you must manually update the
rootservice_listconfiguration item and restart ODP to make the configuration take effect when the Root Service list in OceanBase Database changes.Specify the
obproxy_config_server_urlparameter in the startup command to query the RootServer information of the OceanBase cluster.This method requires you to configure the
obproxy_config_server_urlparameter and depends on the startup of the Config Server. We recommend that you use this method to start ODP.
Notice
Before you start ODP, log in as the admin user and execute the startup command in the home directory of the ODP software. Otherwise, unexpected issues may occur.
Procedure
Log in to the server where ODP is to be started as the admin user.
In the installation directory of ODP, run the following command to start ODP.
Note
Before you start ODP, you can run the
./bin/obproxy -hcommand to view the startup parameters of ODP.Method 1: Run the following command to start ODP and specify the
-rparameter in the command../bin/obproxy -p <obproxy_port> -s <rpc_port> -r <'ip:port'> -n <appname> -o -c <cluster_name>where:
-p: specifies the port number on which ODP listens. Clients connect to this port through MySQL to access OceanBase Database. You need to specify this parameter only during the initial startup. You do not need to specify this parameter during subsequent startups or upgrades.-s: specifies the port number on which the RPC service listens.-r: specifies the RootServer information of the OceanBase cluster, including the IP address and port number. The port number here refers to the SQL port of the OBServer node, not the RPC port.-n(optional): specifies the application name of the ODP to be started.You can modify the application name of ODP by using the
app_nameparameter. The default value isundefined.-o: specifies the hardware or kernel parameters. If you do not specify this parameter, the system default configuration is used.-c: specifies the OceanBase cluster.
Example:
[admin@001 obproxy]$ ./bin/obproxy -p 2883 -s 2885 -r'10.10.10.1:2881;10.10.10.2:2881;10.10.10.3:2881' -o observer_sys_password=$sha1_value,obproxy_sys_password=$sha1_value,enable_cluster_checkout=false,proxy_id=1,client_session_id_version=2 -n test -c myclusterNotice
observer_sys_passwordmust be consistent with the password of the proxyro user in OceanBase Database.obproxy_sys_passwordis the password for logging in to ODP as theroot@proxysysuser.$sha1_valuemust be replaced with the actual password. The password set here is the SHA1 hash value, not the original value. For example, if the password of the proxyro user is123456, you need to set the value ofobserver_sys_passwordto7c4a8d09ca3762af61e59520943dc26494f8941b.proxy_idis set to 1 in this example. You can setproxy_idto any value in the range of 0 to 8191 except 2, as long as it does not conflict with other ODPs. For more information, see proxy_id.
Method 2: Run the following command to start ODP and specify the
obproxy_config_server_urlparameter in the command../bin/obproxy -p <obproxy_port> -s <rpc_port> -n <appname> -o obproxy_config_server_url='your_config_url'where:
-p: specifies the port number on which ODP listens. Clients connect to this port through MySQL to access OceanBase Database. You need to specify this parameter only during the initial startup. You do not need to specify this parameter during subsequent startups or upgrades.-s: specifies the port number on which the RPC service listens.-n: specifies the application name.You can modify the application name of ODP by using the
app_nameparameter. The default value isundefined.-o: specifies the hardware or kernel parameters. If you do not specify this parameter, the system default configuration is used.obproxy_config_server_url: specifies the URL of the Config Server.
Example:
[admin@001 obproxy]$ ./bin/obproxy -p 2883 -s 2885 -n test -o obproxy_config_server_url='http://xx.xx.xx.xx:8877/obproxy_config',observer_sys_password=$sha1_value,obproxy_sys_password=$sha1_value,proxy_id=1,client_session_id_version=2Notice
observer_sys_passwordmust be consistent with the password of the proxyro user in OceanBase Database.obproxy_sys_passwordis the password for logging in to ODP as theroot@proxysysuser.$sha1_valuemust be replaced with the actual password. The password set here is the SHA1 hash value, not the original value. For example, if the password of the proxyro user is123456, you need to set the value ofobserver_sys_passwordto7c4a8d09ca3762af61e59520943dc26494f8941b.proxy_idis set to 1 for example. You can setproxy_idto any value in the range of 0 to 8191 except 2, provided that the value does not conflict with that of other ODPs. For more information, see proxy_id.
After the ODP is started, run the following command to check whether the ODP process exists.
[admin@001 ~]$ ps -ef | grep obproxy
Connect to OceanBase Database
When you connect to OceanBase Database by using ODP, the username must contain the cluster name, instance name, and username. The username can be in one of the following four formats. The first two formats are the most commonly used.
username@tenant name#cluster namecluster name:tenant name:usernamecluster name-tenant name-usernamecluster name.tenant name.username
$ obclient -h10.10.10.1 -uroot@sys#mycluster -P2883 -p -c -A
Enter password:
# or
$ obclient -h10.10.10.1 -umycluster:sys:root -P2883 -p -c -A
Enter password:
FAQ
Question: An error occurs when you connect to OceanBase Database by using ODP.
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization packet', system error: 0
Cause: The password of the observer_sys_password parameter in ODP is inconsistent with the password of the proxyro user in OceanBase Database. ODP cannot communicate with the OBServer node through this user.
Solution: You can choose one of the following solutions based on your business requirements.
Connect to OceanBase Database directly and modify the password of the proxyro user to be consistent with the password of the
observer_sys_passwordparameter when ODP is started.ALTER USER proxyro IDENTIFIED BY 'password';Log in to ODP by using the
root@proxysysaccount and modify the password of theproxyro@sysuser. After the password is modified, you need to restart ODP.alter proxyconfig set observer_sys_password = 'password';
Notice
In the preceding statements, password must be the original password, not the SHA1 value.
