mongodb arbitration node to build a replica set

Server preparation:

The master node 192.168.100.106  

From node 192.168.100.107  

Arbitration node 192.168.100.108 

 

Three servers:

Turn off the firewall

service iptables stop 

chkconfig iptables off 

 

Create a folder

mkdir -p /export/mongo/data/db

mkdir -p /export/mongo/log

mkdir -p /export/mongo/key

mkdir -p /export/mongo/run

mkdir -p /export/mongo/conf

 

Upload mongodb-linux-x86_64-3.4.6.tgz and decompressed at / export / mongo directory

tar -zxvf mongodb-linux-x86_64-3.4.6.tgz

mv mongodb-linux-x86_64-3.4.6 mongodb

 

cd /export/mongo/log

Creating mongod.log file

 

The master node:

vim /export/mongo/conf/mongo.conf

port =28007

fork =true

dbpath =/export/mongo/data/db

logpath =/export/mongo/log/mongod.log

pidfilepath=/export/mongo/run/28007.pid

logappend =true

shardsvr =true

replSet =shard1

bind_ip = master node IP

oplogSize=10000

noprealloc=true

 

From node:

vim /export/mongo/conf/mongo.conf

port =28008

fork =true

dbpath =/export/mongo/data/db

logpath =/export/mongo/log/mongod.log

pidfilepath=/export/mongo/run/28008.pid

logappend =true

shardsvr =true

replSet =shard1

from IP node bind_ip =

oplogSize=10000

noprealloc=true

 

Arbitration node:

vim /export/mongo/conf/mongo.conf

port =28009

fork =true

dbpath =/export/mongo/data/db

logpath =/export/mongo/log/mongod.log

pidfilepath=/export/mongo/run/28009.pid

logappend =true

shardsvr =true

replSet =shard1

bind_ip = arbitration node IP

oplogSize=10000

noprealloc=true

 

Three service starts mongodb:

cd /export/mongo/mongodb/bin

./mongod -f /export/mongo/conf/mongo.conf

 

The master node:

cd /export/mongo/mongodb/bin

 ./mongo master node IP : 28007

 

use admin

config={_id:'shard1',members:[{_id:0,host:'118.1.2.81:28007'},{_id:1,host:'118.1.2.82:28008'},{_id:2,host:'118.1.2.74:28009', arbiterOnly:true}]}

rs.initiate(config)

- view a copy of the case set

rs.status()

 

测试写入数据:
use db_test
db.tb_test01.insert( {"name":"yiibai tutorials"})
db.tb_test01.find()

 

Guess you like

Origin www.cnblogs.com/chong-zuo3322/p/11958857.html