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