(^o^)/~完美 发表于 2018-10-26 12:02:40

【MongoDB学习笔记32】MongoDB修改副本集配置

# ping host113  
PING host113 (192.168.1.113) 56(84) bytes of data.
  
64 bytes from host113 (192.168.1.113): icmp_seq=1 ttl=64 time=0.060 ms
  
64 bytes from host113 (192.168.1.113): icmp_seq=2 ttl=64 time=0.030 ms
  
64 bytes from host113 (192.168.1.113): icmp_seq=3 ttl=64 time=0.026 ms
  
64 bytes from host113 (192.168.1.113): icmp_seq=4 ttl=64 time=1.04 ms
  
--- host113 ping statistics ---
  
4 packets transmitted, 4 received, 0% packet loss, time 3001ms
  
rtt min/avg/max/mdev = 0.026/0.289/1.041/0.434 ms
  
# mongo
  
MongoDB shell version: 2.6.7
  
connecting to: test
  
spock:PRIMARY> rs.config()
  
{
  
    "_id" : "spock",
  
    "version" : 3,
  
    "members" : [
  
                  { "_id" : 1, "host" : "192.168.1.113:27017"},
  
                  { "_id" : 2, "host" : "192.168.1.112:27017"}
  
                ]
  
}
  
spock:PRIMARY> var config=rs.config()
  
spock:PRIMARY> config.members.host="host113:27017"
  
host113:27017
  
spock:PRIMARY> rs.reconfig(config)
  
2015-02-02T22:21:22.793+0800 DBClientCursor::init call() failed
  
2015-02-02T22:21:22.795+0800 trying reconnect to 127.0.0.1:27017 (127.0.0.1) faile
  
2015-02-02T22:21:22.797+0800 reconnect 127.0.0.1:27017 (127.0.0.1) ok
  
reconnected to server after rs command (which is normal)
  
spock:PRIMARY> rs.config()
  
{
  
    "_id" : "spock",
  
    "version" : 4,
  
    "members" : [
  
            { "_id" : 1,"host" : "host113:27017"},
  
            { "_id" : 2, "host" : "192.168.1.112:27017"}
  
                ]
  
}
  
spock:PRIMARY>


页: [1]
查看完整版本: 【MongoDB学习笔记32】MongoDB修改副本集配置