日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

MongoDB replSet

發(fā)布時間:2025/5/22 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MongoDB replSet 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>

http://cn.docs.mongodb.org/manual/tutorial/convert-secondary-into-arbiter/

http://api.mongodb.org/wiki/current/Replica%20Set%20Tutorial.html

http://cn.docs.mongodb.org/manual/core/replication/

還是看官方文檔吧!


新建目錄 # mkdir -p /data/rs0 /data/rs1 /data/rs2啟動mongod replSet # ./bin/mongod --port 11100 --dbpath /data/rs0 --replSet fish --smallfiles # ./bin/mongod --port 11101 --dbpath /data/rs1 --replSet fish --smallfiles # ./bin/mongod --port 11102 --dbpath /data/rs2 --replSet fish --smallfilesmongod replSet 報錯 Fri Nov 30 16:07:27 [rsStart] warning: getaddrinfo("lenovo11") failed: Name or service not known Fri Nov 30 16:07:27 [rsStart] getaddrinfo("lenovo11") failed: Name or service not known Fri Nov 30 16:07:27 [rsStart] trying to contact lenovo11:11100 Fri Nov 30 16:07:27 [rsStart] getaddrinfo("lenovo11") failed: Name or service not known Fri Nov 30 16:07:27 [rsStart] couldn't connect to lenovo11:11100: couldn't connect to server lenovo11:11100 Fri Nov 30 16:07:27 [rsStart] getaddrinfo("lenovo11") failed: Name or service not known Fri Nov 30 16:07:27 [rsStart] replSet can't get local.system.replset config from self or any seed (yet)# /usr/local/mongodb/bin/mongo localhost:11100 > config = { _id: 'fish' ,members: [{_id:0,host:"127.0.0.1:11100"},{_id:1,host:"127.0.0.1:11101"},{_id:2,host:"127.0.0.1:11102}]} > rs.initiate(config) {"startupStatus" : 4,"info" : "fish","errmsg" : "all members and seeds must be reachable to initiate set", "ok" : 0 } > rs.status() {"startupStatus" : 4,"errmsg" : "can't currently get local.system.replset config from self or any seed (EMPTYUNREACHABLE)","ok" : 0 } > rs.conf() null > db.getReplicationInfo() { "errmsg" : "neither master/slave nor replica set replication detected" }***************************************** 解決 ********************************************** 問了公司一個高手,雖然有點不屑這種小問題,不過還是指出問題所在。 “這就是DNS的問題,它找不到“l(fā)enovo11”這個機(jī)器對應(yīng)的ip。” ---> 原來是mongodb不能解析lenovo11.在/etc/hosts 添加一行: 127.0.0.1 lenovo11[root@lenovo11 mongodb]# ./bin/mongo localhost:11100 MongoDB shell version: 2.2.1 connecting to: localhost:11100/test > config = { _id:'fish',members:[ {_id:0,host:'localhost:11100'}, {_id:1,host:'localhost:11101'}, {_id:2,host:'localhost:11102'}]} {"_id" : "fish","members" : [{"_id" : 0,"host" : "localhost:11100"},{"_id" : 1,"host" : "localhost:11101"},{"_id" : 2,"host" : "localhost:11102"}] } > rs.initiate(config) {"info" : "Config now saved locally. Should come online in about a minute.","ok" : 1 } > rs.status() {"set" : "fish","date" : ISODate("2012-11-30T09:41:51Z"),"myState" : 1,"members" : [{"_id" : 0,"name" : "localhost:11100","health" : 1,"state" : 1,"stateStr" : "PRIMARY","uptime" : 172,"optime" : Timestamp(1354268446000, 1),"optimeDate" : ISODate("2012-11-30T09:40:46Z"),"self" : true},{"_id" : 1,"name" : "localhost:11101","health" : 1,"state" : 2,"stateStr" : "SECONDARY","uptime" : 55,"optime" : Timestamp(1354268446000, 1),"optimeDate" : ISODate("2012-11-30T09:40:46Z"),"lastHeartbeat" : ISODate("2012-11-30T09:41:50Z"),"pingMs" : 1,"errmsg" : "syncing to: localhost:11100"},{"_id" : 2,"name" : "localhost:11102","health" : 1,"state" : 3,"stateStr" : "RECOVERING","uptime" : 55,"optime" : Timestamp(0, 0),"optimeDate" : ISODate("1970-01-01T00:00:00Z"),"lastHeartbeat" : ISODate("2012-11-30T09:41:49Z"),"pingMs" : 207}],"ok" : 1 } fish:PRIMARY> rs.conf rs.conf( rs.config( fish:PRIMARY> rs.conf() {"_id" : "fish","version" : 1,"members" : [{"_id" : 0,"host" : "localhost:11100"},{"_id" : 1,"host" : "localhost:11101"},{"_id" : 2,"host" : "localhost:11102"}] } fish:PRIMARY> rs. rs.add( rs.constructor rs.isMaster( rs.status( rs.addArb( rs.debug rs.propertyIsEnumerable( rs.stepDown( rs.apply( rs.freeze( rs.prototype rs.syncFrom( rs.call( rs.hasOwnProperty( rs.reconfig( rs.toLocaleString( rs.conf( rs.help( rs.remove( rs.toString( rs.config( rs.initiate( rs.slaveOk( rs.valueOf( fish:PRIMARY> rs.isMaster() {"setName" : "fish","ismaster" : true,"secondary" : false,"hosts" : ["localhost:11100","localhost:11102","localhost:11101"],"primary" : "localhost:11100","me" : "localhost:11100","maxBsonObjectSize" : 16777216,"localTime" : ISODate("2012-11-30T09:45:59.351Z"),"ok" : 1 }


轉(zhuǎn)載于:https://my.oschina.net/shineyyl/blog/92973

總結(jié)

以上是生活随笔為你收集整理的MongoDB replSet的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。