創(chuàng)新互聯(lián)公司主要從事
網(wǎng)站建設(shè)、成都網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)葉集,10余年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來(lái)電咨詢建站服務(wù):028-86922220MySQL 5.7 基于GTID搭建主從復(fù)制
一、搭建過(guò)程
1.1 準(zhǔn)備三個(gè)MySQL實(shí)例
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/3307/data/
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/3308/data/
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/3309/data/
1.2 server_id, server_uuid 不同
mysql -uroot -p123 -e "select @@server_id"
mysql -uroot -p123 -e "select @@server_uuid"
1.3 gtid_mode 是否開(kāi)啟:
mysql -uroot -p123 -e "select @@gtid_mode"
mysql -uroot -p123 -e "select @@server_gtid"
vi 330{7..9}/my.cnf
gtid_mode=ON
enforce_gtid_consistency=ON
log_slave_updates=ON
1.4 確認(rèn)binlog開(kāi)啟
mysql -uroot -p123 -e "select @@log_bin"
1.5 備份主庫(kù)數(shù)據(jù)到從庫(kù)通過(guò)遠(yuǎn)程方式
mysqldump -uroot -p123 -h 192.168.84.30 -P 3307 > /tmp/full.sql
1.6 恢復(fù)數(shù)據(jù)
mysql> source /tmp/full.sql
1.7 主庫(kù)創(chuàng)建復(fù)制用戶
grant replication slave on *.* to repl@'192.168.84.30' identified by '123';
1.8 從庫(kù)啟動(dòng)復(fù)制
幫助:
mysql> help change master to
......
找到配置模板:
CHANGE MASTER TO
MASTER_HOST='master2.example.com',
MASTER_USER='replication',
MASTER_PASSWORD='password',
MASTER_PORT=3306,
MASTER_LOG_FILE='master2-bin.001',
MASTER_LOG_POS=4,
MASTER_CONNECT_RETRY=10;
3308,3309使用如下配置:
CHANGE MASTER TO
MASTER_HOST='192.168.84.30',
MASTER_USER='repl',
MASTER_PASSWORD='123',
MASTER_PORT=3307,
master_auto_position=1;
開(kāi)始配置3308
mysql> CHANGE MASTER TO
-> MASTER_HOST='192.168.84.30',
-> MASTER_USER='repl',
-> MASTER_PASSWORD='123',
-> MASTER_PORT=3307,
-> master_auto_position=1;
Query OK, 0 rows affected, 2 warnings (0.00 sec)
開(kāi)始配置3309
mysql> CHANGE MASTER TO
-> MASTER_HOST='192.168.84.30',
-> MASTER_USER='repl',
-> MASTER_PASSWORD='123',
-> MASTER_PORT=3307,
-> master_auto_position=1;
Query OK, 0 rows affected, 2 warnings (0.00 sec)
文章題目:MySQL5.7基于GTID搭建主從復(fù)制-創(chuàng)新互聯(lián)
文章地址:
http://weahome.cn/article/popee.html