I’ve done the .conf files + launched the primary daemon and got connected with the shell to it.
Used
rs.initiate()
It worked, but gave me this “warning”:
MongoDB Enterprise > rs.initiate()
{
"info2" : “no configuration specified. Using a default configuration for the set”,
“me” : “192.168.103.100:27001”,
“ok” : 1
}
1st question: What does info2 refers to?
After this, I made the root user and it said OTHER rather than PRIMARY as shown on the next lines:
MongoDB Enterprise m103-repl:OTHER> db.createUser({user:“m103-admin”,pwd:“m103-
pass”,roles:[{role:“root”,db:“admin”}]})
Successfully added user: {
“user” : “m103-admin”,
“roles” : [
{
“role” : “root”,
“db” : “admin”
}
]
}
But after creating the user, then it changed to PRIMARY:
MongoDB Enterprise m103-repl:PRIMARY> exit
bye
Then I reconnected to the primary this way and it allowed me to get connected. I did it by mistake but I noticed how it allowed the connection:
vagrant@m103:/var/mongodb/db$ mongo --host localhost:27001
MongoDB shell version v3.6.17
connecting to: mongodb://localhost:27001/?gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“d9cc2c07-818f-463e-b20d-adb4340261f9”) }
MongoDB server version: 3.6.17
MongoDB Enterprise m103-repl:PRIMARY>
2nd question: Why does it allows to get connected with no credentials?
Then, I got connected with the credentials as shown:
MongoDB Enterprise m103-repl:PRIMARY> exit
bye
vagrant@m103:/var/mongodb/db$ mongo --host localhost:27001 -u m103-admin -p m103-pass
MongoDB shell version v3.6.17
connecting to: mongodb://localhost:27001/?gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“8b644c9a-fb45-4176-b266-ded41e04fbcd”) }
MongoDB server version: 3.6.17
Server has startup warnings:
2020-03-27T15:47:09.516+0000 I STORAGE [initandlisten]
2020-03-27T15:47:09.516+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem
is strongly recommended with the WiredTiger storage engine
2020-03-27T15:47:09.516+0000 I STORAGE [initandlisten] ** See
http://dochub.mongodb.org/core/prodnotes-filesystem
2020-03-27T15:47:09.969+0000 I CONTROL [initandlisten]
2020-03-27T15:47:09.969+0000 I CONTROL [initandlisten] ** WARNING:
/sys/kernel/mm/transparent_hugepage/enabled is ‘always’.
2020-03-27T15:47:09.969+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2020-03-27T15:47:09.969+0000 I CONTROL [initandlisten]
2020-03-27T15:47:09.969+0000 I CONTROL [initandlisten] ** WARNING:
/sys/kernel/mm/transparent_hugepage/defrag is ‘always’.
2020-03-27T15:47:09.969+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2020-03-27T15:47:09.969+0000 I CONTROL [initandlisten]
MongoDB Enterprise m103-repl:PRIMARY>
But I noticed that I missed the replica set’s name in the connection and the authenticationDatabase info.
3rd question Do I need to have the replica set’s name and the authenticationDatabase on or it is just a recommendation to make sure that it gets connected where I want to?
When I try to connect to the other nodes, I get this message:
MongoDB Enterprise m103-repl:PRIMARY> rs.add(“m103-repl/192.168.103.100:27002”)
{
“ok” : 0,
"errmsg" : “Quorum check failed because not enough voting nodes responded; required 2 but only
the following 1 voting nodes responded: 192.168.103.100:27001; the following nodes did not
respond affirmatively: m103-repl/192.168.103.100 failed with HostUnreachable”,
“code” : 74,
“codeName” : “NodeNotFound”,
“operationTime” : Timestamp(1585326426, 1),
“$clusterTime” : {
“clusterTime” : Timestamp(1585326426, 1),
“signature” : {
“hash” : BinData(0,“eo759/PLTUwz7dSaGmSzM3+Gh7A=”),
“keyId” : NumberLong(“6808918753653293057”)
}
}
}
I’ve checked the post of this issue in the forum and found that I do have the file /etc/hosts issue. (3rd point in the post). Here is my file:
vagrant@m103:~$ cat /etc/hosts
127.0.1.1 m103.mongodb.university m103
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
192.168.103.100 m103 m103
I’ve tried to modify it with VI or PICO; but in both cases, it states that this is a read only file.
4th question How can I modify the first IP to be able to connect with 192.168.103.100?
Thank you