I'm migrating my app to a new server and I can't get oplog tailing to work. The idea is to set up a single replica set so there is an oplog for my Meteor app to tail. I followed the same process as on the old server where it works fine.
There is no access control on my MongoDB because it is only available locally.
Old server:
Ubuntu 16.04
MongoDB shell version v3.4.1
New server:
Ubuntu 1.04
MongoDB shell version v4.0.6
I'm using Phusion Passenger to serve a Meteor 1.6 app.
Here's how I set up the replica set:
/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
Restart MongoDB. Then in the Mongo shell:
use local
rs.initiate()
In my Passenger config:
sudo nano /etc/nginx/sites-enabled/myappname.conf
passenger_env_var MONGO_OPLOG_URL mongodb://localhost:27017/local;
And restart Nginx.
I have checked the replica set status in the Mongo shell with rs.conf():
{
"_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")
}
}
However, in the Mongo log /var/log/mongodb/mongod.log I see this:
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
The message "Unable to reach primary for set rs0" suggests it's not working, and also in the mongod.log file I'm seeing queries logged over 100ms which shouldn't happen if oplog tailing is working.
Any ideas what might be wrong? Has something changed between versions of MongoDB? I've hunted around but haven't found any answers.
Thank you for any help!