OPLog Option with external DB Server and Auth in Mongodb
Your Rocket.Chat version: 0.49.3
(Reopens #5637)
HI @engelgabriel,
i just added the Environment="MONGO_OPLOG_URL=mongodb://USERNAME:PASSWORD@SERVER:27017/admin?replicaSet=001-rs" to the systemd file. The problem here is that we're using seperate server for DB and rocket chat. We secured the DB to only accept connections from authorized users. Therefor i tried to create a user for the local db but mongodb does not accept creating users in the local db. As suggested by stack overflow i created a user in the admin DB with readWrite permissions on the localdb. https://docs.mongodb.com/manual/reference/method/db.createUser/#local-database
local Database
You cannot create users on the local database.
The problem now is that rocket chat still telling me that oplog is disabled. Furthermore it telling me that we're running two instances but actually it is only one.
Can you help me out in configuring the connection string?
Kind regards, Marvyn
How many instances Rocket.Chat says that are running on the Admin -> Info page?
@rodrigok can we improve the message to explain that:
OpLog is not enabled on MongoDB or MONGO_OPLOG_URL environment variable is not configured correctly on the application server.
@engelgabriel the current message is:
Error: OpLog (ReplicaSet) should be enabled when running multiple instances
What about this one?
Error: OpLog (ReplicaSet) should be enabled and MONGO_OPLOG_URL environment variable should be set and correctly configured when running multiple instances
Error: Rocket.Chat requires oplog tailing when running in multiple instances. Please make sure your MongoDB is on ReplicaSet mode and MONGO_OPLOG_URL environment variable is defined correctly on the application server.
HI @engelgabriel
rocket chat is telling me that two instances are running. Btw: i got this exception
Jan 20 08:48:08 vchat1 node[897]: Error: $MONGO_OPLOG_URL must be set to the 'local' database of a Mongo replica set
Jan 20 08:48:08 vchat1 node[897]: at Error (native)
Jan 20 08:48:08 vchat1 node[897]: at OplogHandle._startTailing (meteor://💻app/packages/mongo/oplog_tailing.js:185:13)
Jan 20 08:48:08 vchat1 node[897]: at new OplogHandle (meteor://💻app/packages/mongo/oplog_tailing.js:76:8)
Jan 20 08:48:08 vchat1 node[897]: at new MongoConnection (meteor://💻app/packages/mongo/mongo_driver.js:222:25)
Jan 20 08:48:08 vchat1 node[897]: at new MongoInternals.RemoteCollectionDriver (meteor://💻app/packages/mongo/remote_collection_driver.js:4:16)
Jan 20 08:48:08 vchat1 node[897]: at Object.<anonymous> (meteor://💻app/packages/mongo/remote_collection_driver.js:38:10)
Jan 20 08:48:08 vchat1 node[897]: at Object.defaultRemoteCollectionDriver (packages/underscore.js:784:19)
Jan 20 08:48:08 vchat1 node[897]: at new Mongo.Collection (meteor://💻app/packages/mongo/collection.js:103:40)
Jan 20 08:48:08 vchat1 node[897]: at AccountsServer.AccountsCommon (meteor://💻app/packages/accounts-base/accounts_common.js:23:18)
Jan 20 08:48:08 vchat1 node[897]: at new AccountsServer (meteor://💻app/packages/accounts-base/accounts_server.js:18:5)
Which is fine for me. So iam not able to configure oplog with my conditions? (external db with auth only)
@hExPY You should point your MONGO_OPLOG_URL to your local database and not to admin database.
Please try this:
MONGO_OPLOG_URL=mongodb://USERNAME:PASSWORD@SERVER:27017/local?replicaSet=001-rs
Let me now if it works
@rodrigok Since I have upgraded to 0.49.3 I'm trying to make sure this is correct. I have a replica set of rs0. Would my environment be MONGO-OPLOG_URL=mongodb://server:27017/rocketchat?replicaSet=rs0 I asked because if I use the above env. I get the following messages from the mongo log. 2017-01-20T13:25:05.255-0700 I NETWORK [conn282430] end connection 130.57.1.50:29380 (24 connections now open) 2017-01-20T13:25:08.591-0700 I NETWORK [initandlisten] connection accepted from 130.57.1.50:29414 #282431 (25 connections now open)
Over and over again.
@drickerusa Your MONGO_URL should point to your db including credentials and replicaset info.
Your MONGO_OPLOG_URL MUST point to db local including credentials and replicaset info.
@drickerusa please read https://github.com/meteor/docs/blob/master/long-form/oplog-observe-driver.md#oplogobservedriver-in-production
@hExPY I guess you have the info now to configure MONGO_OPLOG_URL correctly.
Please reopen the issue if you still have problems.
Hi @engelgabriel,
now it works like a charm. Thanks for referencing the meteor documentation this helps me out.
Adding ?authSource=admin fixed the problem!
Thank you very much!
which systemd file did you add that into ?
i just added the Environment="MONGO_OPLOG_URL=mongodb://USERNAME:PASSWORD@SERVER:27017/admin?replicaSet=001-rs"
Hi @asifkh11 i created an own one:
server:~# cat /lib/systemd/system/rocketchat.service
[Unit]
Description=Rocket Chat Chat Server
Documentation=https://rocket.chat/docs
After=network.target
[Service]
Environment="PORT=9999"
Environment="ROOT_URL=http://<SERVER>:<PORT>"
Environment="MONGO_URL=mongodb://<MONGO_USER>:<MONGO_PW>@<MONGO_Server>:27017/rocketchat"
Environment="MONGO_OPLOG_URL=mongodb://<MONGO_USER>:<MONGO_PW>@<MONGO_Server>:27017/local?authSource=admin&replicaSet=001-rs"
User=root
Restart=always
StandardOutput=syslog
StandardError=syslog
ExecStart=/opt/rocket.chat/node/bin/node /opt/rocket.chat/rocket.chat/main.js
Hi i'm setting the MONGOURL in the forever service to read the data from secondary mongo server export MONGO_URL=mongodb://10.xx.xx.xxx:27017,10.xx.xx.xxx:27017/Chat?replicaSet=rs1&readPreference=nearest not working for me..help needed
@hExPY I try to connect rocketchat to remote mongodb server but the error show that,
MongoError: no primary found in replicaset or invalid replica set name
However there is a primary in the replicaset? Can you help with that?