用下面命令看在从库10.0.0.5看主备切换,从库数据同步的情况:
mysql -uroot -e "show slave status\G;"|egrep "Slave_IO_Runnin|Slave_SQL_Running"
for i in `seq 100`;do mysql -uroot -e "show slave status\G;"|egrep "Slave_IO_Runnin|Slave_SQL_Running";sleep 10;echo -e "========$i=======\n" ; done
用下面命令进行主备切换
/usr/share/heartbeat/hb_standby
/usr/share/heartbeat/hb_takeover
往主库写数据
for n in `seq 2000 2300`;do mysql -uroot -e "use lvnian;insert test values($n,'lvnian$n');"; sleep 10 ;done;
for n in `seq 100`;do mysql -uroot -e "use lvnian; select * from test;"|tail -5 ;sleep 10;echo -e "=========$i==========" ;done;
mysql -uroot -e "use lvnian; select * from test;"
######################################################
[root@MYSQL_C ~]# for i in `seq 100`;do mysql -uroot -e "show slave status\G;"|egrep "Slave_IO_Runnin|Slave_SQL_Running";sleep 10;echo -e "========$i=======\n" ; done
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
========1=======
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
========2=======
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
========3=======
Slave_IO_Running: No
Slave_SQL_Running: Yes
========4=======
Slave_IO_Running: No
Slave_SQL_Running: Yes
========5=======
Slave_IO_Running: No
Slave_SQL_Running: Yes
========6=======
Slave_IO_Running: No
Slave_SQL_Running: Yes
========7=======
Slave_IO_Running: No
Slave_SQL_Running: Yes
========8=======
Slave_IO_Running: No
Slave_SQL_Running: Yes
========9=======
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
####################################
通过上面的主备切换时,从库同步主库的情况,因为每次查看同步情况,是10秒,所以得出结论:在主备进行切换时,mysql可不得大概会有1分钟的延迟,导致无法正常进行使用mysql数据库