寫:
[root@master ~]# ip a| grep ens32
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000inet 192.168.111.3/24 brd 192.168.111.255 scope global noprefixroute ens32inet 192.168.111.100/32 scope global ens32讀:
[root@slave1 ~]# ip a| grep ens32
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000inet 192.168.111.5/24 brd 192.168.111.255 scope global noprefixroute ens32inet 192.168.111.200/32 scope global ens32
測試VIP轉移
[root@master ~]# /etc/init.d/mysqld stop
Shutting down MySQL............ SUCCESS!
[root@master ~]# ip a| grep ens32
-----寫-----
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000inet 192.168.111.3/24 brd 192.168.111.255 scope global noprefixroute ens32[root@masterba ~]# ip a| grep ens32
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000inet 192.168.111.4/24 brd 192.168.111.255 scope global noprefixroute ens32inet 192.168.111.100/32 scope global ens32-----讀-----
[root@slave1 ~]# /etc/init.d/mysqld stop
Shutting down MySQL.... SUCCESS!
[root@slave1 ~]# ip a| grep ens32
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000inet 192.168.111.5/24 brd 192.168.111.255 scope global noprefixroute ens32inet 192.168.111.200/32 scope global ens32
[root@slave1 ~]# ip a| grep ens32
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000inet 192.168.111.5/24 brd 192.168.111.255 scope global noprefixroute ens32inet 192.168.111.200/32 scope global ens32
[root@slave1 ~]# ip a| grep ens32
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000inet 192.168.111.5/24 brd 192.168.111.255 scope global noprefixroute ens32inet 192.168.111.200/32 scope global ens32
[root@slave1 ~]# ip a| grep ens32
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000inet 192.168.111.5/24 brd 192.168.111.255 scope global noprefixroute ens32[root@slave2 ~]# ip a| grep ens32
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000inet 192.168.111.6/24 brd 192.168.111.255 scope global noprefixroute ens32inet 192.168.111.200/32 scope global ens32
#切換的慢[root@slave2 ~]# mmm_control showdb1(192.168.111.3) master/HARD_OFFLINE. Roles: db2(192.168.111.4) master/ONLINE. Roles: writer(192.168.111.100)db3(192.168.111.5) slave/HARD_OFFLINE. Roles: db4(192.168.111.6) slave/ONLINE. Roles: reader(192.168.111.200)
#離線的已經指明了
mysql> grant all privileges on *.* to root@'192.168.111.%' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.01 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.10 sec)
#主庫上做下授權,從庫也會同步授權信息[root@slave2 ~]# mysql -uroot -p123456 -h'192.168.111.100'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 415
Server version: 5.7.24-log MySQL Community Server (GPL)Copyright (c) 2000, 2018, 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> [root@slave2 ~]# mysql -uroot -p123456 -h'192.168.111.200'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1043
Server version: 5.7.24-log MySQL Community Server (GPL)Copyright (c) 2000, 2018, 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>
#輸入的必須都是VIP進行連接
測試monitorVIP
[root@slave2 ~]# systemctl stop mysql-mmm-monitor.service
[root@slave2 ~]# ip a | grep ens32
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000inet 192.168.111.6/24 brd 192.168.111.255 scope global noprefixroute ens32inet 192.168.111.200/32 scope global ens32[root@monitorba ~]# ip a| grep ens32
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000inet 192.168.111.7/24 brd 192.168.111.255 scope global noprefixroute ens32inet 192.168.111.222/32 scope global ens32:2
[root@monitorba ~]# mmm_control showdb1(192.168.111.3) master/ONLINE. Roles: writer(192.168.111.100)db2(192.168.111.4) master/HARD_OFFLINE. Roles: db3(192.168.111.5) slave/HARD_OFFLINE. Roles: db4(192.168.111.6) slave/ONLINE. Roles: reader(192.168.111.200)