011.MySQL雙主多從+Keepalived配置
阿新 • • 發佈:2018-11-05
一 基礎環境
二 實際部署
2.1 MySQL雙主+Keepalived高可用
略,具體參考《MySQL雙主+Keepalived高可用》筆記。2.2 所有Slave節點配置配置
1 [[email protected] ~]# scp /etc/my.cnf [email protected]:/etc/ 2 [[email protected] ~]# scp /etc/my.cnf [email protected]:/etc/ 3 [[email protected] ~]# vi /etc/my.cnf 4 [mysqld] 5 …… 6 server-id=3 #設定主伺服器Slave01的id 7 [[email protected] ~]# vi /etc/my.cnf 8 [mysqld] 9 …… 10 server-id=4 #設定主伺服器Slave02的id提示:從Master01將複製my.cnf至所有Slave節點,並修改相應的server id。
2.3 所有Slave節點建立賬號
1 [[email protected] ~]# service mysqld start 2 [[email protected] ~]# mysql -uroot -px120952576 3 mysql> grant replication slave on *.* to 'repl_user'@'172.24.8.%' identified by 'x12345678'; #建立用於複製的賬號 4 mysql> grant all privileges on *.* to 'root'@'172.24.8.%' identified by 'x120952576' with grant option; 5 mysql> flush privileges;提示:Slave02如上操作。
2.4 Slave節點配置Master01為主
1 [[email protected] ~]# service mysqld restart 2 [[email protected] ~]# mysql -uroot -px120952576 3 mysql> change master to master_host='172.24.8.10', 4 -> master_user='repl_user', 5 -> master_password='x12345678', 6 -> master_log_file='mysql-bin.000001', 7 -> master_log_pos=120; 8 mysql> start slave; 9 mysql> show slave status\G #檢視slave狀態略