Description
This is the command line for the mongod:
/home/lamp/.local/bin/mongod --dbpath /home/lamp/rocket.chat/mongodb --replSet rs01 --bind_ip "" --unixSocketPrefix /home/lamp/rocket.chat/mongodb --pidfilepath /home/lamp/rocket.chat/mongodb/mongod.pid &>> /home/lamp/rocket.chat/mongodb/mongod.log
I tried a freshly created database. After the initial creation I logged in to mongo shell with mongod --host "/home/lamp/rocket.chat/mongodb/mongo-27017.sock"
and ran rs.initiate({_id:"rs01",version:1,members:[{_id:0,host:"/home/lamp/rocket.chat/mongodb/mongodb-27017.sock"}]})
.
Now here’s the issue. With these environment variables…
MONGO_URL: "mongodb:///home/lamp/rocket.chat/mongodb/mongodb-27017.sock:27017/rocketchat?replicaSet=rs01",
MONGO_OPLOG_URL: "mongodb:///home/lamp/rocket.chat/mongodb/mongodb-27017.sock:27017/local?replicaSet=rs01",
I get the following error:
0|Rocket.Chat | { MongoParseError: No hostname or hostnames provided in connection string
0|Rocket.Chat | at parseConnectionString (/home/lamp/rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/uri_parser.js:308:21)
0|Rocket.Chat | at connect (/home/lamp/rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/operations/mongo_client_ops.js:180:3)
0|Rocket.Chat | at connectOp (/home/lamp/rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/operations/mongo_client_ops.js:284:3)
0|Rocket.Chat | at executeOperation (/home/lamp/rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/utils.js:420:24)
0|Rocket.Chat | at MongoClient.connect (/home/lamp/rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/mongo_client.js:168:10)
0|Rocket.Chat | at Function.MongoClient.connect (/home/lamp/rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/mongo_client.js:372:22)
0|Rocket.Chat | at new MongoConnection (packages/mongo/mongo_driver.js:177:11)
0|Rocket.Chat | at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16)
0|Rocket.Chat | at Object.<anonymous> (packages/mongo/remote_collection_driver.js:38:10)
0|Rocket.Chat | at Object.defaultRemoteCollectionDriver (packages/underscore.js:784:19)
0|Rocket.Chat | at new Collection (packages/mongo/collection.js:97:40)
0|Rocket.Chat | at new AccountsCommon (packages/accounts-base/accounts_common.js:23:18)
0|Rocket.Chat | at new AccountsServer (packages/accounts-base/accounts_server.js:23:5)
0|Rocket.Chat | at server_main.js (packages/accounts-base/server_main.js:7:12)
0|Rocket.Chat | at fileEvaluate (packages/modules-runtime.js:336:7)
0|Rocket.Chat | at Module.require (packages/modules-runtime.js:238:14)
0|Rocket.Chat | name: 'MongoParseError',
0|Rocket.Chat | [Symbol(mongoErrorContextSymbol)]: {} }
And with these environment variables:
MONGO_URL: "mongodb://%2Fhome%2Flamp%2Frocket.chat%2Fmongodb%2Fmongodb-27017.sock:27017/rocketchat?replicaSet=rs01",
MONGO_OPLOG_URL: "mongodb://%2Fhome%2Flamp%2Frocket.chat%2Fmongodb%2Fmongodb-27017.sock:27017/local?replicaSet=rs01",
I get this error:
0|Rocket.Chat | { MongoError: no primary found in replicaset or invalid replica set name
0|Rocket.Chat | at /home/lamp/rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/topologies/replset.js:636:11
0|Rocket.Chat | at Server.<anonymous> (/home/lamp/rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/topologies/replset.js:357:9)
0|Rocket.Chat | at Object.onceWrapper (events.js:315:30)
0|Rocket.Chat | at emitOne (events.js:116:13)
0|Rocket.Chat | at Server.emit (events.js:211:7)
0|Rocket.Chat | at /home/lamp/rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/topologies/server.js:508:16
0|Rocket.Chat | at /home/lamp/rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/pool.js:532:18
0|Rocket.Chat | at _combinedTickCallback (internal/process/next_tick.js:132:7)
0|Rocket.Chat | at process._tickCallback (internal/process/next_tick.js:181:9) name: 'MongoError', [Symbol(mongoErrorContextSymbol)]: {} }
I tried with and without the port number but no difference. And this worked fine with TCP hostname. How do I connect Rocket.Chat to MongoDB via Unix socket???
Server Setup Information
- Version of Rocket.Chat Server: 1.3.2
- Operating System: Ubuntu 18.04
- Deployment Method: PM2 for Rocket.Chat, crontab/nohup for mongod
- Number of Running Instances: 1
- DB Replicaset Oplog: wat
- NodeJS Version: 8.16.1
- MongoDB Version: 4.2.0
- Proxy: not using gateway yet
- Firewalls involved: none