replication简单完成配置 m-s(主从)



replication简单几步完成配置 m-s
1.在master上赋权
grant replication slave on *.* on 'dba'@'slaveip' identied by 'beifen';
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;

你可能感兴趣的:(MySql,m-)