3 月 012014
 

 



mongod   replSet 配置修改

1:修改 /etc/init.d/mongod 把里面的#OPTIONS=” -f $CONFIGFILE –replSet shanliao_base” 注释 再添加修改 OPTIONS=” -f $CONFIGFILE”  然后重启
2:删除本地
use local
db.dropDatabase()
 
3:修改 /etc/init.d/mongod 把里面的#OPTIONS=” -f $CONFIGFILE –replSet shanliao_base” 注释去掉 然后注释#OPTIONS=” -f $CONFIGFILE” 然后重启
 
4:保证一个数据保留做PRIMARY,将其他的mongod的数据全部删除,然后在PRIMARY上执行命令
rsconf = {
“_id” : “shanliao_base”,
“members” : [{
“_id” : 0,
“host” : “192.168.0.42:27017″},{
“_id” : 1,
“host” : “192.168.0.43:27017”},{
“_id” : 2,
“host” : “192.168.0.44:27017”},{
“_id” : 3,
“host” : “192.168.0.45:27017”,
“arbiterOnly” : true}]
}
rs. initiate(rsconf)
rs.
initiate(rsconf)
 
5:连接一个,通过rs.status();查看状态,即完成更改
shanliao_base:PRIMARY> rs.status();
{
“set” : “shanliao_base”,
“date” : ISODate(“2014-01-07T05:57:08Z”),
“myState” : 1,
“members” : [
{
“_id” : 0,
“name” : “192.168.0.42:27017”,
“health” : 1,
“state” : 1,
“stateStr” : “PRIMARY”,
“uptime” : 265,
“optime” : Timestamp(1389074191, 1),
“optimeDate” : ISODate(“2014-01-07T05:56:31Z”),
“self” : true
},
{
“_id” : 1,
“name” : “192.168.0.43:27017”,
“health” : 1,
“state” : 2,
“stateStr” : “SECONDARY”,
“uptime” : 37,
“optime” : Timestamp(1389074191, 1),
“optimeDate” : ISODate(“2014-01-07T05:56:31Z”),
“lastHeartbeat” : ISODate(“2014-01-07T05:57:08Z”),
“lastHeartbeatRecv” : ISODate(“2014-01-07T05:57:07Z”),
“pingMs” : 22,
“lastHeartbeatMessage” : “syncing to: 192.168.0.42:27017”,
“syncingTo” : “192.168.0.42:27017”
},
{
“_id” : 2,
“name” : “192.168.0.44:27017”,
“health” : 1,
“state” : 5,
“stateStr” : “STARTUP2”,
“uptime” : 37,
“optime” : Timestamp(0, 0),
“optimeDate” : ISODate(“1970-01-01T00:00:00Z”),
“lastHeartbeat” : ISODate(“2014-01-07T05:57:08Z”),
“lastHeartbeatRecv” : ISODate(“2014-01-07T05:57:08Z”),
“pingMs” : 23
},
{
“_id” : 3,
“name” : “192.168.0.45:27017”,
“health” : 1,
“state” : 7,
“stateStr” : “ARBITER”,
“uptime” : 37,
“lastHeartbeat” : ISODate(“2014-01-07T05:57:08Z”),
“lastHeartbeatRecv” : ISODate(“2014-01-07T05:57:08Z”),
“pingMs” : 24
}
],
“ok” : 1
}

 

 Posted by at 下午 3:50

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny