作者:王坤,尖端科技OceanBase深度玩家
引言:
使用obproxy连接OceanBase数据库时,系统报错:“ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization packet', system error: 0”。对于obproxy的异常,我们可以通过卸载并重新安装obproxy使其恢复正常。
0.环境
CentOS7.6.1810;
OceanBase 2.2.75;
obproxy-1.9.1.2-1919592.el7.x86_64。
单机3实例测试环境,不建议生产环境以该方式部署。
1. 现象描述
之前部分observer启动异常,obproxy正常;
后来把observer都干掉了,重新配置observer,此时obproxy连接异常(重建后proxyro用户都被删除了,必须异常)。
然后把proxyro用户创建完成,重启obproxy,通过obproxy连接数据库,仍旧异常报错。
使用obproxy连接报错:
[root@ob6 ~]# mysql -h127.1 -uroot@sys -P2883 test -A ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization packet', system error: 0
直连observer1正常:
[admin@ob6 ~]$ mysql -h127.1 -uroot@sys -P2881 test -A Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 3221653071 Server version: 5.7.25 OceanBase 2.2.75 (r20210108170301-c8c037dd6352fa0d00bd8a7105a1b566a5bc790d) (Built Jan 8 2021 17:31:33) Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [test]>
2. 解决思路
直接卸载obproxy,重新安装obproxy后恢复正常。
3. 处理过程
1) 查看obproxy进程
[admin@ob6 ~]$ pidof obproxy 3476 [admin@ob6 ~]$ ps -ef | grep obproxy | grep -v grep admin 3476 1 25 Jul21 ? 03:42:45 bin/obproxy -p2883 -cobdemo -o obproxy_config_server_url=http://192.168.80.20:8088/services?Action=GetObProxyConfig&User_ID=alibaba-inc&uid=ocpmaster,enable_cluster_checkout=false,enable_strict_kernel_release=false,enable_metadb_used=false
2) 杀掉进程
[admin@ob6 ~]$ kill -9 `pidof obproxy` [admin@ob6 ~]$ ps -ef | grep obproxy | grep -v grep
3) proxyro用户保留,该用户只是查询,并无数据
确保proxyro存在,当前如果不存在,则重建该用户并授权。
obclient -h127.1 -uroot@sys -P2881 -p alter user root identified by 'Demo_800'; CREATE USER proxyro IDENTIFIED BY password '*e9c2bcdc178a99b7b08dd25db58ded2ee5bff050' ; GRANT SELECT ON *.* to proxyro; show grants for proxyro;
4) 卸载obproxy
[root@ob6 ~]# rpm -qa | grep obproxy obproxy-1.9.1.2-1919592.el7.x86_64 [root@ob6 ~]# ls /opt/taobao/install/obproxy bin control-config etc log minidump tools [root@ob6 ~]# rpm -e obproxy-1.9.1.2-1919592.el7.x86_64 [root@ob6 ~]# ls /opt/taobao/install/obproxy control-config etc log minidump
5) 删除obproxy目录
[root@ob6 install]# pwd /opt/taobao/install [root@ob6 install]# rm -rf /opt/taobao/install/obproxy* [root@ob6 install]# ls [root@ob6 install]#
6) 重新安装
[root@ob6 install]# rpm -ivh ~/t-oceanbase-antman/obproxy-1.9.1.2-1919592.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:obproxy-1.9.1.2-1919592.el7 ################################# [100%]
7) 新建目录链接
新建obproxy链接:
[root@ob6 install]# pwd /opt/taobao/install [root@ob6 install]# ln -s obproxy-1.9.1.2/ obproxy [root@ob6 install]# ls obproxy bin log minidump tools
对链接进行授权:
[root@ob6 install]# ll total 4 lrwxrwxrwx 1 root root 16 Jul 22 08:50 obproxy -> obproxy-1.9.1.2/ drwxr-xr-x 4 admin admin 4096 Jul 22 08:50 obproxy-1.9.1.2 [root@ob6 install]# chown -h admin:admin /opt/taobao/install/obproxy [root@ob6 install]# ll total 4 lrwxrwxrwx 1 admin admin 16 Jul 22 08:50 obproxy -> obproxy-1.9.1.2/ drwxr-xr-x 4 admin admin 4096 Jul 22 08:50 obproxy-1.9.1.2
8) 模拟OCP API(可选)
[root@ob6 obproxy]# cp /root/t-oceanbase-antman/tools/deploy_physical/configurl_server.py /home/admin/ [root@ob6 obproxy]# chown admin:admin /home/admin/configurl_server.py [admin@ob6 ~]$ nohup python configurl_server.py `hostname -i` 8088 2>&1 1>/tmp/configurl_server.log & [1] 39154 [admin@ob6 ~]$ netstat -ntlp |grep 8088 (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 0.0.0.0:8088 0.0.0.0:* LISTEN 39154/python
9) 设置OB集群参数,指向前面API
[admin@ob6 ~]$ mysql -h127.1 -uroot@sys -P2881 test -A MySQL [test]> alter system set obconfig_url='http://192.168.80.20:8088/services?Action=ObRootServiceInfo&ObRegion=obdemo'; Query OK, 0 rows affected (0.30 sec)
10) 启动OBProxy
[admin@ob6 ~]$ cd /opt/taobao/install/obproxy && bin/obproxy -p2883 -cobdemo -o "obproxy_config_server_url=http://192.168.80.20:8088/services?Action=GetObProxyConfig&User_ID=alibaba-inc&uid=ocpmaster,enable_cluster_checkout=false,enable_strict_kernel_release=false,enable_metadb_used=false" bin/obproxy -p2883 -cobdemo -o obproxy_config_server_url=http://192.168.80.20:8088/services?Action=GetObProxyConfig&User_ID=alibaba-inc&uid=ocpmaster,enable_cluster_checkout=false,enable_strict_kernel_release=false,enable_metadb_used=false listen port: 2883 cluster_name: obdemo optstr: obproxy_config_server_url=http://192.168.80.20:8088/services?Action=GetObProxyConfig&User_ID=alibaba-inc&uid=ocpmaster,enable_cluster_checkout=false,enable_strict_kernel_release=false,enable_metadb_used=false
11) 查看obproxy进程-当前进程已经启动
[admin@ob6 obproxy]$ ps -ef | grep obproxy admin 40048 1 26 09:07 ? 00:00:01 bin/obproxy -p2883 -cobdemo -o obproxy_config_server_url=http://192.168.80.20:8088/services?Action=GetObProxyConfig&User_ID=alibaba-inc&uid=ocpmaster,enable_cluster_checkout=false,enable_strict_kernel_release=false,enable_metadb_used=false admin 40102 3038 0 09:07 pts/2 00:00:00 grep --color=auto obproxy
12) 使用obproxy登录
登录前修改root密码-前述已经操作,本次可不执行。
[admin@ob6 ~]$ mysql -h127.1 -uroot@sys -P2881 test -A MySQL [test]> alter user root identified by 'Demo_800'; Query OK, 0 rows affected (0.27 sec)
使用obproxy登录成功
[admin@ob6 ~]$ mysql -h127.1 -uroot -P2883 -p'Demo_800' test -A Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.6.25 OceanBase 2.2.75 (r20210108170301-c8c037dd6352fa0d00bd8a7105a1b566a5bc790d) (Built Jan 8 2021 17:31:33) Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [test]>
注:使用obproxy登录不需要设置密码也可以
[admin@ob3 ~]$ obclient -h127.1 -P2883 -uroot oceanbase -A Welcome to the OceanBase. Commands end with ; or \g. Your MySQL connection id is 131074 Server version: 5.6.25 OceanBase 3.1.0 (r-00672c3c730c3df6eef3b359eae548d8c2db5ea2) (Built Jun 22 2021 12:46:28) Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [oceanbase]>
4. 小结
当obproxy异常时,可以通过卸载重新安装obproxy恢复正常,生产环境中,会有多个obproxy,其中一个损坏进行修复,对业务不受影响。
5.写在末尾
gitee:https://gitee.com/oceanbase
ps:如果您有任何疑问,可以通过以下方式与我们进行交流:
钉钉群:33254054
博客问答:https://open.oceanbase.com/answer