启动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)


