mysql主從複製、動作陳述式

來源:互聯網
上載者:User

標籤:ant   配置   設定檔   pos   connect   run   使用者   dump   database   

授權

grant replication slave on *.* to [email protected] identified by "123456"

登入測試

mysql -h 192.168.10.63 -u slave -p 123456

 

scp all1.sql 192.168.10.64:/root

 匯入資料庫,和主伺服器保持一致

mysql -u root -p <all1.sql

Relay_Log_Pos:459

Relay_Master_log_File:mysqllog.000001

Slave_IO_Running:Yes  #可以看到這兩個Yes,說明從伺服器安裝成功

Slave_SQL_Running:Yes

Slave_IO_Running:一個負責與主機的io通訊

Slave_SQL_Running:負責自己的slave mysql 進程

修改從伺服器設定檔:

vim /etc/my.cnf

[mysqld]

datadir = /var/lib/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

#Disabling symbolic-links is recommended to prevent assorted security risk

symbolic-links=0

 

唯一的server-id值,必須與主伺服器的以及其他從伺服器的不相同。可以認為server-id值類似於IP地址:這些ID值能唯一識別賦值伺服器群幾種的每個伺服器執行個體。

master-host=192.168.10.63  #指定主伺服器IP地址

master-user=slave  #指定在主伺服器上可以進行同步的使用者名稱

master-password=123456  #密碼

####以下可以不寫

master-port=3306   #同步所用的連接埠

master-connect-retry=60  #斷點重新連線時間

 

複製前保證主從兩個資料庫資料一致:

把主的未經處理資料傳給從:

例:到處所有資料庫:

mysqldump -u root -p -A>all1.sql

參數:-A,--all-databases Dump all the databases.

 

show binlog events

 

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.