Yum instances
Vim/etc/yum.repos.d/mongodb-org-3.2.repo
[Mongodb-org-3.2]name=mongodbbaseurl=http://repo.mongodb.org/yum/redhat/6server/mongodb-org/3.2/x86_64/gpgcheck=0enabled=1
Then yum-y install MongoDB
Quick Start Script
#!/bin/bashinstance=$1action=$2case "$action" in ' Start ') mongod-f/etc/$instance. cnf ;; ' Stop ') mongod-f/etc/$instance. cnf--shutdown ;; ' Restart ') mongod-f/etc/$instance. CNF--shutdown mongod-f/etc/$instance. CNF ; Esac# of course, the configuration file should be placed under/etc/ by:v
Configuration file Instance
Dbpath=/data/mongodata2fork=trueport=27019logpath=/data/log/mongolog2/mongodb1.logauth=truekeyfile =/data/ Mongo22.keyreplset = Qby
The ID should be the same as the one set in Replset. and CONFIG_REPL the name can be arbitrarily named, equivalent to the copy set of the conference room. Members of the meeting room.
> config_repl={_id: ' gechongrepl ', members:[... {_id:0,host: ' 192.168.91.128:27017 ', priority:10},... {_id:1,host: ' 192.168.91.129:27017 ', priority:9},... {_id:2,host: ' 192.168.91.130:27017 ', Priority:9}]}
The following 2 steps can be implemented for adding and deleting nodes.
... {_id:1,host: ' 192.168.91.129:27017 ', Priority:9},]}
>rs.reconfig (CONFIG_REPL) #相当于重新加载了配置, where you can delete nodes or add nodes.
>rs.status () #然后查看状态
There is also a rs.add ("127.0.0.1:27020") or Rs.remove (). Which one to use specifically. Differentiate themselves.
============ next look at the master-slave. The master-slave behind the 3.X has a security policy. Of course to turn on user authentication, otherwise what is the point? So you have to open the key option here for the main configuration file
Master
Dbpath=/data/mongodatafork=trueport=27017logpath=/data/log/mongolog/mongodb1.logauth=truemaster=truekeyfile =/ Data/mongo.key
Slave
Auth=truedbpath=/data/mongodatalogpath=/data/log/mongolog/mongo1.logfork=trueport=27017slave=true # Set to slavesource=172.16.38.178:27017 #指定Master在哪keyFile =/data/mongo.key
Of course, there must be a user authentication. Some people will wonder which user to use for data validation and synchronization. Master will record the operation in Local. Oplog, and then periodically get Oplog content from the server. Executed on the slave.
MongoDB3.2.6 replica set and master-slave