为什么加上#demo集群名称登录就失败了?

【 使用环境 】测试环境
【 使用版本 】
4.0社区版
【问题现象及影响】
[root@ceph02 bin]# obd cluster list
±-------------------------------------------------+
| Cluster List |
±-----±------------------------±----------------+
| Name | Configuration Path | Status (Cached) |
±-----±------------------------±----------------+
| demo | /root/.obd/cluster/demo | deployed |
±-----±------------------------±----------------+
[root@ceph02 bin]# obclient -h127.0.0.1 -uroot@sys -P2881 -c -A -Doceanbase
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3221745414
Server version: OceanBase_CE 4.0.0.0 (r100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be) (Built Nov 1 2022 14:57:18)

Copyright (c) 2000, 2018, OB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

obclient [oceanbase]> alter user root identified by ‘abcd!QAZ’;
Query OK, 0 rows affected (0.335 sec)

[root@ceph02 bin]# obclient -h127.0.0.1 -uroot@sys -P2881 -c -A -Doceanbase -p’abcd!QAZ’
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3221747664
Server version: OceanBase_CE 4.0.0.0 (r100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be) (Built Nov 1 2022 14:57:18)

Copyright (c) 2000, 2018, OB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

obclient [oceanbase]> \q
Bye
[root@ceph02 bin]# obclient -h127.0.0.1 -uroot@sys#demo -P2881 -c -A -Doceanbase -p’abcd!QAZ’
ERROR 1045 (42000): Access denied for user ‘root’@‘xxx.xxx.xxx.xxx’ (using password: YES)
为什么加上#demo集群名称登录就失败了?

【附件】

使用2881直连ob的时候,带#集群名称,observer会把租户+集群名称解析成租户信息。
使用proxy连接的话,不存在该问题;

原来如此 :+1:
不过还是发现问题,连接#demo 2883的proxy,为何还报错?
[root@ceph02 bin]# obclient -h127.0.0.1 -uroot@sys#demo -P2883 -c -A -Doceanbase -p’abcd!QAZ’
ERROR 2014 (HY000): Commands out of sync; you can’t run this command now
[root@ceph02 bin]# ps -ef|grep proxy
root 21319 1 0 16:40 pts/2 00:00:00 bash /root/obproxy-ce/obproxyd.sh /root/obproxy-ce 127.0.0.1 2883 daemon
root 23644 1 4 16:49 ? 00:00:00 /root/obproxy-ce/bin/obproxy --listen_port 2883
root 23752 16746 0 16:49 pts/2 00:00:00 grep --color=auto proxy
[root@ceph02 bin]# netstat -tunlp|grep proxy
tcp 0 0 0.0.0.0:2883 0.0.0.0:* LISTEN 23644/obproxy
tcp 0 0 0.0.0.0:2884 0.0.0.0:* LISTEN 23644/obproxy
[root@ceph02 bin]# obclient -h127.0.0.1 -uroot@sys -P2883 -c -A -Doceanbase -p’abcd!QAZ’
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 1
Server version: OceanBase_CE 4.0.0.0 (r100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be) (Built Nov 1 2022 14:57:18)

Copyright (c) 2000, 2018, OB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

obclient [oceanbase]> \q
Bye
[root@ceph02 bin]# obclient -h127.0.0.1 -uroot@sys -P2881 -c -A -Doceanbase -p’abcd!QAZ’
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3221487628
Server version: OceanBase_CE 4.0.0.0 (r100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be) (Built Nov 1 2022 14:57:18)

Copyright (c) 2000, 2018, OB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

obclient [oceanbase]> \q
Bye
[root@ceph02 bin]# netstat -tunlp|grep LISTEN|grep 288
tcp 0 0 0.0.0.0:2881 0.0.0.0:* LISTEN 20507/observer
tcp 0 0 0.0.0.0:2882 0.0.0.0:* LISTEN 20507/observer
tcp 0 0 0.0.0.0:2883 0.0.0.0:* LISTEN 23964/obproxy
tcp 0 0 0.0.0.0:2884 0.0.0.0:* LISTEN 23964/obproxy
[root@ceph02 bin]#

可以试试使用proxy的IP地址 重新连接下,这个报错可能是解析有异常。

我这里也是,通过obproxy连接总是断开,加上demo集群名无法登录。即使用ip也一样报错。

[root@ceph02 ~]# netstat -tunlp|grep LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1831/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2108/master
tcp 0 0 0.0.0.0:2881 0.0.0.0:* LISTEN 20507/observer
tcp 0 0 0.0.0.0:2882 0.0.0.0:* LISTEN 20507/observer
tcp 0 0 0.0.0.0:2883 0.0.0.0:* LISTEN 31277/obproxy
tcp 0 0 0.0.0.0:2884 0.0.0.0:* LISTEN 31277/obproxy
tcp6 0 0 :::22 :::* LISTEN 1831/sshd
tcp6 0 0 :::8088 :::* LISTEN 21129/monagent
tcp6 0 0 ::1:25 :::* LISTEN 2108/master
tcp6 0 0 :::8089 :::* LISTEN 21129/monagent
[root@ceph02 ~]# obclient -h127.0.0.1 -uroot@sys#demo -P2883 -c -A -Doceanbase -p’abcd!QAZ’
ERROR 2002 (HY000): Can’t connect to MySQL server on ‘127.0.0.1’ (115)
[root@ceph02 ~]# obclient -h127.0.0.1 -uroot@sys -P2881 -c -A -Doceanbase -p’abcd!QAZ’
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3221487629
Server version: OceanBase_CE 4.0.0.0 (r100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be) (Built Nov 1 2022 14:57:18)

