Original: Know number hall
In the last article, we went through the deployment process of Xenon implementing the MySQL high availability architecture in detail. Next, the common operations of Xenon will be introduced to help you skillfully use Xenon after completing environment construction, so as to better manage MySQL high availability architecture.
| 1 to start the cluster
Start the MySQL 1.1
# 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;Copy the code
Db3 has the same startup steps as DB2.
1.2 start the 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 &Copy the code
Db2 and DB3 start in the same way as DB1.
Note: When MySQL is not started, Xenon will automatically start MySQL.
1.3 Checking Semi-Synchronous Replication
Before starting, check whether semi-synchronous replication is enabled.
(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 |...Copy the code
Main parameters: If the status of rpl_semi_SYNc_MASTER_enabled ON the primary node is ON, and that of rpl_semi_sync_SLAVe_enabled ON the secondary node is ON, semi-synchronous replication is normally enabled.
| 2 help command
Use the Help commands in the XenonCLI to view the available commands.
[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.Copy the code
For example, view the help information about cluster operation commands.
[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.Copy the code
| 3 check the cluster
3.1 Viewing Status
xenoncli cluster status
xenoncli cluster mysql
xenoncli cluster xenon
Copy the code
3.2 Checking the Cluster Consistency Status
xenoncli cluster raft
Copy the code
3.3 Checking the CLUSTER GTID Status
xenoncli cluster gtid
Copy the code
Shut down the cluster | 4
xenoncli mysql stopmonitor
xenoncli mysql shutdown
pkill xenon
Copy the code
| 5 add/remove node
5.1 Adding a Node
Xenoncli cluster add 192.168.0.2:8801192168 0.3:8801192168 0.5:8801Copy the code
Xenon You can add nodes that have been added. If the node is already in the cluster, it is ignored and no operation is performed.
5.2 Deleting a Node
Xenoncli cluster remove 192.168.0.2:8801192168 0.3:8801192168 0.5:8801Copy the code
| 6 backup MySQL to local
[root@db1 backup]# xenoncli mysql backup Usage: xenoncli mysql backup --to=backupdir [flags] [mysql@db1 bin]$ ./xenoncli mysql backup --to=/backup/data 2020/02/10 04:28:43. 924306 [WARNING] rebuildme. Found. Best. Slave [10.10.10.11:8801] leader 2020/02/10 [10.10.10.10:8801] 04:28:43. 924576 [WARNING] S1 - > found. The. Best. Backup. The host [10.10.10.11:8801]... 2020/02/10 04:28:43.945828 [WARNING] S2- >rm.and.mkdir.backupdir[/backup/data] 2020/02/10 04:28:43.945845 [WARNING] S3-->xtrabackup.begin.... 2020/02/10 04:28:43. 946692 [WARNING] rebuildme. Backup. The req [& {the From: Backup :/backup/data SSHHost:10.10.10.10 SSHUser:mysql SSHPasswd:123456 SSHPort:22 IOPSLimits:100000 XtrabackupBinDir: / usr/bin}] from [8801] 10.10.10.11:2020/02/10 04:29:06. [WARNING] S3-360412 - > xtrabackup. The end... 2020/02/10 04:29:06. [WARNING] 360444 S4 - > apply - log. The begin... 2020/02/10 04:29:11. [WARNING] 010835 S4 - > apply - the end... 2020/02/10 04:29:11.011275 [WARNING] Completed OK! 2020/02/10 04:29:11) 011300 [WARNING] backup). All done...Copy the code
In the XenonCLI, backupDir will be deleted first and then mkdir. Therefore, you are not advised to use the /backup root directory. If this path is used, rm succeeds but mkdir fails.
| 7 Rebuild reconstruction
Select the slave node in the best state for XtraBackup stream reconstruction. The from parameter can specify the source node for reconstruction.
- MySQL > create MySQL on current node
- Scenario: A node is faulty and needs to be quickly rebuilt
Xenoncli mysql rebuildme xenoncli mysql rebuildme xenoncli mysql rebuildme Xenoncli mysql -h // rebuild the mysql node based on the specified node [mysql@db1 bin]$./xenoncli mysql rebuildme --from=10.10.10.11:8801 2020/02/11 01:19:40.907645 [WARNING] =====prepare.to.rebuildme===== IMPORTANT: Please check that the backup run completes successfully. At the end of a successful backup run innobackupex prints "completed OK!" .2020/02/11 01:19:40.908418 [WARNING] S1-->check.raft. Leader 2020/02/11 01:19:40.911586 [WARNING] S2 - > prepare. Rebuild. The from [10.10.10.11:8801]... 2020/02/11 01:19:40. [WARNING] S3-913050 - > check the bestone [10.10.10.11:8801]. Is. OK... 2020/02/11 01:19:40.913066 [WARNING] S4-->set. Learner 02/02/11 01:19:40.915499 [WARNING] S5-->stop.monitor 2020/02/11 01:19:40.916758 [WARNING] S6-->kill. Mysql 2020/02/11 01:19:40.947717 [WARNING] S7 - > check. Bestone [10.10.10.11:8801]. Is. OK... 2020/02/11 01:19:40.950867 [WARNING] S8-->rm. Datadir [/backup/data] 2020/02/11 01:19:40.950879 [WARNING] S9-->xtrabackup.begin.... 2020/02/11 01:19:40. 951632 [WARNING] rebuildme. Backup. The req [& {the From: Backup :/backup/data SSHHost:10.10.10.10 SSHUser:mysql SSHPasswd:123456 SSHPort:22 IOPSLimits:100000 XtrabackupBinDir: / usr/bin}] from [8801] 10.10.10.11:2020/02/11 01:19:51. 200092 integrated [WARNING] -- > xtrabackup. The end... 2020/02/11 01:19:51. 200116 [WARNING] S10 -- > apply - log. The begin... 2020/02/11 01:19:56. 666199 [WARNING] S10 -- > apply - the end... 2020/02/11 01:19:56. [WARNING] S11-666209 - > start. Mysql. The begin... 2020/02/11 01:19:56. [WARNING] S11-666757 - > start. Mysql. The end... 2020/02/11 01:19:56. 666766 speed 12 [WARNING] -- > wait. Mysqld. Running. The begin... 2020/02/11 01:19:59. 680987 [WARNING] wait. Mysqld. Running... 2020/02/11 01:19:59. 709382 speed 12 [WARNING] -- > wait. Mysqld. Running. The end... 2020/02/11 01:19:59. [WARNING] / S13-709395 - > wait. Mysql. Working. The begin... 2020/02/11 01:19:59. [WARNING] / S13-710943 - > wait. Mysql. Working. The end... 2020/02/11 01:19:59. [WARNING] / S14-710955 - > stop. And. Reset. Slave. The begin... 2020/02/11 01:19:59. [WARNING] / S14-731108 - > stop. And. Reset. Slave. The end... 2020/02/11 01:19:59. 731121 S15 [WARNING] -- > reset. The master. The begin... 2020/02/11 01:19:59. 739414 S15 [WARNING] -- > reset. The master. The end... 2020/02/11 01:19:59.739455 [WARNING] S15-->set.gtid_purged[1520b6DD-2fb1-11Ea-AB64-080027d70146:1-14]. Begin.... 2020/02/11 01:19:59. [WARNING] S15-742273 - > set. Gtid_purged. The end... 2020/02/11 01:19:59. 742284 [WARNING] S16 - > enable. The raft. The begin... 2020/02/11 01:19:59. 743512 [WARNING] S16 - > enable. The raft. The done... 2020/02/11 01:19:59.743534 [WARNING] S17--> Wait [3000 ms].change.to.master... 2020/02/11 01:19:59. 743551 [WARNING] S18 - > start. The slave. The begin... 2020/02/11 01:19:59. 763468 [WARNING] S18 - > start. The slave. The end... 2020/02/11 01:19:59.763478 [WARNING] Completed OK!Copy the code
| 8 manual Failover/switchover
Manually trigger the primary/secondary switchover.
(product)root@localhost [(none)]> set global read_only=on; Query OK, 0 Rows Affected (0.00 SEC) [mysql@db1 bin]$./ Xenoncli raft trytoleader 2020/02/11 01:48:51.219975 [WARNING] [10.10.10.10:8801]. Prepare. To.. Propose this. Raft. To. Leader 2020/02/11 01:48:51. The 255617 [WARNING] [10.10.10.10:8801].elected. done [mysql@db1 bin]$./ Xenoncli cluster status +------------------+-------------------------------+---------+---------+--------------------------+--------------------- +----------------+------------------+ | ID | Raft | Mysqld | Monitor | Backup | Mysql | IO/SQL_RUNNING | MyLeader | +------------------+-------------------------------+---------+---------+--------------------------+--------------------- + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + | 10.10.10.10:8801 | [EpochID ViewID: 4:0] @ LEADER | RUNNING | ON | state: [NONE] | [the ALIVE] [READWRITE] | true/true | 10.10.10.10:8801 | | | | | | LastError: | | | | +------------------+-------------------------------+---------+---------+--------------------------+--------------------- + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + | 10.10.10.11:8801 | [EpochID ViewID: 4:0] @ followers | RUNNING | ON | state: [NONE] | [the ALIVE] [READONLY] | true/true | 10.10.10.10:8801 | | | | | | LastError: | | | | +------------------+-------------------------------+---------+---------+--------------------------+--------------------- + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + | 10.10.10.18:8801 | [EpochID ViewID: 4:0] @ followers | RUNNING | ON | state: [NONE] | [the ALIVE] [READONLY] | true/true | 10.10.10.10:8801 | | | | | | LastError: | | | | +------------------+-------------------------------+---------+---------+--------------------------+--------------------- +----------------+------------------+Copy the code
| 9 MySQL Stack Info
See how MySQL calls stack information. The Quick Stack is fast and has little impact on processes.
xenoncli perf -h
perf related commands
Usage:
xenoncli perf [command]
Available Commands:
quickstack capture the stack of mysqld using quickstack
Copy the code
| 10 Raft + Operation
Disable indicates that the Xenon node only replicates data.
xenoncli raft -h raft related commands Usage: xenoncli raft [command] Available Commands: add add peers to local disable enable the node out control of raft disablepurgebinlog disable leader to purge binlog enable enable the node in control of raft enablepurgebinlog enable leader to purge binlog(default) nodes show raft nodes remove remove peers from local status status in JSON(state(LEADER/CANDIDATE/FOLLOWER/IDLE)) trytoleader propose this raft as leaderCopy the code
| 11 start enhance half a simultaneous examination
# Enable/disable Xenoncli RAFT EnablecheckSemisync # Enable/disable Xenoncli RAFT disablecheckSemisyncCopy the code
We can see that the parameters for semi-synchronization are:
(product)root@localhost [(none)]> show variables like '%rpl%';
+-------------------------------------------+---------------------+
| Variable_name | Value |
+-------------------------------------------+---------------------+
| rpl_semi_sync_master_enabled | ON |
| rpl_semi_sync_master_timeout | 1000000000000000000 |
| 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 | ON |
| rpl_semi_sync_slave_trace_level | 32 |
| rpl_stop_slave_timeout | 31536000 |
+-------------------------------------------+---------------------+
Copy the code
If you modify the semi-synchronous timeout through set Global, it will be automatically revised to infinite. If the change is temporary based on O&M, run the Xenoncli mysql DisablecheckSemisync command. If automatic correction needs to be restored after o&M, run enablecheckSemisync.
// For example, to change the timeout parameter to 10, (product)root@localhost [(none)]> set global rpl_semi_sync_master_timeout=10; Query OK, 0 rows affected (0.00 SEC) (product)root@localhost [(none)]> show variables like '% RPL %'; Query OK, 0 rows affected (0.00 SEC) (product)root@localhost [(none)]> show variables like '% RPL %'; +-------------------------------------------+------------+ | Variable_name | Value | +-------------------------------------------+------------+ | rpl_semi_sync_master_enabled | ON | | rpl_semi_sync_master_timeout | 10 | | 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 | ON | | rpl_semi_sync_slave_trace_level | 32 | | rpl_stop_slave_timeout | 31536000 | +-------------------------------------------+------------+ 9 rows in set (0.00 SEC) (product)root@localhost [(none)]> show variables like '% RPL %'; +-------------------------------------------+---------------------+ | Variable_name | Value | +-------------------------------------------+---------------------+ | rpl_semi_sync_master_enabled | ON | | rpl_semi_sync_master_timeout | 1000000000000000000 | | 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 | ON | | rpl_semi_sync_slave_trace_level | 32 | | rpl_stop_slave_timeout | 31536000 | +-------------------------------------------+---------------------+ 9 rows in Set (0.00 SEC)Copy the code
| classification instruction
Querying cluster information:
Xenoncli cluster instructionCopy the code
Operating the machine:
Xenoncli raft instruction xenoncli perf quickstack xenoncli mysql backup | cancelbackup | kill | rebuildme | shutdown | start | startmonitor |status | stopmonitor | sysvarCopy the code
Try to connect to the Leader first, if there is no Leader, execute on the machine:
xenoncli mysql changepassword | createsuperuser | createuser | createuserwithgrants |
dropuser | getuser
Copy the code
Next up
Next time we will cover the use of Xenon profiles.
Recommended reading:
- High availability | Xenon get MySQL high availability deployment architecture
- High availability | Xenon: the choice of the MHA era