MySQL5.7 MHA+MaxScale2.0构建高可用环境(6)

恢复HE1 
mysql> start
slave;
Query OK, 0 rows
affected (0.00 sec)
 
 
[root@HE3 ~]#
maxadmin -pmariadb list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server            | Address        | Port 
| Connections | Status             
-------------------+-----------------+-------+-------------+--------------------
server1            | 192.168.1.248  | 
3306 |          0 | Slave,
Running
server2            | 192.168.1.249  | 
3306 |          0 | Slave,
Running
server3            | 192.168.1.250  | 
3306 |          0 | Master,
Running
-------------------+-----------------+-------+-------------+--------------------
 
验证
[root@HE3 ~]#  mysql -h192.168.1.250 -P 4006 -usys_admin
-pMANAGER maxscale -e"select * from helei;"
mysql: [Warning]
Using a password on the command line interface can be insecure.
+--------+
| a      |
+--------+
| HE3    |
| HE2    |
| 写入 
|
+--------+
[root@HE3 ~]#  mysql -h192.168.1.250 -P 4006 -usys_admin
-pMANAGER maxscale -e"select * from helei;"
mysql: [Warning]
Using a password on the command line interface can be insecure.
+--------+
| a      |
+--------+
| HE3    |
| HE1    |
| 写入 
|
+--------+

在HE1(slave1)恢复完成后,重新有了负载均衡。
 
Part2:mysql down故障
[root@HE1 ~]#
/etc/init.d/mysqld stop
Shutting down
MySQL..... SUCCESS!
 
停止HE1(slave)可以看到转发到了HE2上
 
[root@HE3 ~]#  maxadmin -pmariadb list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server            | Address        | Port 
| Connections | Status             
-------------------+-----------------+-------+-------------+--------------------
server1            | 192.168.1.248  | 
3306 |          0 | Down
server2            | 192.168.1.249  | 
3306 |          1 | Slave,
Running
server3            | 192.168.1.250  | 
3306 |          1 | Master,
Running
-------------------+-----------------+-------+-------------+--------------------
[root@HE3
~]# mysql -h192.168.1.250 -P 4006 -usys_admin -pMANAGER
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 28948
Server version:
5.5.5-10.0.0 2.0.1-maxscale MySQL Community Server (GPL)
 
Copyright (c) 2000,
2016, 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
@@hostname;
+------------+
| @@hostname |
+------------+
| HE2        |
+------------+
1 row in set (0.00
sec)
 
 
停掉2台slave,观察maxscale的状态
[root@HE3 ~]#
maxadmin -pmariadb list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server            | Address        | Port 
| Connections | Status             
-------------------+-----------------+-------+-------------+--------------------
server1            | 192.168.1.248  | 
3306 |          0 | Running
server2            | 192.168.1.249  | 
3306 |          0 | Running
server3            | 192.168.1.250  | 
3306 |          0 | Master, Stale
Status, Running
-------------------+-----------------+-------+-------------+--------------------

Warning:警告这里我并没有在
[MySQL Monitor]中配置detect_stale_master=true
可以看出,在maxscale2.0中,已经默认从库都停掉,也不影响

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/b359578e79f9490f04c16ee61984b2a0.html