【MySQL 复制】20G以下的mysql数据库从库快速搭建

因为20G以下,所以数据容量比较小,用mysqldump全库导出对业务影响不大,所以采用这种模式进行从库的搭建:


PS: master-data=1 ,record the Master_Log_File and Read_Master_Log_Pos:




1 backup the backup sql log
/usr/local/mysql/bin/mysqldump -uroot -p -S /usr/local/mysql/mysql.sock --default-character-set=utf8 --extended-insert=false --triggers -R --hex-blob --all-databases --master-data=1 --flush-logs >/tmp/create-master2-20140416.sql


2 scp the sql log to the slave from master
scp create-master2-20140409.sql 10.xx.3.x2:/tmp/




3 create the replication account in master db servers.
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' IDENTIFIED BY 'xx@xx';


4 import the sql to slave
/usr/local/mysql/bin/mysql -uroot -p -S /usr/local/mysql/mysql.sock --default-character-set=utf8 < /tmp/


5 reset the replication slave status
find the master binlog position of slave from backup sql log file.

change master to master_user='repl', master_password='Plcc0805@replicationm2', master_host='10.xx.3.x1',master_port=3306, master_log_file='mysql-bin.008713',master_log_pos=120;


6 启动slave

start slave;

show slave status\G


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值