单副本模式运行
如果DN集群中只有单个节点存活,将无法完成paxos的选举,便无法对外提供服务,此时需要以单副本模式运行。登录存活DN所在的容器,执行ps -ef | grep mysql
获取mysqld
启动命令及进程号,
[root@polardbx-demo /]# ps -ef | grep mysql
root 172 1 0 Apr15 ? 00:00:00 /bin/sh /opt/galaxy_engine/bin/mysqld_safe --defaults-file=/data/mysql/conf/my.cnf --loose-pod-name=pxd_test-dn-0-Cand-0-17777
mysql 5087 172 1 11:43 ? 00:03:11 /opt/galaxy_engine/bin/mysqld --defaults-file=/data/mysql/conf/my.cnf --basedir=/opt/galaxy_engine --datadir=/data/mysql/data --plugin-dir=/opt/galaxy_engine/lib/plugin --user=mysql --loose-pod-name=pxd_test-dn-0-Cand-0-17777 --log-error=/data/mysql/log/alert.log --open-files-limit=65535 --pid-file=/data/mysql/run/mysql.pid --socket=/data/mysql/run/mysql.sock --port=17777
root 5329 5309 0 16:17 pts/1 00:00:00 grep --color=auto mysql
根据defaults-file
指向的路径,修改配置文件,在[mysqld]
这个section中添加如下配置:
[mysqld]
cluster-force-single-mode = 1
之后将原mysqld
进程终止,等待mysqld_safe
将其重新拉起:
[root@polardbx-demo /]# kill 5087
重新拉起后可以执行myc
命令,登录DN的数据库,查看DN集群状态是否正常:
[root@polardbx-demo /]# myc
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 130
Server version: 8.0.30 Source distribution
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select * from information_schema.alisql_cluster_global;
+-----------+---------------------+-------------+------------+--------+-----------+------------+-----------------+----------------+---------------+------------+--------------+
| SERVER_ID | IP_PORT | MATCH_INDEX | NEXT_INDEX | ROLE | HAS_VOTED | FORCE_SYNC | ELECTION_WEIGHT | LEARNER_SOURCE | APPLIED_INDEX | PIPELINING | SEND_APPLIED |
+-----------+---------------------+-------------+------------+--------+-----------+------------+-----------------+----------------+---------------+------------+--------------+
| 1 | 172.16.201.11:25777 | 124 | 0 | Leader | Yes | No | 5 | 0 | 123 | No | No |
+-----------+---------------------+-------------+------------+--------+-----------+------------+-----------------+----------------+---------------+------------+--------------+
1 row in set (0.00 sec)
此时集群中只有该节点存活了,单节点拉起成功,可以进一步验证数据库访问是否正常。