通过密钥文件进行身份验证的mongodb分片副本集 [英] mongodb sharding replica sets with authentication via keyfile

查看:92
本文介绍了通过密钥文件进行身份验证的mongodb分片副本集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有两个副本集和一个artiber节点.在副本集中,一个被指定为主副本,另一个被指定为次副本.当其中一个关闭时,另一个将自动接管为主服务器.但是在无法预料的情况下,当主服务器和辅助服务器都关闭时(也是仲裁器),当我们重新启动它们时,rs.status都显示为SECONDARY.他们都没有被选为主要. rs.status显示如下错误(注意:我们尝试手动更改pri/secondary节点的优先级.我们使用带有--keyfile的mongodb 2.0版进行身份验证.所有基本检查均已完成初步调试,但到目前为止没有任何线索).请建议.

We are having two replica sets and one artiber node. In the replica set one is designated as primary and other as secondary. When one of them is shut down, automatically the other one takes over as primary. But under unforseen situations, when both the primary and secondary are down (also the arbiter) and when we restart them, the rs.status shows both as SECONDARY. None of them gets elected as primary. rs.status displays an error as below (NOTE: We tried changing the priority of pri/secondary nodes manually. We are using mongodb version 2.0 with --keyfile for authentication. All basic checks done for preliminary debugging but no clue so far). Pls suggest.

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

推荐答案

  1. 检查密钥文件的权限,以确保可以读取它.
  2. 检查mongod日志以查看是否报告了您可以修复的任何错误

否则,根据 https://jira.mongodb.org/browse,这可能是一个错误/SERVER-3929 ,由 https://jira.mongodb.org/browse修复/SERVER-3715 在2.0.2中(撰写本文时尚未发布).

Otherwise, this may be a bug as per https://jira.mongodb.org/browse/SERVER-3929 which is fixed by https://jira.mongodb.org/browse/SERVER-3715 in 2.0.2 (not yet released at time of writing).

SERVER-3929案例中的某些用户报告说,重新启动节点很有帮助.

Some users in the SERVER-3929 case reported that restarting the nodes helped.

这篇关于通过密钥文件进行身份验证的mongodb分片副本集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