MongoDB 4.x上的副本集和操作日志拖尾问题

时间:2019-02-27 11:11:51

标签: mongodb replication mongodb-oplog

我正在将我的应用程序迁移到新服务器,并且无法正常运行oplog。这个想法是设置一个副本集,这样我的Meteor应用程序就会出现尾声。我在旧服务器上遵循与正常工作相同的过程。

我的MongoDB上没有访问控制,因为它仅在本地可用。

旧服务器:

Ubuntu 16.04

MongoDB Shell版本v3.4.1

新服务器:

Ubuntu 1.04

MongoDB Shell版本v4.0.6

我正在使用Phusion Passenger服务Meteor 1.6应用程序。

这是我设置副本集的方法:

/etc/mongod.conf

replication:
  replSetName: rs0
  oplogSizeMB: 100

/ etc / hosts /

127.0.1.1 myhostname myhostname
127.0.0.1 localhost
127.0.0.1 myhostname

重新启动MongoDB。然后在Mongo shell中:

use local
rs.initiate()

在我的乘客配置中:

sudo nano /etc/nginx/sites-enabled/myappname.conf

passenger_env_var MONGO_OPLOG_URL mongodb://localhost:27017/local;

然后重新启动Nginx。

我已经用rs.conf()检查了Mongo shell中的副本集状态:

{
    "_id" : "rs0",
    "version" : 1,
    "protocolVersion" : NumberLong(1),
    "writeConcernMajorityJournalDefault" : true,
    "members" : [
        {
            "_id" : 0,
            "host" : "127.0.0.1:27017",
            "arbiterOnly" : false,
            "buildIndexes" : true,
            "hidden" : false,
            "priority" : 1,
            "tags" : {

            },
            "slaveDelay" : NumberLong(0),
            "votes" : 1
        }
    ],
    "settings" : {
        "chainingAllowed" : true,
        "heartbeatIntervalMillis" : 2000,
        "heartbeatTimeoutSecs" : 10,
        "electionTimeoutMillis" : 10000,
        "catchUpTimeoutMillis" : -1,
        "catchUpTakeoverDelayMillis" : 30000,
        "getLastErrorModes" : {

        },
        "getLastErrorDefaults" : {
            "w" : 1,
            "wtimeout" : 0
        },
        "replicaSetId" : ObjectId("5c7580c68631363039a485f1")
    }
}

但是,在Mongo日志/var/log/mongodb/mongod.log中,我看到了:

2019-02-27T10:26:14.783+0000 I REPL     [replexec-0] New replica set config in use: { _id: "rs0", version: 1, protocolVersion: 1, writeConcernMajorityJournalDefault: true, members: [ { _id: 0, host: "127.0.0.1:27017", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 } ], settings: { chainingAllowed: true, heartbeatIntervalMillis: 2000, heartbeatTimeoutSecs: 10, electionTimeoutMillis: 10000, catchUpTimeoutMillis: -1, catchUpTakeoverDelayMillis: 30000, getLastErrorModes: {}, getLastErrorDefaults: { w: 1, wtimeout: 0 }, replicaSetId: ObjectId('5c7580c68631363039a485f1') } }
2019-02-27T10:26:14.783+0000 I REPL     [replexec-0] This node is 127.0.0.1:27017 in the config
2019-02-27T10:26:14.783+0000 I REPL     [replexec-0] transition to STARTUP2 from STARTUP
2019-02-27T10:26:14.783+0000 I REPL     [replexec-0] Starting replication storage threads
2019-02-27T10:26:14.783+0000 I REPL     [replexec-0] transition to RECOVERING from STARTUP2
2019-02-27T10:26:14.783+0000 I REPL     [replexec-0] Starting replication fetcher thread
2019-02-27T10:26:14.783+0000 I REPL     [replexec-0] Starting replication applier thread
2019-02-27T10:26:14.783+0000 I REPL     [replexec-0] Starting replication reporter thread
2019-02-27T10:26:14.784+0000 I NETWORK  [LogicalSessionCacheRefresh] Starting new replica set monitor for rs0/127.0.0.1:27017
2019-02-27T10:26:14.784+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:34490 #2 (1 connection now open)
2019-02-27T10:26:14.785+0000 I REPL     [rsSync-0] Starting oplog application
2019-02-27T10:26:14.785+0000 I REPL     [rsSync-0] transition to SECONDARY from RECOVERING
2019-02-27T10:26:14.785+0000 I REPL     [rsSync-0] conducting a dry run election to see if we could be elected. current term: 1
2019-02-27T10:26:14.785+0000 I REPL     [replexec-0] dry election run succeeded, running for election in term 2
2019-02-27T10:26:14.786+0000 I NETWORK  [conn2] received client metadata from 127.0.0.1:34490 conn2: { driver: { name: "MongoDB Internal Client", version: "4.0.6" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "18.04" } }
2019-02-27T10:26:14.786+0000 I NETWORK  [LogicalSessionCacheRefresh] Successfully connected to 127.0.0.1:27017 (1 connections now open to 127.0.0.1:27017 with a 5 second timeout)
2019-02-27T10:26:14.786+0000 I REPL     [replexec-0] election succeeded, assuming primary role in term 2
2019-02-27T10:26:14.786+0000 I REPL     [replexec-0] transition to PRIMARY from SECONDARY
2019-02-27T10:26:14.786+0000 I REPL     [replexec-0] Resetting sync source to empty, which was :27017
2019-02-27T10:26:14.786+0000 I REPL     [replexec-0] Entering primary catch-up mode.
2019-02-27T10:26:14.786+0000 I REPL     [replexec-0] Exited primary catch-up mode.
2019-02-27T10:26:14.786+0000 I REPL     [replexec-0] Stopping replication producer
2019-02-27T10:26:14.787+0000 W NETWORK  [LogicalSessionCacheRefresh] Unable to reach primary for set rs0

消息“无法为set rs0达到主要级别”表明它不起作用,而且在mongod.log文件中,我还看到查询记录了100毫秒以上,如果oplog拖尾工作正常,则不应记录该查询。

任何想法可能有什么问题吗?不同版本的MongoDB之间有什么变化吗?我已经四处寻找,但没有找到答案。

谢谢您的帮助!

0 个答案:

没有答案