資源描述:
《利用keepalived構(gòu)建高可用mysql-ha》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、利用keepalived構(gòu)建高可用MySQL-HA在MySQL-HA環(huán)境中,MySQL互為主從關(guān)系,這樣就保證了兩臺(tái)MySQL數(shù)據(jù)的一致性,然后用keepalived實(shí)現(xiàn)虛擬IP,通過keepalived自帶的服務(wù)監(jiān)控功能來實(shí)現(xiàn)MySQL故障時(shí)自動(dòng)切換。構(gòu)架環(huán)境拓?fù)淙缦?.MySQL-VIP:172.168.1.8?2.MySQL-master1:172.168.1.6?3.MySQL-master2:172.168.1.7??4.OS版本:redhat5.55.MySQL版本:5.0.89?6.Keepalived版本:1.1.20?
2、一、MySQLmaster-master配置1、修改MySQL配置文件兩臺(tái)MySQL均如要開啟binlog日志功能,開啟方法:在MySQL配置文件[MySQLd]段中加上log-bin=MySQL-bin選項(xiàng)兩臺(tái)MySQL的server-ID不能一樣,默認(rèn)情況下兩臺(tái)MySQL的serverID都是1,需將其中一臺(tái)修改為2即可2、將172.168.1.6設(shè)為172.168.1.7的主服務(wù)器在172.168.1.6上新建授權(quán)用戶1.MySQL>?grant?replication?slave?on?*.*?to?'replication'@
3、'%'?identified?by?'replication';?2.Query?OK,?0?rows?affected?(0.00?sec)?3.?4.MySQL>?show?master?status;?5.+------------------+----------+--------------+------------------+?6.
4、?File?????????????
5、?Position?
6、?Binlog_Do_DB?
7、?Binlog_Ignore_DB?
8、?7.+------------------+---------
9、-+--------------+------------------+?8.
10、?MySQL-bin.000003?
11、??????374?
12、??????????????
13、??????????????????
14、??9.+------------------+----------+--------------+------------------+?10.1?row?in?set?(0.00?sec)?在172.168.1.7上將172.168.1.6設(shè)為自己的主服務(wù)器1.MySQL>?change?master?to?master_hos
15、t='172.168.1.6',master_user='replication',master_password='replication',master_log_file='MySQL-bin.000003',master_log_pos=374;?2.Query?OK,?0?rows?affected?(0.05?sec)?3.?4.MySQL>?start?slave;?5.Query?OK,?0?rows?affected?(0.00?sec)?6.?7.MySQL>?show?slave?statusG?8.*******
16、********************?1.?row?***************************?9.?????????????Slave_IO_State:?Waiting?for?master?to?send?event?10.????????????????Master_Host:?172.168.1.6?11.????????????????Master_User:?replication?12.????????????????Master_Port:?3306?13.??????????????Connect_R
17、etry:?60?14.????????????Master_Log_File:?MySQL-bin.000003?15.????????Read_Master_Log_Pos:?374?16.?????????????Relay_Log_File:?MySQL-master2-relay-bin.000002?17.??????????????Relay_Log_Pos:?235?18.??????Relay_Master_Log_File:?MySQL-bin.000003?19.???????????Slave_IO_Runnin
18、g:?Yes?20.??????????Slave_SQL_Running:?Yes?21.????????????Replicate_Do_DB:??22.????????Replicate_Ignore