码迷,mamicode.com
首页 > 数据库 > 详细

mysql主从配置

时间:2017-06-19 15:54:57      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:relay   pwa   uid   tls   ror   port   show   get   5.7   

 

 mysql 安装在这里就不说了,可以参考我的安装笔记

http://www.cnblogs.com/vick51/p/7048417.html 

下面直接开始配置mysql 主从

mysql 主从环境介绍

Mysql Master  系统:Centos6.*  mysql version mysql-5.7.17  IP:192.168.1.223
Mysql Slave    系统:Centos6.*  mysql version mysql-5.7.17  IP:192.168.1.224

开始配置 mysql 主从:

 

1、在master上创建主从用户
[root@m3 ~]# mysql -uroot -pyou_password
mysql> grant replication slave on *.* to vick@‘192.168.1.224‘ identified by ‘vick_slave‘;
mysql> flush privileges;
mysql> show master status\G
*************************** 1. row ***************************
File: mysql-bin.000002
Position: 997
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: 89a442a1-511d-11e7-b608-000c29789b2f:1-4
row in set (0.00 sec)

2、在slave上配置从库
vim /etc/my.cnf
server_id = 2 ## 注意数据库的唯一ID不能一样
[root@m4 ~]# mysql -uroot -pwangkai
mysql> change master to \
-> master_host=‘192.168.1.223‘, \
-> master_user=‘vick‘,\
-> master_password=‘vick_slave‘, \
-> master_port=3306, \
-> master_log_file=‘mysql-bin.000002‘,\
-> master_log_pos=997;

Query OK, 0 rows affected, 2 warnings (0.02 sec)
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.223
Master_User: vick
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 997
Relay_Log_File: relay.000003
Relay_Log_Pos: 320
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table: information_schema.%,performance_schema.%
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 997
Relay_Log_Space: 683
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 2
Master_UUID: 89a442a1-511d-11e7-b608-000c29789b2f
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set: 5ee0a7e0-51bf-11e7-93a9-000c2923b43c:1-2
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
row in set (0.00 sec)

当这两项为yes 说明显示正常
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

mysql主从配置

标签:relay   pwa   uid   tls   ror   port   show   get   5.7   

原文地址:http://www.cnblogs.com/zoupufa/p/7048951.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!