手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

MySQL主主复制故障自动切换解决方案

[日期:2013-03-21] 来源:Linux社区  作者:Linux [字体:大 中 小]

启动keepalived
1.#/usr/local/keepalived/sbin/keepalived –D
2. #ps -aux | grep keepalived
(停止进程的话,直接kill,哈哈)
至此配置工作已经做完,记下来就是测试工作,可一个远程msyql服务可以ping我们的50端口,然后再另启动一个会话,在链接到50端口上
如下;
D:\Program Files\uptime software\uptime\MySQL\bin>mysql.exe -uroot -p -h1492.168.0.50 -P3306
Enter password:
ERROR 2005 (HY000): Unknown MySQL server host '1492.168.0.50' (11004)
D:\Program Files\uptime software\uptime\mysql\bin>mysql.exe -uroot -proot -h192.
168.0.50 -P3306
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3275
Server version: 5.5.13-log Source distribution


Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| inno |
| mysql |
| performance_schema |
| test |
| test_db |
+--------------------+
6 rows in set (0.07 sec)
然后进行故障测试,分别对keepalived和,mysql服务分别停掉看看不同服务切换的效果!以下是我测试的;


mysql>
mysql> show databases;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> show databases;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 601
Current database: *** NONE ***


+--------------------+
| Database |
+--------------------+
| information_schema |
| inno |
| mysql |
| performance_schema |
| test |
| test_db |
+--------------------+
6 rows in set (0.01 sec)


mysql> show databases;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> show databases;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 3665
Current database: *** NONE ***


+--------------------+
| Database |
+--------------------+
| information_schema |
| inno |
| mysql |
| performance_schema |
| test |
| test_db |
+--------------------+
6 rows in set (0.00 sec)


mysql> show databases;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> show databases;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 1033
Current database: *** NONE ***


+--------------------+
| Database |
+--------------------+
| information_schema |
| inno |
| mysql |
| performance_schema |
| test |
| test_db |
+--------------------+
6 rows in set (0.01 sec)

linux
相关资讯       MySQL主主复制 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款