快速业务通道

mysql 双主从 keepalived,给mysql 做 HA

作者 佚名技术 来源 Linux系统 浏览 发布时间 2012-03-30
-----------
4 rows in set (0.00 sec)

b server b 192.168.5.86 监控 message 日志
tail /var/log/messages -f

c server a 192.168.5.85 停止 mysqld
/etc/init.d/mysqld stop

d 查看 server b messages 日志
Jun 8 11:42:22 master86 Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE
Jun 8 11:42:23 master86 Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATE
Jun 8 11:42:23 master86 Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.5.88
server b 已经切到 master

e clinet 上检查mysql, 并访问 zabbix
mysql> show databases;
--------------------
| Database |
--------------------
| information_schema |
| mysql |
| test |
| zabbix |
--------------------
4 rows in set (0.00 sec)

mysql> use zabbix;
Database changed
mysql> select count(*) from history;
----------
| count(*) |
----------
| 8633466 |
----------
1 row in set (0.00 sec)

f server a 开启 mysql, 并 检查主从状态!

mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.5.86
Master_User: rep
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000003
Read_Master_Log_Pos: 642907
Relay_Log_File: master85-relay-bin.000023
Relay_Log_Pos: 643052
Relay_Master_Log_File: mysql-bin.000003
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 642907
Relay_Log_Space: 643210
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)

g server a 与 server b 数据检查
server a
mysql> use zabbix;
Database changed
mysql> select count(*) from history;
----------
| count(*) |
----------
| 8398064 |
----------
1 row in set (0.00 sec)

server b
mysql> use zabbix;
Database changed
mysql> select count(*) from history;
----------
| count(*) |
----------
| 8398064 |
----------
1 row in set (0.00 sec)


5 总结
a keepalive

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号