1. Primary server Configuration #auth = True DBPath =/data/mongodb/db LogPath =/data/mongodb/log/mongodb.log Port = 27017 Fork = True #以 Daemon is enabled, that is, running in the background Nohttpinterface = True Logappend=true master=true 2, configuration from server #auth = True DBPath =/data/mongodb/ DB LogPath =/data/mongodb/log/mongodb.log Port = 27017 Fork = True #以守护程序的方式启用, which is run in the background Nohttpinterface = True Logappe Nd=true slave=true source=101.101.101.190 3, start
4. Master-slave Safety
This master-slave security in the MongoDB official website said very clearly. cannot be verified with normal Mongod permissions. In addition to the need to join-auth also need to add-keyfile validation. First, we generate our keyfile, according to the official website to provide the instructions, this keyfile can be arbitrary content, as long as all the machines in the cluster have the same files. In the Linux environment, we generated our keyfile through the command of OpenSSL rand-base64 741 >/opt/mongodb/bin/mongo-keyfile. After the build, you can specify it when you start Mongod. In the master-slave configuration file, add the following configuration 1, open auth 2, add keyfile keyfile =/opt/mongodb/bin/mongo-keyfile 5, Problems encountered permissions on/opt/mongodb/bin/m Ongo-keyfile is too open modify chmod 400/opt/mongodb/bin/mongo-keyfile
MongoDB master-Slave and auth master-slave configuration detailed