MongoDB Series (ii): MongoDB replica set
Mongodb2.6 replica set validation deployment and certification
Replica sets have the following characteristics:
1. The minimum composition is: Primary,secondary,arbiter, General deployment is: primary,2 secondary.
2. The number of members should be odd, and if the addition of arbiter,arbiter for even cases does not save data, only votes.
3. Max members, but only 7 voting members, others are non-voting members.
Note: When configuring the MONGO replica set, you cannot add a login authorization user first, but you can modify the port number first.
Modify the configuration file/etc/mongo.conf for each machine to increase the replica set name
#replSet =Setnamereplset=wangyunpeng
And then re-start every MONGO service.
Service Mongod Stop
Service Mongod Start
At this point through the Mongovue tool access to each of the MONGO server inside the collection, will prompt:cannot currently read from the This replset * * * * * * * * * * error.
Log on to the MongoDB database on one of the data nodes
127.0. 0.1:27017/admin
Specifies the name of the replica set Wangyunpeng and data node, moderator
View machine information after a successful
Arbitrator's information
Configure to start user authentication after playing the replica set, need to configure two users, one is the system user, and one is the database administrator user. When the configuration is complete, the configuration information is synchronized to the other nodes.
After the user authentication is configured, the replica set is stopped and the password file is generated with OpenSSL first.
OpenSSL rand-base64 741 > Mongodb-keyfile
Give permission 600, the file can be called
chmod mongodb-keyfile
Save the file, modify the owner and all the groups,
Chown-r mongod:mongod mongodb-keyfile
Then in the node configuration file join start calling the Authentication file parameter vim/etc/mongo.conf, such as:
KeyFile =/data/mongo/mongodb-keyfile
The mongodb-keyfile is then copied to each slave machine, and then the copy is started, and only the nodes that are authenticated by the password file can join. Database operations also require password authentication, which greatly improves security.
cd/data/mongo/741 > mongodb- mongodb--R mongod:mongod mongodb- /etc/mongo.confkeyfile=/data/mongo/mongodb-keyfile
This will not have to modify the/etc/mongo.conf file Nuauth=false and auth=true can also be done, the modification is not wrong.
MongoDB 2.6 Configuration Replica set, support port number modification and user login authentication