-----------------------------------------------------------

mysql 5.5 環(huán)境用的數(shù)據(jù)庫(kù)可的多實(shí)例
-----------------------------------------------------------
mysql 主從復(fù)制原理圖

mysql 主從復(fù)制開(kāi)始配置 環(huán)境是一個(gè)數(shù)據(jù)庫(kù)多個(gè)實(shí)例 3306端口為主 3307端口為從
1 開(kāi)始配置主庫(kù)和從庫(kù)的my.cnf配置文件
配置主數(shù)據(jù)庫(kù)的my.cnf文件(3306)
server-id = 1
log-bin=mysql-bin
配置從數(shù)據(jù)庫(kù)的my.cnf文件(3307)
server-id = 2
#log-bin=mysql-bin
然后重啟數(shù)據(jù)庫(kù)
2登錄主數(shù)據(jù)庫(kù)給從數(shù)據(jù)庫(kù)分配權(quán)限用戶
grant replication slave on *.* to 'repl'@'192.168.1.17' identified by '123456';
3 鎖表并且導(dǎo)出主庫(kù)里的數(shù)據(jù)
flush table with read lock;
show master status;查看bin-log的位置狀態(tài)
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000009 | 264 | | |
+------------------+----------+--------------+------------------+
/usr/local/mysql/bin/mysqldump -uroot -plampol -S /tmp/mysql3306.sock --events -A -B > /tmp/master.sql;
4 進(jìn)從數(shù)據(jù)庫(kù)導(dǎo)入主數(shù)據(jù)庫(kù)的數(shù)據(jù)
source /tmp/master.sql
5進(jìn)從庫(kù)執(zhí)行
change master to master_host='192.168.1.17',
master_port=3306,
master_user='repl',
master_password='123456',
master_log_file='mysql-bin.000009',
master_log_pos=264;
6 從庫(kù)開(kāi)啟同步開(kāi)關(guān) start slave
show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.17
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000009
Read_Master_Log_Pos: 500
Relay_Log_File: bogon-relay-bin.000002
Relay_Log_Pos: 489
Relay_Master_Log_File: mysql-bin.000009
Slave_IO_Running: Yes
Slave_SQL_Running: Yes //兩個(gè)yes就ok了主從配置成功
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 500
Relay_Log_Space: 645
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: 1
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
文章名稱:MySQL主從復(fù)制的配置及原理-創(chuàng)新互聯(lián)
標(biāo)題路徑:http://www.jbt999.com/article2/dsesic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App開(kāi)發(fā)、虛擬主機(jī)、云服務(wù)器、標(biāo)簽優(yōu)化、關(guān)鍵詞優(yōu)化、域名注冊(cè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容