preparatory work
Software Environment
Os:oracle Linux 6.5
mongodb:mongodb3.2.3
Deploy schema
Analog has three servers
10.1.5.123:28001 Master Node
10.1.5.123:28002 from Node
10.1.5.123:28003 election node
Replica set Schema: one master, one from, one election node
Download Installation
Download Address: Https://www.mongodb.org/downloads
Mongodb-linux-x86_64-rhel62-3.2.3.tgz
Deployment Steps 1. Create Directories and Users
[Root@devtest mongodb]# mkdir conf data log
[Root@devtest data]# mkdir 28001 28002 28003
--Create MONGO user
[Root@devtest conf]# Groupadd Mongod
[Root@devtest conf]# useradd-g Mongod Mongod
2. Create a configuration file
--Configure three instance configuration files (modify the corresponding port number)
--Node 1
$ vi/home/mongod/mongodb3.2.3/conf/28001.conf
port=28001
Bind_ip=10.1.5.123
Logpath=/home/mongod/mongodb3.2.3/log/28001.log
dbpath=/home/mongod/mongodb3.2.3/data/28001/
Logappend=true
Pidfilepath=/home/mongod/mongodb3.2.3/data/28001/28001.pid
Fork=true
oplogsize=1024
Replset=mymongo
--Node 2
$ vi/home/mongod/mongodb3.2.3/conf/28002.conf
port=28002
Bind_ip=10.1.5.123
Logpath=/home/mongod/mongodb3.2.3/log/28002.log
dbpath=/home/mongod/mongodb3.2.3/data/28002/
Logappend=true
Pidfilepath=/home/mongod/mongodb3.2.3/data/28002/28002.pid
Fork=true
oplogsize=1024
Replset=mymongo
--Node 3
$ vi/home/mongod/mongodb3.2.3/conf/28003.conf
port=28003
Bind_ip=10.1.5.123
Logpath=/home/mongod/mongodb3.2.3/log/28003.log
dbpath=/home/mongod/mongodb3.2.3/data/28003/
Logappend=true
Pidfilepath=/home/mongod/mongodb3.2.3/data/28003/28003.pid
Fork=true
oplogsize=1024
Replset=mymongo
3. Start MONGO replication set
$ mongod-f/home/mongod/mongodb3.2.3/conf/28001.conf
$ mongod-f/home/mongod/mongodb3.2.3/conf/28002.conf
$ mongod-f/home/mongod/mongodb3.2.3/conf/28003.conf
4. Initializing the replica set
[Mongod@devtest ~]$ MONGO 10.1.5.123:28001/admin
MongoDB Shell version:3.2.3
Connecting To:10.1.5.123:28001/admin
Welcome to the MongoDB shell.
For interactive help, type ' help '.
For more comprehensive documentation
http://docs.mongodb.org/
Questions? Try the Support group
Http://groups.google.com/group/mongodb-user
> DB
Admin
> config = {
... "_id": "Mymongo",
... members:[
... {"_id": 0,host: "10.1.5.123:28001"},
... {"_id": 1,host: "10.1.5.123:28002"},
... {"_id": 2,host: "10.1.5.123:28003"}]
... }
{
"id": "Mymongo",
"Members": [
{
"_id": 0,
"Host": "10.1.5.123:28001"
},
{
"_id": 1,
"Host": "10.1.5.123:28002"
},
{
"_id": 2,
"Host": "10.1.5.123:28003"
}
]
}
--View Replica set members
> config.members
[
{
"_id": 0,
"Host": "10.1.5.123:28001"
},
{
"_id": 1,
"Host": "10.1.5.123:28002"
},
{
&nb