-------------配置主主復制----兩臺主服務(wù)器互相復制--------------------------------------- show master status; //記錄日志文件名稱和位置,在兩臺主上查看。 -----在m1上為m2授予從的權(quán)限,在m2上也要給m1授予從的權(quán)限---- grant replication slave on . to 'replication' @'192.168.100.%' identified by '123456'; //兩臺主都執(zhí)行,從不需要
change master to master_host='192.168.100.20',master_user='replication',master_password='123456',master_log_file='mysql_bin.000003',master_log_pos=245; 注意:在m1上要指定m2上的日志文件名和位置參數(shù)。在m2上要反過來指定m1的。(注意其中要改的IP地址、文件名及偏移量)
start slave; //開啟同步功能 show slave status/G; Slave_I0_Running: Yes Slave_SQL_Running: Yes
----------------在兩臺從上做------注意日志文件和位置參數(shù)的改變-------------- 注:兩臺從都需要指向其中的一臺主服務(wù)器(這里指向m1) change master to master_host='192.168.100.10',master_user='replication',master_password='123456',master_log_file='mysql_bin.000003',master_log_pos=245;
start slave; //開啟同步 show slave status/G;//查看狀態(tài)
--------------在monitor服務(wù)器上配置--------------------------------------- cd /etc/mysql-mmm/ vim mmm_mon.conf ping_ips 192.168.100.10,192.168.100.20,192.168.100.30,192.168.100.40 //監(jiān)視器監(jiān)聽的服務(wù)器地址 auto_set_online 10 //自動上線時間10秒 <host default> monitor_user mmm_monitor monitor_password 123456 //改密碼 </host>
---------------在所有數(shù)據(jù)庫上為mmm_agent授權(quán)----------(進入數(shù)據(jù)庫)----------------- grant super, replication client, process on . to 'mmm_agent'@'192.168.100.%' identified by '123456';
---------------在所有數(shù)據(jù)庫上為mmm_moniter授權(quán)---------(進入數(shù)據(jù)庫)------------------ grant replication client on . to 'mmm_monitor'@'192.168.48.%' identified by '123456';
flush privileges; //刷新
---------------修改所有數(shù)據(jù)庫的mmm_agent.conf--------------------------------------------- vim /etc/mysql-mmm/mmm_agent.conf this db1 //根據(jù)之前代理名稱的規(guī)劃進行逐一調(diào)整
----------------在monitor服務(wù)器上配置---------------------------------------------------------- cd /etc/mysql-mmm/ vim mmm_mon.conf .......... ping_ips 192.168.100.10,192.168.100.20,192.168.100.30,192.168.100.40 //數(shù)據(jù)庫服務(wù)器地址
在m1服務(wù)器上進數(shù)據(jù)庫為監(jiān)控機地址授權(quán)登錄 grant all on . to 'testdba'@'192.168.100.50' identified by '123456'; flush privileges; //刷新 按理來講監(jiān)控服務(wù)器只單獨充當監(jiān)控這一角色就行了,這里臨時將它也作為客戶端來配置一下: yum install -y mariadb-server mariadb
------------------在監(jiān)控服務(wù)器上登錄------------------------------------------- mysql -utestdba -p -h 192.168.100.199 //虛擬地址 創(chuàng)建數(shù)據(jù),測試同步情況