Questions about MongoDB replica set

Hello Mate,
I am fairly new to graylog but I have to manage to set up. But my issue is creating the MongoDB replicate set and Use a replica set instead of a single host.I have followed tons of documentation but still not manage to have it working. Below are the steps I used in creating the

on server A and B

sudo apt-get install mongodb-server

#mongo
replSet = "rs01"
use graylog
db.createUser(
{
user: “gray”,
pwd: “ubuntu”,
roles: [ “readWrite”, “dbAdmin” ]
}
)

nano /etc/graylog/server/server.conf
mongodb_uri = mongodb://gray:ubuntu@serverA:27017,ServerB:27017/graylog?replicaSet=rs01

Please Help me

You do not need to define replicaSet in the mongodb_uri. Just log in normally.

When setting up a replica set, first set up one node. Then start mongo command prompt in the node and command the other node to join in the replica set by rs.add(“serverB:27017”). The user accounts etc. are automatically added in the second node. After adding the node, you can check the status of the replica set by rs.status()

Thanks @jtkarvo

I manage to figure out how it is done.

on Primary Server.

1 set ur /etc/ hosts set to hosts for all the servers.
2 on the primary set ur replica set and bind it nano /etc/mongodb.conf

bind_ip = hostip

port = 27017
replSet = rs0

3 terminal
#mongo
replSet = "rs0"
rs.initiate()
rs.status()

on the Secondary server

1 set ur /etc/ hosts set to hosts for all the servers.
2 on the Secondary Server set ur replica set and bind it nano /etc/mongodb.conf
bind_ip = hostip
port = 27017
replSet = rs0

#service mongodb restart

on server A

mongo (hostip)

rs.add(‘secondary SERVER ip:27017’)

rs0:PRIMARY>

ON SECONDARY
#mongo (hostip)

rs0:SECONDARY>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.