У нас есть два набора реплик и один артибер-узел.В наборе реплик один обозначен как первичный, а другой как вторичный.Когда один из них выключается, другой автоматически становится основным.Но в непредвиденных ситуациях, когда и первичный и вторичный выключены (также арбитр) и когда мы перезапускаем их, rs.status показывает оба как ВТОРИЧНЫЙ.Ни один из них не будет избран в качестве основного.rs.status отображает ошибку, как показано ниже (ПРИМЕЧАНИЕ. Мы попытались вручную изменить приоритет первичных / вторичных узлов. Мы используем mongodb версии 2.0 с ключом --keyfile для проверки подлинности. Все базовые проверки выполнены для предварительной отладки, но пока ничего не известно).Просьба предложить.
SECONDARY> rs.status();
{
"set" : "testdata1",
"date" : ISODate("2011-11-08T15:30:14Z"),
"myState" : 2,
"members" : [
{
"_id" : 0,
"name" : "192.162.1.19:10001",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"optime" : {
"t" : 1320763306000,
"i" : 1
},
"optimeDate" : ISODate("2011-11-08T14:41:46Z"),
"self" : true
},
{
"_id" : 1,
"name" : "192.162.1.29:10002",
"health" : 0,
"state" : 8,
"stateStr" : "(not reachable/healthy)",
"uptime" : 0,
"optime" : {
"t" : 0,
"i" : 0
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2011-11-08T15:30:13Z"),
"pingMs" : 0,
"errmsg" : "need to login"
},
{
"_id" : 2,
"name" : "192.162.1.29:10003",
"health" : 0,
"state" : 8,
"stateStr" : "(not reachable/healthy)",
"uptime" : 0,
"optime" : {
"t" : 0,
"i" : 0
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2011-11-08T15:30:13Z"),
"pingMs" : 0,
"errmsg" : "need to login"
}
],
"ok" : 1
}
Below of the log details which we have configured and getting the log details.
===============================================================================
[192.162.1.19]
nohup mongod --rest --shardsvr --replSet testdata1 --port 10001 --oplogSize 50 --nojournal --keyFile /data/mongopwdkey/shardkey --dbpath /data/db/shardrepl_pri_1 > /tmp/shardrepl_pri_1.txt &
[192.162.1.29]
nohup mongod --rest --shardsvr --replSet testdata1 --port 10002 --oplogSize 50 --nojournal --keyFile /data/mongopwdkey/shardkey --dbpath /data/db/shardrepl_sec_1 > /tmp/shardrepl_sec_1.txt &
nohup mongod --rest --shardsvr --replSet testdata1 --port 10003 --oplogSize 10 --nojournal --keyFile /data/mongopwdkey/shardkey --dbpath /data/db/shardrepl_arb_1 > /tmp/shardrepl_arb_1.txt &
[192.162.1.19]
mongo --port 10001
conf = {_id : "testdata1",members : [{_id : 0, host : "192.162.1.19:10001", votes : 2},{_id : 1, host : "192.162.1.29:10002", votes : 1},{_id:2, host: "192.162.1.29:10003", votes : 3, arbiterOnly: true}]}
rs.initiate(conf)
rs.status()
use admin;
db.addUser("admin","admin");
exit;
# mongo -port 10001 admin -u admin -p
MongoDB shell version: 2.0.1
Enter password:
connecting to: 127.0.0.1:10001/admin
SECONDARY> rs.status();
{
"set" : "testdata1",
"date" : ISODate("2011-11-09T10:11:46Z"),
"myState" : 2,
"members" : [
{
"_id" : 0,
"name" : "192.162.1.19:10001",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"optime" : {
"t" : 1320763306000,
"i" : 1
},
"optimeDate" : ISODate("2011-11-08T14:41:46Z"),
"self" : true
},
{
"_id" : 1,
"name" : "192.162.1.29:10002",
"health" : 0,
"state" : 8,
"stateStr" : "(not reachable/healthy)",
"uptime" : 0,
"optime" : {
"t" : 0,
"i" : 0
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2011-11-09T10:11:45Z"),
"pingMs" : 0,
"errmsg" : "need to login"
},
{
"_id" : 2,
"name" : "192.162.1.29:10003",
"health" : 0,
"state" : 8,
"stateStr" : "(not reachable/healthy)",
"uptime" : 0,
"optime" : {
"t" : 0,
"i" : 0
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2011-11-09T10:11:45Z"),
"pingMs" : 0,
"errmsg" : "need to login"
}
],
"ok" : 1
}
[192.162.1.29]
[root@dev_bmapp ~]# mongo -port 10002 admin -u admin -p
MongoDB shell version: 2.0.1
Enter password:
connecting to: 127.0.0.1:10002/admin
SECONDARY> rs.status();
{
"set" : "testdata1",
"date" : ISODate("2011-11-09T10:13:41Z"),
"myState" : 2,
"members" : [
{
"_id" : 0,
"name" : "192.162.1.19:10001",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 67411,
"optime" : {
"t" : 1320763306000,
"i" : 1
},
"optimeDate" : ISODate("2011-11-08T14:41:46Z"),
"lastHeartbeat" : ISODate("2011-11-09T10:13:40Z"),
"pingMs" : 0
},
{
"_id" : 1,
"name" : "192.162.1.29:10002",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"optime" : {
"t" : 1320763306000,
"i" : 1
},
"optimeDate" : ISODate("2011-11-08T14:41:46Z"),
"self" : true
},
{
"_id" : 2,
"name" : "192.162.1.29:10003",
"health" : 1,
"state" : 5,
"stateStr" : "STARTUP2",
"uptime" : 67411,
"optime" : {
"t" : 0,
"i" : 0
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2011-11-09T10:13:41Z"),
"pingMs" : 0
}
],
"ok" : 1
}
Primary Node Log [192.162.1.19]
==============================
Tue Nov 8 20:45:19 [initandlisten] MongoDB starting : pid=31771 port=10001 dbpath=/usr/db/shardrepl_pri_1 64-bit host=tedst.com
Tue Nov 8 20:45:19 [initandlisten] db version v2.0.1, pdfile version 4.5
Tue Nov 8 20:45:19 [initandlisten] git version: 3a5cf0e2134a830d38d2d1aae7e88cac31bdd684
Tue Nov 8 20:45:19 [initandlisten] build info: Linux bs-linux64.10gen.cc 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41
Tue Nov 8 20:45:19 [initandlisten] options: { dbpath: "/usr/db/shardrepl_pri_1", keyFile: "/data/mongopwdkey/shardkey", nojournal: true, oplogSize: 50, port: 10001, replSet: "testdata1", rest: true, shardsvr:
true }
Tue Nov 8 20:45:19 [initandlisten] waiting for connections on port 10001
Tue Nov 8 20:45:19 [websvr] admin web console waiting for connections on port 11001
Tue Nov 8 20:45:19 [rsStart] warning: getaddrinfo("localhost") failed: Name or service not known
Tue Nov 8 20:45:19 [initandlisten] connection accepted from 127.0.0.1:44334 #1
Tue Nov 8 20:45:19 [conn1] authenticate: { authenticate: 1, nonce: "ef53058aadd66cdb", user: "__system", key: "cbb8f221a881a90f8335edfb872a2300" }
Tue Nov 8 20:45:19 [conn1] end connection 127.0.0.1:44334
Tue Nov 8 20:45:19 [initandlisten] connection accepted from 127.0.0.1:44335 #2
Tue Nov 8 20:45:19 [conn2] authenticate: { authenticate: 1, nonce: "86291a3e4c0c34e7", user: "__system", key: "2767d3377e700e50ab5a981a1c912516" }
Tue Nov 8 20:45:19 [rsStart] replSet STARTUP2
Tue Nov 8 20:45:19 [rsMgr] replSet total number of votes is even - add arbiter or give one member an extra vote
Tue Nov 8 20:45:19 [rsSync] replSet SECONDARY
Tue Nov 8 20:45:19 [rsHealthPoll] couldn't connect to 192.162.1.29:10002: couldn't connect to server 192.162.1.29:10002
Tue Nov 8 20:45:19 [rsHealthPoll] couldn't connect to 192.162.1.29:10003: couldn't connect to server 192.162.1.29:10003
Tue Nov 8 20:45:19 [rsHealthPoll] replSet info 192.162.1.29:10002 is down (or slow to respond): socket exception
Tue Nov 8 20:45:19 [rsHealthPoll] replSet member 192.162.1.29:10002 is now in state DOWN
Tue Nov 8 20:45:19 [rsMgr] replSet can't see a majority, will not try to elect self
Tue Nov 8 20:45:19 [rsHealthPoll] replSet info 192.162.1.29:10003 is down (or slow to respond): socket exception
Tue Nov 8 20:45:19 [rsHealthPoll] replSet member 192.162.1.29:10003 is now in state DOWN
Tue Nov 8 20:45:34 [rsSync] waiting for 6 pings from other members before syncing
Tue Nov 8 20:45:45 [initandlisten] connection accepted from 192.162.1.29:39967 #3
Tue Nov 8 20:45:45 [conn3] authenticate: { authenticate: 1, nonce: "fedd49f05b5d622a", user: "__system", key: "e935b883e38f43df80ec4d2f0dc44203" }
Tue Nov 8 20:45:49 [rsSync] waiting for 6 pings from other members before syncing
Tue Nov 8 20:46:04 [rsSync] waiting for 6 pings from other members before syncing
Tue Nov 8 20:46:19 [clientcursormon] mem (MB) res:32 virt:338 mapped:80
Tue Nov 8 20:46:19 [rsSync] waiting for 6 pings from other members before syncing
Tue Nov 8 20:46:32 [initandlisten] connection accepted from 127.0.0.1:59064 #4
Tue Nov 8 20:46:32 [conn4] authenticate: { authenticate: 1.0, user: "admin", nonce: "5a933fe3ff7d0f19", key: "f5a9f4d430188708bc1bfc599ce0cfd8" }
Tue Nov 8 20:46:34 [rsSync] waiting for 6 pings from other members before syncing
Tue Nov 8 20:46:49 [rsSync] waiting for 6 pings from other members before syncing
Tue Nov 8 20:47:04 [rsSync] waiting for 6 pings from other members before syncing
Tue Nov 8 20:47:19 [clientcursormon] mem (MB) res:48 virt:419 mapped:160
Tue Nov 8 20:47:19 [rsSync] waiting for 6 pings from other members before syncing
Tue Nov 8 20:47:34 [rsSync] waiting for 6 pings from other members before syncing
Second Node Log [192.162.1.29]
==============================
Tue Nov 8 21:00:10 [initandlisten] MongoDB starting : pid=26348 port=10002 dbpath=/usr/db/shardrepl_sec_1 64-bit host=dev_bmapp
Tue Nov 8 21:00:10 [initandlisten] db version v2.0.1, pdfile version 4.5
Tue Nov 8 21:00:10 [initandlisten] git version: 3a5cf0e2134a830d38d2d1aae7e88cac31bdd684
Tue Nov 8 21:00:10 [initandlisten] build info: Linux bs-linux64.10gen.cc 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41
Tue Nov 8 21:00:10 [initandlisten] options: { dbpath: "/usr/db/shardrepl_sec_1", keyFile: "/data/mongopwdkey/shardkey", nojournal: true, oplogSize: 50, port: 10002, replSet: "testdata1", rest: true, shardsvr:
true }
Tue Nov 8 21:00:10 [initandlisten] waiting for connections on port 10002
Tue Nov 8 21:00:10 [websvr] admin web console waiting for connections on port 11002
Tue Nov 8 21:00:10 [rsStart] warning: getaddrinfo("localhost") failed: Name or service not known
Tue Nov 8 21:00:10 [initandlisten] connection accepted from 127.0.0.1:49277 #1
Tue Nov 8 21:00:10 [conn1] authenticate: { authenticate: 1, nonce: "d70feca6820c2618", user: "__system", key: "5a722a819e43d1d7d71732206c39bac8" }
Tue Nov 8 21:00:10 [conn1] end connection 127.0.0.1:49277
Tue Nov 8 21:00:10 [initandlisten] connection accepted from 127.0.0.1:49278 #2
Tue Nov 8 21:00:10 [conn2] authenticate: { authenticate: 1, nonce: "ec42a3430be2cea3", user: "__system", key: "b2d06709594afb1a747784a2a98aee68" }
Tue Nov 8 21:00:10 [rsStart] replSet STARTUP2
Tue Nov 8 21:00:10 [rsMgr] replSet total number of votes is even - add arbiter or give one member an extra vote
Tue Nov 8 21:00:10 [rsSync] replSet SECONDARY
Tue Nov 8 21:00:10 [rsHealthPoll] replSet info member 192.162.1.29:10003 is up
Tue Nov 8 21:00:10 [rsHealthPoll] replSet member 192.162.1.29:10003 is now in state STARTUP2
Tue Nov 8 21:00:10 [rsHealthPoll] replSet info member 192.162.1.19:10001 is up
Tue Nov 8 21:00:10 [rsHealthPoll] replSet member 192.162.1.19:10001 is now in state SECONDARY
Tue Nov 8 21:00:10 [rsMgr] not electing self, 192.162.1.29:10003 would veto
Tue Nov 8 21:00:10 [rsMgr] not electing self, 192.162.1.29:10003 would veto
Tue Nov 8 21:00:11 [initandlisten] connection accepted from 192.162.1.29:45450 #3
Tue Nov 8 21:00:11 [initandlisten] connection accepted from 192.168.1.19:56403 #4
Tue Nov 8 21:00:16 [rsMgr] not electing self, 192.162.1.29:10003 would veto
Tue Nov 8 21:00:22 [rsMgr] not electing self, 192.162.1.29:10003 would veto
Tue Nov 8 21:00:26 [rsMgr] not electing self, 192.162.1.29:10003 would veto
Tue Nov 8 21:00:28 [rsMgr] not electing self, 192.162.1.29:10003 would veto
Tue Nov 8 21:00:34 [rsMgr] not electing self, 192.162.1.29:10003 would veto
Tue Nov 8 21:00:40 [rsMgr] not electing self, 192.162.1.29:10003 would veto
Tue Nov 8 21:00:41 [rsMgr] not electing self, 192.162.1.29:10003 would veto
Tue Nov 8 21:00:46 [rsMgr] not electing self, 192.162.1.29:10003 would veto
Tue Nov 8 21:00:52 [rsMgr] not electing self, 192.162.1.29:10003 would veto
Tue Nov 8 21:00:56 [rsMgr] not electing self, 192.162.1.29:10003 would veto
Tue Nov 8 21:00:58 [rsMgr] not electing self, 192.162.1.29:10003 would veto
Tue Nov 8 21:01:04 [rsMgr] not electing self, 192.162.1.29:10003 would veto
Tue Nov 8 21:01:10 [clientcursormon] mem (MB) res:32 virt:329 mapped:80
Tue Nov 8 21:01:10 [rsMgr] not electing self, 192.162.1.29:10003 would veto
Arbitor Log [192.162.1.29]
========================
Tue Nov 8 20:45:43 [initandlisten] MongoDB starting : pid=25602 port=10003 dbpath=/usr/db/shardrepl_arb_1 64-bit host=dev_bmapp
Tue Nov 8 20:45:43 [initandlisten] db version v2.0.1, pdfile version 4.5
Tue Nov 8 20:45:43 [initandlisten] git version: 3a5cf0e2134a830d38d2d1aae7e88cac31bdd684
Tue Nov 8 20:45:43 [initandlisten] build info: Linux bs-linux64.10gen.cc 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41
Tue Nov 8 20:45:43 [initandlisten] options: { dbpath: "/usr/db/shardrepl_arb_1", keyFile: "/data/mongopwdkey/shardkey", nojournal: true, oplogSize: 10, port: 10003, replSet: "testdata1", rest: true, shardsvr:
true }
Tue Nov 8 20:45:43 [initandlisten] waiting for connections on port 10003
Tue Nov 8 20:45:43 [websvr] admin web console waiting for connections on port 11003
Tue Nov 8 20:45:43 [rsStart] warning: getaddrinfo("localhost") failed: Name or service not known
Tue Nov 8 20:45:43 [initandlisten] connection accepted from 127.0.0.1:35243 #1
Tue Nov 8 20:45:43 [conn1] authenticate: { authenticate: 1, nonce: "58de2a6831f1e8d9", user: "__system", key: "6a91a713f03914981bf02291ed2be857" }
Tue Nov 8 20:45:43 [conn1] end connection 127.0.0.1:35243
Tue Nov 8 20:45:43 [initandlisten] connection accepted from 127.0.0.1:35244 #2
Tue Nov 8 20:45:43 [conn2] authenticate: { authenticate: 1, nonce: "5b004a2a3b5dc6aa", user: "__system", key: "6b558e1b9f108f1b0ddfa2186d037fd7" }
Tue Nov 8 20:45:43 [rsStart] replSet STARTUP2
Tue Nov 8 20:45:43 [rsMgr] replSet total number of votes is even - add arbiter or give one member an extra vote
Tue Nov 8 20:45:43 [rsHealthPoll] couldn't connect to 192.162.1.29:10002: couldn't connect to server 192.162.1.29:10002
Tue Nov 8 20:45:43 [rsHealthPoll] replSet info 192.162.1.29:10002 is down (or slow to respond): socket exception
Tue Nov 8 20:45:43 [rsHealthPoll] replSet member 192.162.1.29:10002 is now in state DOWN
Tue Nov 8 20:45:43 [initandlisten] connection accepted from 192.168.1.19:58278 #3
Tue Nov 8 20:45:45 [rsHealthPoll] replSet info member 192.162.1.19:10001 is up
Tue Nov 8 20:45:45 [rsHealthPoll] replSet member 192.162.1.19:10001 is now in state SECONDARY
Tue Nov 8 20:46:43 [clientcursormon] mem (MB) res:32 virt:254 mapped:80
Tue Nov 8 20:51:43 [clientcursormon] mem (MB) res:32 virt:254 mapped:80
Tue Nov 8 20:56:43 [clientcursormon] mem (MB) res:32 virt:254 mapped:80
Tue Nov 8 21:00:10 [initandlisten] connection accepted from 192.162.1.29:51209 #4
Tue Nov 8 21:00:10 [conn4] authenticate: { authenticate: 1, nonce: "645eb986e2df4ea6", user: "__system", key: "11937268ef824799913b556c48cbd146" }
Tue Nov 8 21:01:43 [clientcursormon] mem (MB) res:32 virt:255 mapped:80
Tue Nov 8 21:02:43 [clientcursormon] mem (MB) res:32 virt:319 mapped:80
Tue Nov 8 21:07:43 [clientcursormon] mem (MB) res:32 virt:319 mapped:80
Tue Nov 8 21:12:43 [clientcursormon] mem (MB) res:32 virt:319 mapped:80
Tue Nov 8 21:17:43 [clientcursormon] mem (MB) res:32 virt:319 mapped:80
Tue Nov 8 21:22:43 [clientcursormon] mem (MB) res:32 virt:319 mapped:80
Tue Nov 8 21:27:43 [clientcursormon] mem (MB) res:32 virt:319 mapped:80
Tue Nov 8 21:32:43 [clientcursormon] mem (MB) res:32 virt:319 mapped:80
Tue Nov 8 21:37:43 [clientcursormon] mem (MB) res:32 virt:319 mapped:80
Tue Nov 8 21:42:43 [clientcursormon] mem (MB) res:32 virt:319 mapped:80
Tue Nov 8 21:47:44 [clientcursormon] mem (MB) res:32 virt:319 mapped:80
Tue Nov 8 21:52:44 [clientcursormon] mem (MB) res:32 virt:319 mapped:80
"/tmp/shardrepl_arb_1.txt" 249L, 18928C