Basic operations

2025-03-21 09:20:28  Updated

View the version

After OceanBase Database Proxy (ODP) is installed, check the version of ODP in the following ways:

  1. View the directory of the ODP. The directory of the ODP of the new version contains the version number. For example, the obproxy-4.0.0 directory indicates ODP version 4.0.0.

  2. Run the ./bin/obproxy -V command in the home directory of the ODP to view the version of the ODP. Take version 3.2.3 as an example:

    [admin@test obproxy]# ./bin/obproxy -V
    ./bin/obproxy -V
    obproxy (OceanBase 3.2.3 2)
    REVISION: 6-local-99faebfc7130b70ad0f56330a28cab6a32ec9a33
    BUILD_TIME: Mar 30 2022 01:53:08
    
  3. Log on to the ODP with the root@proxysys account, and run the show proxyinfo binary command to view the version of the ODP. Take version 4.0.0 as an example:

    MySQL [(none)]> show proxyinfo binary\G
    *************************** 1. row ***************************
    name: binary info
    info: ObProxy-OceanBase 4.0.0-20221103165243.el7
    version:RELEASE_7U
    MD5
    REVISION:20221103165243-7c7e5821009b2d3924d1bc7a8165edf7384f6ed3
    BUILD_TIME:Nov  3 2022 16:57:16
    

Connect to OceanBase Database

Run the following command to connect to an OceanBase cluster by using the OBClient or MySQL client through ODP:

obclient -h<obproxy_ip> -u<user> -P<obproxy_port> -p<obproxy_pwd> -c -A
or
mysql -h<obproxy_ip> -u<user> -P<obproxy_port> -p<obproxy_pwd> -c -A

# Example
obclient -h10.10.10.1 -uroot@sys#obcluster -P2883 -p****** -c -A

where

  • -h specifies the IP address for connecting to OceanBase Database, which is usually the IP address of the ODP.

  • -u specifies the account for connecting to OceanBase Database. Two account formats are supported: username@tenant name#cluster name and cluster name:tenant name:username.

  • -P specifies the port for connecting to OceanBase Database, which is also the listening port of the ODP. The default value is 2883, which can be customized.

  • -p specifies the account password. For security reasons, you do not need to specify this parameter. In that case, you will be prompted to enter a password later. The password is invisible.

  • -c specifies that comments must not be ignored in the runtime environment of OBClient.

    Note

    Hint is a special comment that is not affected by the -c option.

  • -A specifies not to automatically retrieve the statistical information when connecting to a MySQL tenant.

Restart ODP

After the obproxy process exits, obproxyd.sh will start the process again within 1s. Therefore, you may not perceive an ODP exit. In a production environment, this mechanism can quickly restore services and prevent damages.

If you want to manually restart ODP, use the kill command to stop the obproxy process. After the first startup, the configuration file is generated in the etc and .conf directories, and the configuration information is persisted. Therefore, you can simply run the ./bin/obproxy command to restart ODP.

If you want to use the default configuration, run rm -rf etc .conf to delete the persisted configuration information, and then run the initial startup command.

Procedure

  1. Log on to the server that hosts the obproxy process as the user who started the process.

  2. Run the following command to view the ID of the obproxy process:

    -bash-4.2$ ps -ef | grep obproxy
    

    The output is as follows, where the ID of the obproxy process is 37360.

    admin     37360      0  6 11:35 ?        00:00:09 bin/obproxy
    admin     43055  36750  0 11:37 pts/10   00:00:00 grep --color=auto obproxy
    root      85623      1  0 Jun02 ?        00:15:19 /home/admin/ocp_agent/obagent/obstat2 -o http://xx.xx.xx.xx:81 -c test323 __obproxy__ -f 20
    
  3. Run the following command to stop the obproxy process based on the process ID:

    -bash-4.2$ kill -9 37360
    
  4. After the process is stopped, run the following command to view the ID of the obproxy process again:

    -bash-4.2$ ps -ef | grep obproxy
    

    The output is as follows, showing that the obproxy process no longer exists.

    admin     43055  36750  0 11:37 pts/10   00:00:00 grep --color=auto obproxy
    root      85623      1  0 Jun02 ?        00:15:19 /home/admin/ocp_agent/obagent/obstat2 -o http://xx.xx.xx.xx:81 -c test323 __obproxy__ -f 20
    
  5. Start the obproxy process.

    • If you want to use configurations of the last startup to start the obproxy process, run the ./bin/obproxy command directly under the ODP home directory.

    • If you want to use new configurations to start the obproxy process, run the rm -rf etc .conf command under the ODP home directory to delete the persisted configuration information, and then run the obproxy process start command. For more information about how to start ODP, see Start ODP in Deploy ODP by using the CLI.

  6. Verify whether ODP is restarted.

    In ODP, you can query the startup time to find out whether ODP has been restarted. There are many ways to query the startup time. You can check succ to init logger in the obproxy.log file to determine the startup time. This information is printed only once when the process is started. You can also query the startup time by using the following command:

    -bash-4.2$ ls -l /proc/`pidof obproxy` -d
    dr-xr-xr-x 8 admin admin 0 Nov 14 14:18 /proc/118273
    

Directories

The directory structure of ODP is as follows:

-bash-4.2$ ls -alrt
total 48
-rw-r--r-- 1 admin admin 14245 Nov  3 16:57 start_obproxy.sh
drwxr-xr-x 2 admin admin  4096 Nov 14 14:15 bin
drwxr-xr-x 2 admin admin  4096 Nov 14 14:15 tools
lrwxrwxrwx 1 admin admin    28 Nov 14 14:15 log -> /home/admin/logs/obproxy/log
lrwxrwxrwx 1 admin admin    33 Nov 14 14:15 minidump -> /home/admin/logs/obproxy/minidump
drwxr-xr-x 1 root  root   4096 Nov 14 14:16 ..
drwxrwxr-x 2 admin admin  4096 Nov 14 14:18 sharding-config
drwxrwxr-x 2 admin admin  4096 Nov 14 14:18 control-config
drwxr-xr-x 8 admin admin  4096 Nov 14 14:18 .
drwxrwxr-x 2 admin admin  4096 Nov 14 14:18 etc
drwxrwxr-x 2 admin admin  4096 Nov 14 14:18 .conf

Important directories and files include:

  • start_obproxy.sh: the daemon script. Its content is simple. You can read the script code to understand the implementation principle. The daemon script for ODP deployed by OceanBase Deployer (obd) is obproxyd.sh.

  • bin directory: stores ODP binary files.

  • log directory: stores log files. This directory occupies the largest disk space. Log files are divided into various types to help you troubleshoot and locate issues.

  • sharding-config directory: stores configuration files related to sharding.

  • etc and .conf directories: store configuration information. The .conf directory is a backup of the etc directory. If the etc directory is deleted, the content of the .conf directory is used.

Contact Us