资源描述:
《mongodb主从仲裁集群安装部署》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、mongo安装配置一、主、从、仲裁环境搭建1.环境系统版本:#cat/etc/issueCentOSrelease6.5(Final)系统位数#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.下载并创建文件夹下载mongodb-linux-x86_64-
2、2.4.6.tgz,在每台机器上加压,并且#mkdirdata#mkdirlogs#cdlogs#touchmongodb.log3.在每台机器解压后的bin下执行命令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:./mong
3、od--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/logs/mongodb.log--port27018--
4、replSettest/192.168.192.142:27018,192.168.192.143:27018--fork--logappend--nojuornal最开始在142执行命令的时候,没有加--nojournal,结果报错:abouttoforkchildprocess,waitinguntilserverisreadyforconnections.forkedprocess:5428alloutputgoingto:/home/mongodb/mongo/logs/mongodb.logERROR:childprocessfa
5、iled,exitedwitherrornumber100解决:查看日志logs/mongodb.log,发现步骤:先找到/data下,发现,存在一个mongod.lock文件#rm–fmongod.lock删掉lock文件,然后在命令行后面加上—nojournal,重新启动,OK!4.配置在143服务器下的../bin下,运行mongodb数据库,注意安装的时候,我们用的不是默认的27017端口,一次,如果直接运行#./mongo会提示看来mongo命令已经默认的连接了27017端口,怎么修改连接的端口呢?#./mongo–help懂了!
6、使用#./mongo-port27018就可以连上了。首先执行>db.runCommand({"replSetInitiate":{..."_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"
7、:0,"host":"59.108.137.55:27017"},{"_id":1,"host":"59.108.137.56:27017"}]}});{"ok":0,"errmsg":"accessdenied;useadmindb"}此处提示“使用admindb”,执行一下:#useadmin再执行上述命令就可以了。此时输出:{"info":"Confignowsavedlocally.Shouldcomeonlineinaboutaminute.","ok":1}然后:>rs.initiate();提示输出:{"info":"tryq
8、ueryinglocal.system.replsettoseecurrentconfiguration","ok":0,"errmsg":"alreadyinitialized