replication簡單完成配置 m-s(主從),replicationm-s
replication簡單幾步完成配置 m-s
1.在master上賦權
grant replication slave on *.* on 'sync'@'slaveip' identied by 'password';
flush privileges;
2.master配置
[mysqld]
log-bin
binlog-format=row --提供效能
sync-binlog=1 --官方建議開啟
server-id=1
3.製作master完整備份
innobackupex --user=dba --password=beifen /var/lib/backup/
innobackupex --use-memory=500m --apply-log /var/lib/backup/2015-06-13_10-38-21/
4.拷貝全備到slave並恢複備份
scp /var/lib/backup/2015-06-13_10-38-21/ slaveip:/var/lib/backup/
cd /var/lib/backup/2015-06-13_10-38-21/
service mysql stop
mv * /var/lib/mysql
chown -R mysql.mysql /var/lib/mysql
5.slave配置
[mysqld]
server-id=2
6.查看並記錄二進位日誌中的position id
cd /var/lib/mysql
cat xtrabackup_binlog_info
7.配置slave replication
在slave
change master to
master_host='master_ip',
master_user='dba',
master_password='beifen',
master_log_file='host2-bin.0000001',
master_log_pos=120;
8.啟動replication,並檢查結果
在slave
start slave
show slave status \G;