資源描述:
《mongodb主從仲裁集群安裝部署》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫。
1、mongo安裝配置一、主、從、仲裁環(huán)境搭建1.環(huán)境系統(tǒng)版本:#cat/etc/issueCentOSrelease6.5(Final)系統(tǒng)位數(shù)#uname–aLinuxserver1422.6.32-431.el6.x86_64#1SMPFriNov2203:15:09UTC2013x86_64x86_64x86_64GNU/LinuxIP和端口:192.168.192.142:27018192.168.192.143:27018192.168.192.144:27018仲裁2.下載并創(chuàng)建文件夾下載mongodb-linu
2、x-x86_64-2.4.6.tgz,在每臺機(jī)器上加壓,并且#mkdirdata#mkdirlogs#cdlogs#touchmongodb.log3.在每臺機(jī)器解壓后的bin下執(zhí)行命令142:./mongod--dbpath=/home/mongodb/mongo/data--logpath=/home/mongodb/mongo/logs/mongodb.log--port27018--replSettest/192.168.192.143:27018--maxConns=200--fork--logappend--n
3、ojournal143:./mongod--dbpath=/home/mongodb/mongo/data--logpath=/home/mongodb/mongo/logs/mongodb.log--port27018--replSettest/192.168.192.142:27018--maxConns=200--fork--logappend--nojournal144:./mongod--dbpath=/home/mongodb/mongo/data--logpath=/home/mongodb/mongo/lo
4、gs/mongodb.log--port27018--replSettest/192.168.192.142:27018,192.168.192.143:27018--fork--logappend--nojuornal最開始在142執(zhí)行命令的時(shí)候,沒有加--nojournal,結(jié)果報(bào)錯(cuò):abouttoforkchildprocess,waitinguntilserverisreadyforconnections.forkedprocess:5428alloutputgoingto:/home/mongodb/mongo/
5、logs/mongodb.logERROR:childprocessfailed,exitedwitherrornumber100解決:查看日志logs/mongodb.log,發(fā)現(xiàn)步驟:先找到/data下,發(fā)現(xiàn),存在一個(gè)mongod.lock文件#rm–fmongod.lock刪掉lock文件,然后在命令行后面加上—nojournal,重新啟動(dòng),OK!4.配置在143服務(wù)器下的../bin下,運(yùn)行mongodb數(shù)據(jù)庫,注意安裝的時(shí)候,我們用的不是默認(rèn)的27017端口,一次,如果直接運(yùn)行#./mongo會(huì)提示看來mongo
6、命令已經(jīng)默認(rèn)的連接了27017端口,怎么修改連接的端口呢?#./mongo–help懂了!使用#./mongo-port27018就可以連上了。首先執(zhí)行>db.runCommand({"replSetInitiate":{..."_id":"test",..."members":[...{..."_id":0,..."host":"192.168.192.142:27018"...},...{"_id":1,..."host":"192.168.192.143:27018"...}...]}})或者:>db.runComm
7、and({"replSetInitiate":{"_id":"test","members":[{"_id":0,"host":"59.108.137.55:27017"},{"_id":1,"host":"59.108.137.56:27017"}]}});{"ok":0,"errmsg":"accessdenied;useadmindb"}此處提示“使用admindb”,執(zhí)行一下:#useadmin再執(zhí)行上述命令就可以了。此時(shí)輸出:{"info":"Confignowsavedlocally.Shouldcomeonl
8、ineinaboutaminute.","ok":1}然后:>rs.initiate();提示輸出:{"info":"tryqueryinglocal.system.replsettoseecurrentconfiguration","ok":0,"errmsg":"alreadyinitialized