Mysql5.7.13主从同步(复制)配置
主从同步是分布式mysql数据库相当重要的配置,现在我在虚拟机上完成主从配置,系统是CenterOS6.5,mysql版本是5.7.13
主服务器的ip是192.168.19.139 副服务器的ip是192.168.19.142
1.主服务器配置
(1)修改my.cnf(注意使用root)
vim /etc/my.cnf sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
log-bin=mysqlbin-log
server_id=
basedir=/home/mysql
user=mysql
datadir=/home/mysql/data
port=
innodb_flush_log_at_trx_commit=
sync_binlog=
log-slave-updates
(2)进入mysql安装目录下的bin,启动mysql
cd /home/mysql/bin ./mysqld
(3)重开启mysql客户端,进入mysql安装目录下的bin,授权副服务器主从复制,用mysqld的好处是可以查看错误。
./mysql -uroot -p mysql> grant replication slave on *.* to test@192.168.19.142 identified by '';
(4)显示主服务器状态
mysql> show master status;
+---------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------------+----------+--------------+------------------+-------------------+
| mysqlbin-log. | | | | |
+---------------------+----------+--------------+------------------+-------------------+
2.副服务器配置
(1)修改my.cnf(注意使用root)
vim /etc/my.cnf sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLE
user=mysql
server_id =
replicate-do-db = sbfxd
master-info-file = master.info
relay-log = relay-relay-bin
relay-log-index = relay-relay-bin.index
relay-log-info-file=relay-relay-log.info
(2)进入mysql安装目录下的bin,启动mysql
1 cd /home/mysql/bin 2 ./mysqld
(3)重开启mysql客户端,进入mysql安装目录下的bin,设置slave属性并开始服务
./mysql -uroot -p
mysql> change master to master_host='192.168.19.139',master_port= , master_log_file='mysqlbin-log.000019', master_log_pos= , master_bind='', master_user='test',master_password='123';
mysql> start slave;
(4)显示副服务器的状态
show slave status \G; Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.19.139
Master_User: test
Master_Port:
Connect_Retry:
Master_Log_File: mysqlbin-log.
Read_Master_Log_Pos:
Relay_Log_File: relay-relay-bin.
Relay_Log_Pos:
Relay_Master_Log_File: mysqlbin-log.
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: sbfxd
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:
Last_Error:
Skip_Counter:
Exec_Master_Log_Pos:
Relay_Log_Space:
Until_Condition: None
Until_Log_File:
Until_Log_Pos:
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master:
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno:
Last_IO_Error:
Last_SQL_Errno:
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:
Master_UUID: -5ab2-11e6-869b-000c293990c1
Master_Info_File: /home/mysql/data/master.info
SQL_Delay:
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count:
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
出现两个yes表示slave可以跑了
3.注意事项:
(1)楼主的虚拟机是通过克隆产生的,所以不需要对mysql进行备份,然后在副服务器上恢复,这步对于数据库极其重要,否则就会出现如下错误:
--17T03::.579193Z [ERROR] Slave SQL for channel '': Error executing row event: 'Table 'sbfxd.sbtable' doesn't exist', Error_code: 1146
--17T03::.584268Z [Warning] Slave: Table 'sbfxd.sbtable' doesn't exist Error_code: 1146
(2)如果将主服务器的属性配错了需要stop slave,然后设置好之后start slave
Mysql5.7.13主从同步(复制)配置的更多相关文章
- MySQL数据库的主从同步复制配置
一.主从同步机制原理 MYSQL主从同步是在MySQL主从复制(Master-Slave Replication)基础上实现的,通过设置在Master MySQL上的binlog(使其处于打开状态), ...
- 烂泥:mysql5.5主从同步复制配置
本文由秀依林枫提供友情赞助,首发于烂泥行天下. 在上篇文章<烂泥:学习mysql数据库主从同步复制原理>中,我们介绍了有关mysql主从复制的基本原理.在这篇文章中,我们来实际测试下mys ...
- mysql5.5主从同步复制配置
在上篇文章<烂泥:学习mysql数据库主从同步复制原理>中,我们介绍了有关mysql主从复制的基本原理.在这篇文章中,我们来实际测试下mysql5.5的主从同步复制功能. 注意mysql5 ...
- percona-xtrabackup工具实现mysql5.6.34的主从同步复制
percona-xtrabackup工具实现mysql5.6.34的主从同步复制 下载并安装percona-xtrabackup工具 # wget https://www.percona.com/do ...
- MySQL-5.6.13免安装版配置方法
MySQL-5.6.13免安装版配置方法 1. 下载MySQL Community Server 5.6.13 2. 解压MySQL压缩包 将以下载的MySQL压缩包解压到自定义目录下,我的 ...
- Redis的主从同步复制
先来看一下Redis的主从同步复制的原理: 在Slave启动并连接到Master之后,它将主动发送一条SYNC命令.此后Master将启动后台存盘进程,同时收集所有接收到的用于修改数据集的命令,在后台 ...
- mysql5.5 Replication 主从同步
mysql5.5 Replication 主从同步 ------------------[主]------------------[mysqld]server-id=1 log-bin=mysql-b ...
- mysql 主从master-slave同步复制 配置,为读写分离准备
1.为方便,我在一个windows下安装两个mysql实例,端口分别是 3306.3307 打开 my.ini 或 my-default.ini 文件 配置 basedir datadir 和port ...
- Mysql 半同步复制配置
以下是配置和监控半同步复制: 1. 半同步复制功能以plugin的方式接入MySQL,需要在主库与从库两端同时开启半同步的支持,具体配置如下: On the master mysql> INST ...
随机推荐
- ODAC (odp.net) 从开发到部署
2013-09-30 16:08 4097人阅读 评论(0) 收藏 举报 分类: Oracle(10) 版权声明:本文为博主原创文章,未经博主允许不得转载. 1. 确定你开发机和服务器的操作系统是 ...
- SqlServer查询表中各列名称、表中列数
查询表名为tb_menu的所有列名 select name from syscolumns where id=object_id('tb_menu') 查询表名为tb_menu的所有列名个数 ...
- Ue4的容器(数据结构)
之前都没注意,作为程序眼这些还是比较重要的 Engine\Source\Runtime\Core\Public\Containers\
- 每天一个linux命令--定时启动
1.设置启动的时间,输入crontab -e命令 设置一种编辑器,进入编辑界面,设置启动的时间为每5分钟启动一次wanghy.sh脚本 # m h dom mon dow command # */ * ...
- java-并发-活性
浏览以下内容前,请点击并阅读 声明 一个并发程序以适时方式执行的能力叫活性.以下部分介绍最常见的一种活性问题,死锁,并简单介绍其他两种活性问题,饥饿和活锁. 死锁 死锁描述了一种情况:两个或两个以上的 ...
- Building a RESTful Web Service
Reference: https://spring.io/guides/gs/rest-service/ 参照上述链接进行操作,使用gradle build. 因为total new to this. ...
- Access restriction: The type 'FileURLConnection' is not API
遇到这种报错,解决方案如下: 报错原因是访问限制报错 工具栏中Project>preferences>java-Compiler>Errors/Warnings>把右侧的[De ...
- POJ 1979 题解
Red and Black Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 31722 Accepted: 17298 D ...
- 使用神经网络来识别手写数字【译】(三)- 用Python代码实现
实现我们分类数字的网络 好,让我们使用随机梯度下降和 MNIST训练数据来写一个程序来学习怎样识别手写数字. 我们用Python (2.7) 来实现.只有 74 行代码!我们需要的第一个东西是 MNI ...
- 前端UI框架和JS类库
一.前端框架库: 1.Zepto.js 地址:http://www.css88.com/doc/zeptojs/ 描述:Zepto是一个轻量级的针对现代高级浏览器的JavaScript库, 它与jqu ...