Chapter 2 Replication Lab Deploy a Replica Set

storage:
dbPath: /var/mongodb/db/1
net:
bindIp: localhost
port: 27001
security:
authorization: enabled
keyFile: /var/mongodb/pki/m103-keyfile
systemLog:
destination: file
path: /var/mongodb/logs/mongod2.log
logAppend: true
processManagement:
fork: true
replication:
replSetName: m103-repl

Commands used ::

mkdir -p /var/mongodb/pki/
openssl rand -base64 741 > /var/mongodb/pki/m103-keyfile
chmod 400 /var/mongodb/pki/m103-keyfile

mkdir -p /var/mongodb/db/1
mongod -f mongod_1.conf
mkdir -p /var/mongodb/db/2
mongod -f mongod_2.conf
mkdir -p /var/mongodb/db/3
mongod -f mongod_3.conf

mongo --port 27001

rs.initiate()

db.createUser({
user: “m103-admin”,
pwd: “m103-pass”,
roles: [
{role: “root”, db: “admin”}
]
})

exit
mongo --host “m103-repl/localhost:27011” -u “m103-admin” -p “m103-pass” --authenticationDatabase “admin”

rs.status()

rs.add(“m103:27002”)
rs.add(“m103:27003”)

When tried to add above 2 commands i am getting error like this.

Try to add it as localhost.In the config file your host is localhost but you are trying to add it as m103

1 Like

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