日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

四条命令搞定mysql主从

發布時間:2024/6/21 数据库 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 四条命令搞定mysql主从 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一 . 環境準備

  先上拓撲圖

兩個虛擬機 129和130.CentOS 6.3 安裝mysql 版本5.1 .yum 確保安裝配置一樣.

1 yum -y install mysql mysql-devel mysql-server

service mysqld start

二 環境.

  實驗環境 service iptables stop? || setenforce 0

三 主從配置

  vi /etc/my.cnf

1 主服務器 2 log-bin 3 server-id=129 4 從服務器 5 log-bin 6 server-id=130

主服務器上

1 grant replication slave on *.* to 'testsync'@'*' identified by '123456'

創建賬號給從服務器用.

** use mysql; select * from user='testsync'? 能看到賬號建立.這一步一般不會有問題.

1 mysql> show master status\G 2 *************************** 1. row *************************** 3 File: mysqld-bin.000001 4 Position: 106 5 Binlog_Do_DB: 6 Binlog_Ignore_DB: 7 1 row in set (0.00 sec)

記錄信息,從服務器會用到

?

從服務器上

1 change master to master_host = '192.168.137.129',master_user = 'testsync',master_password = '123456',
2 master_log_file = 'mysqld-bin.000001',master_log_pos = 106;

啟動 slave start; 查看信息

1 mysql> show slave status\G 2 *************************** 1. row *************************** 3 Slave_IO_State: 4 Master_Host: 192.168.137.129 5 Master_User: testsync 6 Master_Port: 3306 7 Connect_Retry: 60 8 Master_Log_File: mysqld-bin.000001 9 Read_Master_Log_Pos: 106 10 Relay_Log_File: mysqld-relay-bin.000002 11 Relay_Log_Pos: 4 12 Relay_Master_Log_File: mysqld-bin.000001 13 Slave_IO_Running: Yes 14 Slave_SQL_Running: Yes 15 Replicate_Do_DB: 16 Replicate_Ignore_DB: 17 Replicate_Do_Table: 18 Replicate_Ignore_Table: 19 Replicate_Wild_Do_Table: 20 Replicate_Wild_Ignore_Table: 21 Last_Errno: 0 22 Last_Error: 23 Skip_Counter: 0 24 Exec_Master_Log_Pos: 106 25 Relay_Log_Space: 106 26 Until_Condition: None 27 Until_Log_File: 28 Until_Log_Pos: 0 29 Master_SSL_Allowed: No 30 Master_SSL_CA_File: 31 Master_SSL_CA_Path: 32 Master_SSL_Cert: 33 Master_SSL_Cipher: 34 Master_SSL_Key: 35 Seconds_Behind_Master: NULL 36 Master_SSL_Verify_Server_Cert: No 37 Last_IO_Errno: 1593 38 Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it). 39 Last_SQL_Errno: 0 40 Last_SQL_Error: 41 1 row in set (0.00 sec)


IO yes ,sql yes .其實主從配置還是很簡單的.

?

** server-id 必須有區別

??? server 之間網絡可達,之間3306端口可達

 log-bin 打開, log-position 一致. 主從服務器版本,初始數據信息一致. 

?

done . that's all .

?

may tomorrow a clear morning.

本站博客皆為原創,轉載請標記下 小三爺.多謝~~!

?

轉載于:https://www.cnblogs.com/liuyuxing/p/5024802.html

總結

以上是生活随笔為你收集整理的四条命令搞定mysql主从的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。