MySQL5 master slave安裝配置全過(guò)程
我們今天主要向大家介紹的是MySQL5 master slave安裝配置的實(shí)際操作過(guò)程,我們?cè)趯?duì)MySQL5 master slave進(jìn)行安裝配置日志在以下的背景中,以下就是文章的具體內(nèi)容的介紹,望你瀏覽之后會(huì)有所收獲。
master:192.168.100.231 MySQL(和PHP搭配之最佳組合)5.0.19 linux
slave: 192.168.100.234 MySQL(和PHP搭配之最佳組合)5.0.18 linux
step1) 配置master
在/etc/init.d MySQL(和PHP搭配之最佳組合)d段加入
要同步的數(shù)據(jù)庫(kù))
- binlog_do_db = test
并確保
- server-id=1
- log-bin=MySQL(和PHP搭配之最佳組合)-bin
- step2) 授權(quán)slave
- GRANT REPLICATION SLAVE ON *.* TO test@192.168.100.234 IDENTIFIED BY '123';
重啟master
step3)配置slave
vi /etc/my.cnf
設(shè)置下面4行
- server-id = 2
- master-host = 192.168.100.231
- master-user = test
- master-password = 123
重啟發(fā)現(xiàn)slave的I/O線程工作正常,而SQL線程不工作
報(bào)了很怪的錯(cuò)誤
070307 16:30:27 [ERROR] Slave: Error 'Table 'passport.loginuser' doesn't exist' on query. Default database: 'passport'. Query: 'delete from loginuser where tokenRefreshTime<='2006-07-03 07:00:00'', Error_code: 1146
070307 16:30:27 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'MySQL(和PHP搭配之最佳組合)-bin.000001' position 98
因該是relay log中的數(shù)據(jù)有問(wèn)題,于是在
將master機(jī)器上的數(shù)據(jù)拷到244,發(fā)現(xiàn)還是有問(wèn)題。
于是在/etc/my.cnf中加入
- replicate-do-db=test
MySQL5 master slave安裝配置日志中需要重啟slave,
show slave status發(fā)現(xiàn)兩個(gè)線程工作正常
5)測(cè)試
在master的test數(shù)據(jù)的user表中添加了一條記錄
然后在slave上通過(guò)show processlist看slave工作情況一切正常,
再查數(shù)據(jù)庫(kù)數(shù)據(jù)似乎沒(méi)有更新,查看slave錯(cuò)誤日志
070307 16:45:16 [ERROR] Slave: Error 'Can't create database 'test'; database exists' on query. Default database: 'test'. Query: 'create database test', Error_code: 1007
070307 16:45:16 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'MySQL(和PHP搭配之最佳組合)-bin.000040' position 70671
原來(lái)都是我當(dāng)初拷貝數(shù)據(jù)惹的禍,因?yàn)橹鳈C(jī)日志在我建數(shù)據(jù)庫(kù)的時(shí)候就開(kāi)始了,所以我拷貝數(shù)據(jù)多此一舉,于是
我刪除拷貝的數(shù)據(jù)庫(kù),一切ok
以上的相關(guān)內(nèi)容就是對(duì)MySQL5 master slave安裝配置日志的介紹,望你能有所收獲。
【編輯推薦】