【MySQL 复制】20G以下的mysql数据库从库快速搭建
2014-04-22 21:33
453 查看
因为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
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
相关文章推荐
- [MySQL 复制] 20G以下的mysql数据库从库快速搭建
- 20G以下的mysql数据库从库快速搭建
- 使用mysqlreplicate命令快速搭建 Mysql 主从复制
- Xtrabackup快速搭建MySQL主从复制
- 使用mysqlreplicate命令快速搭建 Mysql 主从复制
- 实战mysql集群搭建(二)-- 实现mysql数据库主从复制
- 利用percona-xtrabackup快速搭建MySQL数据库主从复制
- 使用mysqlreplicate命令快速搭建 Mysql 主从复制
- 安装MySQL先复制1. Linux (CentOS 7.3) 下快速安装Mysql数据库(安装教程)2.后复制阿里云配置 MySQL 远程连接的详细步骤
- mysql 5.7.15单机主从快速搭建并配置复制表到不同库
- Jsp+Tomcat+Mysql搭建web项目 Jsp链接Mysql数据库
- 在linux同一台主机下面搭建两个mysql 实例并实现主从复制 (二)
- MySQL主主复制搭建教程收集(待实践)
- MySQL复制搭建
- CentOS6.5使用yum快速搭建LAMP(Linux+Apache+MySQL+PHP)环境
- 基于Docker搭建MySQL主从复制
- 用 KVM 搭建web集群实验笔记 - MySQL多实例和主从复制
- mysql主从复制搭建中几种log和pos详解
- 【大型网站技术实践】初级篇:搭建MySQL主从复制经典架构
- Django + mysql 快速搭建简单web投票系统