Posts

Showing posts with the label high availability

MongoDB tip: issue with specifying localhost in replica set configuration

Often time when we want to quickly spin up a demo mongodb replica set, we would simply use the localhost:port to specify the nodes assuming all members are on the same server. Here is an quick example why that's not a good practice Here is the output of my current rs.status() MongoDB Enterprise biDemo:PRIMARY> conf= rs.conf() {         "_id" : "biDemo",         "version" : 5,         "protocolVersion" : NumberLong(1),         "members" : [                 {                         "_id" : 0,                         "host" : "localhost:31111",                         "arbiterOnly" : false,                         "b...

MongoDB tip: MongoDB 3.4, creating replica set using config file

In my previous post,  MongoDB tip: MongoDB 3.4, adding replica set members, issue/resolution , we created the replica set using rs.add(), in this post, I am going to use the config file option to achieve the same result. First, let's spin up 3 mongod instances. This can be done in single servers or multiple servers, doesn't really matter, as long as for multiple servers, they can resolve the IP/hostname and communicate with one another. I edited the /etc/hosts to make sure the hostname can be resolved 127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain 10.155.208.169  demo2.net demo2 10.155.228.75   demo3.net demo3 10.155.208.207  demo1.net demo1 To validate, same ping from one of the servers to the other two by, assuming from demo3 ping demo1 ping demo2 On all servers, start the mongod process as # assign ownership of /data/demo to user mongod chown -R mongod. /data/demo # this starts mongod process as user mongo...