mongodb副本集仲裁節點搭建


服務器准備:

主節點192.168.100.106  

從節點192.168.100.107  

仲裁節點192.168.100.108 

 

三台服務器:

關閉防火牆

service iptables stop 

chkconfig iptables off 

 

創建文件夾

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

 

上傳mongodb-linux-x86_64-3.4.6.tgz並解壓在/export/mongo目錄下

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

mv mongodb-linux-x86_64-3.4.6 mongodb

 

cd /export/mongo/log

創建mongod.log文件

 

主節點:

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=主節點IP

oplogSize=10000

noprealloc=true

 

從節點:

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

bind_ip=從節點IP

oplogSize=10000

noprealloc=true

 

仲裁節點:

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=仲裁節點IP

oplogSize=10000

noprealloc=true

 

三台服務啟動mongodb:

cd /export/mongo/mongodb/bin

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

 

主節點:

cd /export/mongo/mongodb/bin

 ./mongo 主節點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)

--查看副本集情況

rs.status()

 

測試寫入數據:
use db_test
db.tb_test01.insert( {"name":"yiibai tutorials"})
db.tb_test01.find()

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM