Construction of Mongodb3.3.6 CentOS7 Shard Experiment Environment
first, topology diagram
ii. deployment of 1.Mongodb installation
3 servers are installed MongoDB, installation package to/usr/local/, in order to clear the display, each node created a MongoDB, altogether created 4, wherein, master, slave, arbiter build replica level.
2. Create a single shard replica level
1) Create log directory logs, data directory data/db, configuration directory in each directory conf
2) write the configuration file in each conf directory mongd.conf
192.168.1.82
Master:
port=10002
dbpath=/usr/local/mongodb-3.3.6_master/data/db
Logpath=/usr/local/mongodb-3.3.6_master/logs/mongod.log
Fork=true
Logappend=true
Nohttpinterface=true
Replset=test1 #副本集名称
Pidfilepath=/var/run/mongo_master.pid
bind_ip=192.168.1.82
Slave:
port=10001
dbpath=/usr/local/mongodb-3.3.6_slave/data/db
Logpath=/usr/local/mongodb-3.3.6_slave/logs/mongod.log
Fork=true
Logappend=true
Nohttpinterface=true
Replset=test1
Pidfilepath=/var/run/mongo_slave.pid
bind_ip=192.168.1.82
Arbiter:
port=10000
dbpath=/usr/local/mongodb-3.3.6_arbiter/data/db
Logpath=/usr/local/mongodb-3.3.6_arbiter/logs/mongod.log
Fork=true
Logappend=true
Replset=test1
Nohttpinterface=true
Pidfilepath=/var/run/mongo_arbiter.pid
bind_ip=192.168.1.82
3) Start MongoDB separately
/usr/local/mongodb-3.3.6_master/bin/mongod-f. /conf/mongod.conf
/usr/local/mongodb-3.3.6_slave/bin/mongod-f. /conf/mongod.conf
/usr/local/mongodb-3.3.6_arbiter/bin/mongod-f. /conf/mongod.conf
4) Configure the replica level
Enter Master's MONGO shell
#cd/usrl/local/mongodb-3.3.6_master/bin
#./mongo192.168.1.82:10002
Switch to Admin library
>useadmin
>config={' _id ': ' test1 ', ' Members ': [{' _id ': 0, ' host ': ' 192.168.1.82:10002 ', ' priority ': 2},{' _id ': 1, ' Host ': ' 192.168.1.82:10001 ', ' priority ': 1},{' _id ': 2, ' host ': ' 192.168.1.82:10000 ', ' arbiteronly ': true}]};
Initializing replicas
>rs.initiate (config)
View cluster status
>rs.status ()
Test1:primary>rs.status ()
{
"Set": "Test1",
"Date": Isodate ("2017-01-04t06:36:07.732z"),
"MyState": 1,
"Term": Numberlong (9),
"Heartbeatintervalmillis": Numberlong (2000),
"Optimes": {
"Lastcommittedoptime": {
"TS": Timestamp (1483511762, 1),
"T": Numberlong (9)
},
"Appliedoptime": {
"TS": Timestamp (1483511762, 1),
"T": Numberlong (9)
},
"Durableoptime": {
"TS": Timestamp (1483511762, 1),
"T": Numberlong (9)
}
},
"Members": [
{
"_id": 0,
"Name": "192.168.1.82:10002",
"Health": 1,
"State": 1,
"Statestr": "PRIMARY",
"Uptime": 448,
"Optime": {
"TS": Timestamp (1483511762, 1),
"T": Numberlong (9)
},
"Optimedate": Isodate ("2017-01-04t06:36:02z"),
"Electiontime": Timestamp (1483511352, 1),
"Electiondate": Isodate ("2017-01-04t06:29:12z"),
"ConfigVersion": 3,
"Self": true
},
{