Copyright (c) 2000, 2018, OB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

obclient [oceanbase]> \q
Bye
[root@ceph02 ~]# obd cluster list
±-------------------------------------------------+
| Cluster List |
±-----±------------------------±----------------+
| Name | Configuration Path | Status (Cached) |
±-----±------------------------±----------------+
| demo | /root/.obd/cluster/demo | deployed |
±-----±------------------------±----------------+
[root@ceph02 ~]# obd cluster start demo
Get local repositories ok
Search plugins ok
Open ssh connection ok
Load cluster param plugin ok
Check before start observer ok
Check before start obagent ok
Check before start obproxy ok
Check before start prometheus ok
Check before start grafana ok
Start observer ok
observer program health check ok
Connect to observer x
[ERROR] OBD-1006: Failed to connect to oceanbase-ce
See https://www.oceanbase.com/product/ob-deployer/error-codes .
[root@ceph02 ~]# obd cluster display demo
Deploy “demo” is deployed
See https://www.oceanbase.com/product/ob-deployer/error-codes .
[root@ceph02 ~]# obclient -h127.0.0.1 -uroot@sys -P2881 -c -A -Doceanbase -p’abcd!QAZ’
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3221487640
Server version: OceanBase_CE 4.0.0.0 (r100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be) (Built Nov 1 2022 14:57:18)

Copyright (c) 2000, 2018, OB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

obclient [oceanbase]> \q
Bye
[root@ceph02 ~]# obclient -h127.0.0.1 -uroot@sys -P2883 -c -A -Doceanbase -p’abcd!QAZ’
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 1
Server version: OceanBase_CE 4.0.0.0 (r100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be) (Built Nov 1 2022 14:57:18)

Copyright (c) 2000, 2018, OB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

obclient [oceanbase]> \q
Bye
[root@ceph02 ~]# obclient -h127.0.0.1 -uroot@sys#demo -P2883 -c -A -Doceanbase -p’abcd!QAZ’
ERROR 2013 (HY000): Lost connection to MySQL server at ‘handshake: reading initial communication packet’, system error: 104
[root@ceph02 ~]# netstat -tunlp|grep LISTEN|grep 28
tcp 0 0 0.0.0.0:2881 0.0.0.0:* LISTEN 20507/observer
tcp 0 0 0.0.0.0:2882 0.0.0.0:* LISTEN 20507/observer
[root@ceph02 ~]#

  1. demo是obd 给集群启的别名,对于ob来说他不知道obd启的这个别名
  2. 一个obproxy代理一个一个ob集群时,可以不用加上#集群名

请问这个问题解决没。我也是出现这样的情况


我也遇到了这个问题,不过我想明白了。

这里出来的name为demo,实际上只是我们这次部署的配置的一个别名,不是ob的集群名称

-bash-4.2# obd cluster list
+--------------------------------------------------+
|                   Cluster List                   |
+------+-------------------------+-----------------+
| Name | Configuration Path      | Status (Cached) |
+------+-------------------------+-----------------+
| demo | /root/.obd/cluster/demo | running         |
+------+-------------------------+-----------------+

真正ob的集群名称是在上面的配置文件里面

-bash-4.2# cat /root/.obd/cluster/demo/config.yaml |grep appname
    appname: obcluster

在启动进程里面也可以看到" --cluster_name obcluster"

-bash-4.2# ps -ef|grep obproxy
root       2230      1  0 15:11 ?        00:00:18 /root/obproxy-ce/bin/obproxy -o obproxy_sys_password=,enable_strict_kernel_release=False,skip_proxy_sys_private_check=True,proxy_mem_limited=500M,enable_cluster_checkout=False --listen_port 2883 --prometheus_listen_port 2884 --rs_list 127.0.0.1:2881 --cluster_name obcluster

可以使用集群名称obcluster连接到数据库

-bash-4.2# obclient -uroot@sys#demo -p -h192.168.20.20 -P2883
Enter password: 
ERROR 2014 (HY000): Commands out of sync; you can't run this command now


-bash-4.2# obclient -uroot@sys#obcluster -p -h192.168.20.20 -P2883
Enter password: 
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 6
Server version: OceanBase_CE 4.0.0.0 (r100000282022112511-dd289d2407609a88b1fcdf2be9e7c384cb8e19d0) (Built Nov 25 2022 11:58:08)

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)]>