高可用 | Xenon 实现 MySQL 高可用架构 常用操作篇

本文详细介绍了 Xenon 实现 MySQL 高可用架构的常用操作,包括启动集群、检查半同步复制、添加/删除节点、重建及手动 Failover 等,帮助管理员更好地管理和维护 MySQL 集群。
摘要由CSDN通过智能技术生成

原创:知数堂

上一篇文章,我们详细介绍了 Xenon 实现 MySQL 高可用架构的部署过程。接下来本篇将介绍 Xenon 的常用操作,帮助大家在完成环境搭建之后,能把 Xenon 熟练的用起来,以更好的对 MySQL 高可用架构进行管理。

| 1 启动集群

1.1 启动 MySQL

# db1:
[mysql@db1 ~]$ nohup mysqld_safe --defaults-file=/etc/my.cnf &
[1] 5526
[mysql@db1 ~]$ nohup: ignoring input and appending output to ‘nohup.out’
 
# db2:
[mysql@db2 ~]$ nohup mysqld_safe --defaults-file=/etc/my.cnf &
[1] 3637
[mysql@db2 ~]$ nohup: ignoring input and appending output to 'nohup.out'
mysql –uroot –p    # 开启增强半同步
set global  rpl_semi_sync_slave_enabled=1;
stop  slave io_thread;
start slave  io_thread;

db3 的启动步骤同 db2。

1.2 启动 Xenon

db1:
[mysql@db1 ~]$ cd /usr/local/xenon/bin/
[mysql@db1 bin]$ ./xenon -c /etc/xenon/xenon.json > /etc/xenon/log/xenon.log 2>&1 &

db2、db3 的启动方式同 db1。

注意:当 MySQL 未启动时,启动 Xenon 会自动启动 MySQL。

1.3 检查半同步复制

启动时,需要检查半同步复制是否开启。

(product)root@localhost [(none)]> show variables like '%semi%';
+-------------------------------------------+------------+
| Variable_name                             | Value      |
+-------------------------------------------+------------+
| rpl_semi_sync_master_enabled              | ON         |
| rpl_semi_sync_master_timeout              | 10000      |
| rpl_semi_sync_master_trace_level          | 32         |
| rpl_semi_sync_master_wait_for_slave_count | 1          |
| rpl_semi_sync_master_wait_no_slave        | ON         |
| rpl_semi_sync_master_wait_point           | AFTER_SYNC |
| rpl_semi_sync_slave_enabled               | OFF        |
| rpl_semi_sync_slave_trace_level           | 32         |
……

主要参数:主节点rpl_semi_sync_master_enabled 的状态为 ON,从节点 rpl_semi_sync_slave_enabled 的状态为 ON,表示半同步复制正常开启。

| 2 帮助命令

通过 xenoncli 的帮助命令查看可选的命令。

[mysql@db1 bin]$ ./xenoncli  help
A simple command line client for xenon
 
Usage:
  xenoncli [command]

Available Commands:
  cluster     cluster related commands
  init        init the xenon config file
  mysql       mysql related commands
  perf        perf related commands
  raft        raft related commands
  version     Print the version number of xenon client
  xenon       xenon related commands
 
Use "xenoncli [command] --help" for more information about a command.

举例说明,查看 cluster 的操作命令帮助。

[mysql@db1 bin]$  ./xenoncli cluster -h
cluster related commands
Usage:
  xenoncli cluster [command]
 
Available Commands:
  add         add peers to leader(if there is no leader, add to local)
  gtid        show cluster gtid status
  log         merge cluster xenon.log from logdir
  mysql       show cluster mysql status
  raft        show cluster raft status
  remove      remove peers from leader(if there is no leader, remove from local)
  status      show cluster status
  xenon       show cluster xenon status
 
Use "xenoncli cluster [command] --help" for more information about a command.

| 3 查看集群

3.1 查看状态

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值