mysql主從配置

來源:互聯網
上載者:User

標籤: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上建立主從使用者
[[email protected] ~]# mysql -uroot -pyou_password
mysql> grant replication slave on *.* to [email protected]‘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不能一樣
[[email protected] ~]# 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主從配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.