OceanBase Database Proxy (ODP) can forward the data access requests of users to OBServer nodes. The results are returned to the clients through ODP.
This topic describes how to install ODP by using the ODP package.
Notice
- After you deploy ODP on a server, ODP provides the proxy service of OceanBase Database by exposing a socket in the format of
IP address:port. You can access OceanBase Database through the socket in the same way you access MySQL databases. We recommend that you deploy ODP on an OBServer node. - We recommend that you deploy only one ODP on a server and use port
2883. If you deploy multiple ODPs on the same server, you need to specify different ports and configuration file paths for differentiation. You can set the port number to3306,1521, or other port numbers.
Procedure
Step 1: Install the ODP RPM package
$rpm_dir specifies the directory in which the RPM package is stored. $rpm_name specifies the name of the RPM package.
[root@xxx /]# cd $rpm_dir
[root@xxx $rpm_dir]# rpm -ivh $rpm_name
Note
ODP is installed in the /opt/taobao/install directory.
Example:
[root@xxx admin]# rpm -ivh obproxy-4.0.0-20230109154442.el7.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:obproxy-4.0.0-20230109154442.el7 ################################# [100%]
Step 2: Configure directories
- (Optional) Create a soft link to ODP.
Note
A soft link to ODP can hide the version information, facilitating subsequent operations.
ODP is installed in the /opt/taobao/install directory. The home directory of the obproxy process is /opt/taobao/install/obproxy, which is a soft link that points to the directory of ODP of the corresponding version.
[root@xxx admin]# su - admin
-bash-4.2$ cd /opt/taobao/install
-bash-4.2$ ls
ajdk-8.3.6-b129 obproxy-4.0.0
#Create a soft link to ODP.
-bash-4.2$ sudo ln -s obproxy-4.0.0 obproxy
[sudo] password for admin:
-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 Jan 29 16:51 obproxy -> obproxy-4.0.0
drwxr-xr-x 5 admin admin 4096 Jan 29 16:42 obproxy-4.0.0
-- Change the owner and group of the obproxy process to admin.
[root@xxx install]# chown -R admin:admin obproxy
[root@xxx install]# ll
total 8
drwxr-xr-x 9 root root 4096 Sep 26 15:24 ajdk-8.3.6-b129
lrwxrwxrwx 1 admin admin 13 Jan 29 16:51 obproxy -> obproxy-4.0.0
drwxr-xr-x 5 admin admin 4096 Jan 29 16:42 obproxy-4.0.0
Establish an operation log directory for the obproxy process.
The operation log directory of the obproxy process points to
/home/admin/logs/obproxy/logthrough a soft link.[root@xxx admin]# su - admin # Create a log directory -bash-4.2$ mkdir -p /home/admin/logs/obproxy/log # View the obproxy process directory -bash-4.2$ tree /opt/taobao/install/obproxy /opt/taobao/install/obproxy |-- bin | |-- obp_xflush.py | |-- obproxy | |-- obproxyd.sh | `-- unzip.py |-- lib | |-- libgpr.so.7 | |-- libgrpc++.so.1 | |-- libgrpc++_cronet.so.1 | |-- libgrpc.so.7 | |-- libgrpc_cronet.so.7 | |-- libobproxy_so.so | |-- libprotobuf.so.18 | `-- libstdc++.so.6 |-- log -> /home/admin/logs/obproxy/log |-- minidump -> /home/admin/logs/obproxy/minidump |-- start_obproxy.sh `-- tools |-- dump_syms |-- log4cplus.conf |-- minidump.sh |-- minidump_stackwalk `-- obproxy.sym 3 directories, 20 files
Step 3: Initialize the ODP account
ODP needs to communicate with the backend OBServer node. Therefore, you need to create a user (proxyro) under the sys tenant of the OceanBase cluster and specify a password for the user. When you start ODP later, you can specify the username and password of the proxyro user in the startup parameters.
Note
ODP can use the proxyro user to access the OceanBase cluster. One proxyro user can be used for accessing one OceanBase cluster.
Example:
Create the proxyro user and grant the SELECT privilege to the user.
$obclient -hxxx.xxx.xxx.1 -P2881 -uroot@sys -p
Enter password:
obclient [(none)]> CREATE USER proxyro IDENTIFIED BY '******';
Query OK, 0 rows affected
obclient [(none)]> GRANT SELECT ON *.* TO proxyro;
Query OK, 0 rows affected
obclient [(none)]> SHOW GRANTS FOR proxyro;
+----------------------------------+
| Grants for proxyro@% |
+----------------------------------+
| GRANT SELECT ON *.* TO 'proxyro' |
+----------------------------------+
1 row in set
Step 4: Start ODP
Notice
Start ODP from its home directory as the admin user. Problems may occur if you start ODP from other directories or as other users.
When ODP starts, it needs to know the target OceanBase cluster, which is specified by the
rootservice_listparameter.Startup code:
cd /opt/taobao/install/obproxy && bin/obproxy -r "xxx.xxx.xxx.1:2881;xxx.xxx.xxx.2:2881;xxx.xxx.xxx.3:2881" -p 2883 -o "observer_sys_password=$sha1_value,enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false" -c tenant_name
Note
- Replace the password in
$sha1_valuewith the actual password. When you set the startup parameter of ODP, the password is the value behindsha1instead of the original value. For example, if the password of the proxyro user is123456, theobserver_sys_passwordparameter must be set to7c4a8d09ca3762af61e59520943dc26494f8941b. - The IP addresses in the sample code are for reference only. You need to enter the actual server IP address.
Parameters:
| Parameter | Description |
|---|---|
-r |
The IP address and port of the OBServer node. |
-p |
The service port number, which is usually set to 2883. |
-c |
The name of the cluster. |
-o |
The hardware or kernel parameter configuration. |
Example:
[root@xxx admin]# su - admin
-bash-4.2$ cd /opt/taobao/install/obproxy && bin/obproxy -r "xxx.xxx.xxx.1:2881" -p 2883 -o "observer_sys_password=7c4a8d09ca3762af61e59520943dc26494f8941b,enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false" -c test3241
bin/obproxy -r xxx.xxx.xxx.1:2881 -p 2883 -o observer_sys_password=7c4a8d09ca3762af61e59520943dc26494f8941b,enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false -c test3241
rs list: xxx.xxx.xxx.1:2881
listen port: 2883
optstr: observer_sys_password=7c4a8d09ca3762af61e59520943dc26494f8941b,enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false
cluster_name: test3241
After ODP starts, you can check whether the obproxy process exists.
ps -ef|grep obproxyExample:
[root@xxx admin]# ps -ef|grep obproxy admin 79111 0 6 17:32 ? 00:00:58 bin/obproxy -r xxx.xxx.xxx.1:2881 -p 2883 -o observer_sys_password=7c4a8d09ca3762af61e59520943dc26494f8941b,enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false -c test3241
What to do next
Connect to OceanBase Database
When you connect to OceanBase Database through ODP, you must combine the username, tenant name, and cluster name. Valid format: Username@Tenant name#Cluster name or Cluster name:Tenant name:Username.
Example:
Use Username@Tenant name#Cluster name to connect to OceanBase Database.
[admin@xxx /home/admin] $obclient -hxxx.xxx.xxx.1 -P2883 -uroot@sys#test3241 -p****** Welcome to the OceanBase. Commands end with ; or \g. ... Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. obclient [(none)]>Use Cluster name:Tenant name:Username to connect to OceanBase Database.
[admin@xxx /home/admin] $obclient -hxxx.xxx.xxx.1 -P2883 -utest3241:sys:root -p****** Welcome to the OceanBase. Commands end with ; or \g. ...... 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 [(none)]>
(Optional) Adjust ODP parameters
You can set parameters such as the operation log volume or CPU consumption based on the server specifications by modifying ODP parameters.
Example:
The following example shows the parameter configurations of ODP. You can adjust the parameter configurations to decrease the operation log volume or CPU consumption.
obclient [(none)]> ALTER PROXYCONFIG SET slow_proxy_process_time_threshold='1000ms';
Query OK, 0 rows affected
obclient [(none)]> ALTER PROXYCONFIG SET xflush_log_level=ERROR;
Query OK, 0 rows affected
obclient [(none)]> ALTER PROXYCONFIG SET syslog_level=WARN;
Query OK, 0 rows affected
obclient [(none)]> ALTER PROXYCONFIG SET enable_compression_protocol=false;
Query OK, 0 rows affected
obclient [(none)]> SHOW PROXYCONFIG LIKE '%compress%'\G
*************************** 1. row ***************************
name: enable_compression_protocol
value: False
info: if enabled, proxy will use compression protocol with server
need_reboot: false
visible_level: USER
*************************** 2. row ***************************
name: enable_syslog_file_compress
value: False
info: Whether to enable archive log compression
need_reboot: false
visible_level: SYS
2 rows in set
More information
- For more information about how to deploy ODP, see Deployment methods.
- For more information about how to adjust ODP parameters, see Parameter description.
- For more information about how to use ODP to connect to OceanBase Database, see Connection management.