Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

Mongo db 001-rs:SECONDARY instead of 001-rs:PRIMARY

Open phillip-white-sociomantic opened this issue 11 years ago • 7 comments

Hi All,

I have seen a possible issue when trying to initiate mongo:

root@rchat:~# nano /etc/mongod.conf
root@rchat:~# service mongod restart
mongod stop/waiting
mongod start/running, process 10436
root@rchat:~# mongo
MongoDB shell version: 3.0.7
connecting to: test
Server has startup warnings: 
2015-11-03T16:28:23.420+0100 I CONTROL  [initandlisten] 
2015-11-03T16:28:23.420+0100 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-11-03T16:28:23.420+0100 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-11-03T16:28:23.420+0100 I CONTROL  [initandlisten] 
2015-11-03T16:28:23.420+0100 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-11-03T16:28:23.420+0100 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-11-03T16:28:23.420+0100 I CONTROL  [initandlisten] 
> rs.initiate()
{
    "info2" : "no configuration explicitly specified -- making one",
    "me" : "rchat:27017",
    "ok" : 1
}
001-rs:SECONDARY>

I am running Mongodb-org 3.0.7. And this to /etc/mongod.conf

replication:
      replSetName:  "001-rs"

Will i have any issues if i continue the install with 001-rs:SECONDARY?

Just running through the install, I have come to this error:

root@rchat:/var/www/rocket.chat/bundle# pm2 start pm2-rocket-chat.json

/usr/lib/node_modules/pm2/lib/CLI.js:2305
    if(util.isObject(app.env[key])) {
            ^
TypeError: Object #<Object> has no method 'isObject'
    at mergeEnvironmentVariables (/usr/lib/node_modules/pm2/lib/CLI.js:2305:13)
    at /usr/lib/node_modules/pm2/lib/CLI.js:337:7
    at /usr/lib/node_modules/pm2/node_modules/async/lib/async.js:181:20
    at replenish (/usr/lib/node_modules/pm2/node_modules/async/lib/async.js:319:21)
    at /usr/lib/node_modules/pm2/node_modules/async/lib/async.js:330:15
    at Object.async.forEachLimit.async.eachLimit (/usr/lib/node_modules/pm2/node_modules/async/lib/async.js:220:35)
    at startApps (/usr/lib/node_modules/pm2/lib/CLI.js:323:11)
    at /usr/lib/node_modules/pm2/lib/CLI.js:423:14
    at /usr/lib/node_modules/pm2/node_modules/async/lib/async.js:52:16
    at replenish (/usr/lib/node_modules/pm2/node_modules/async/lib/async.js:314:29)

I have been following the guide here https://github.com/RocketChat/Rocket.Chat/wiki/Deploy-Rocket.Chat-without-docker

Same error when trying to start # pm2 start pm2-rocket-chat.json

ghost avatar Nov 03 '15 16:11 ghost

I managed to get this working by having localhost in /etc/mongod.conf

net:
  port: 27017
  bindIp: localhost

then, on the mongo command line. run rs.initiate() twice. It will be SECONDARY first, then it will be PRIMARY which indicates no errors.

After doing that, pm2 start pm2-rocket-chat.json seemed to work fine.

@phillip-white-sociomantic I don't get mongo even to run image

ghost avatar Nov 06 '15 15:11 ghost

@phillip-white-sociomantic

Does this link help: https://gist.github.com/leefaus/fd55eee32f1dc5918220

leefaus avatar Nov 06 '15 15:11 leefaus

@stephenreda Have you set this in /etc/mongod.conf. And do you have the hosts file setup correctly?

replication:
      replSetName:  "001-rs"

After i fixed up the hosts file to be:

127.0.0.1 localhost rchat

And i set:

net:
  port: 27017
  bindIp: localhost

in /etc/mongod.conf. Restarted mongo and it worked.

@leefaus I managed to solve it with the above setup. So not sure if the link works or not.

@phillip-white-sociomantic Thanx, I have solved it. For people also having this issue, check the mongoDB log:

tail /var/log/mongodb/mongod.log

2015-11-07T11:12:25.427+0100 I CONTROL  ***** SERVER RESTARTED *****
2015-11-07T11:12:25.446+0100 E NETWORK  [initandlisten] Failed to unlink socket file      /tmp/mongodb-27017.sock errno:1 Operation not permitted
2015-11-07T11:12:25.446+0100 I -        [initandlisten] Fatal Assertion 28578
2015-11-07T11:12:25.446+0100 I -        [initandlisten] 

I had to manually delete the .sock file

rm /tmp/mongodb-****.sock

After this, I restarted mongo

service mongod start

The mongoDB log now shows it is waiting for an incoming connection, which is what we want! (/var/log/mongodb/mongod.log)

2015-11-07T11:15:21.934+0100 I NETWORK  [initandlisten] waiting for connections on port 27017

ghost avatar Nov 07 '15 10:11 ghost