資源描述:
《centos下搭建mongodb集群》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫。
1、centos下搭建mongodb集群mongodbcentos?安裝前先同步服務(wù)器時(shí)間:?a.yuminstallntp?b.ntpdate210.72.145.44?配置總覽:?3個(gè)分片sharding?每一個(gè)分片由3個(gè)節(jié)點(diǎn)構(gòu)成1主2備的ReplicaSets?3個(gè)配置節(jié)點(diǎn)Configsever?1個(gè)路由節(jié)點(diǎn)Mongos?步驟:?首先安裝mongodb:將其解壓到/usr,再重命名為mongodb,路徑為/usr/mongodb1.創(chuàng)建分片:?serverA:?mkdir-p/data/a/r0?mkdir-p/data/b/r0?mkdir-p/
2、data/c/r0?mkdir-p/data/logs/a?mkdir-p/data/logs/b?mkdir-p/data/logs/c?mkdir-p/data/configServer/r0?mkdir-p/data/logs/configServer?mkdir-p/data/logs/serverlogs?./mongod--logpath/data/logs/a/r0.log--logappend--dbpath/data/a/r0--port10000--shardsvr--replSetsetA--rest?--oplogSize64
3、--fork?serverBserverC?執(zhí)行同上命令。?2.初始化復(fù)制集setA:?./mongo192.168.1.115:10000/admin?config={_id:'setA',members:[{_id:0,host:'192.168.1.115:10000'},{_id:1,host:'192.168.1.116:10000'},{_id:2,host:'192.168.1.117:10000'}]}?rs.initiate(config);?3.初始化復(fù)制集setB:?./mongod--logpath/data/logs/b/r
4、0.log--logappend--dbpath/data/b/r0--port20000--shardsvr--replSetsetB--rest?--oplogSize64--fork?./mongo192.168.1.116:20000/admin?config={_id:'setB',members:[{_id:0,host:'192.168.1.115:20000'},{_id:1,host:'192.168.1.116:20000'},{_id:2,host:'192.168.1.117:20000'}]}?rs.initiate(con
5、fig);?4.初始化復(fù)制集setC:?./mongod--logpath/data/logs/c/r0.log--logappend--dbpath/data/c/r0--port30000--shardsvr--replSetsetC--rest?--oplogSize64--fork?./mongo192.168.1.117:30000/admin?config={_id:'setC',members:[{_id:0,host:'192.168.1.115:30000'},{_id:1,host:'192.168.1.116:30000'},{
6、_id:2,host:'192.168.1.117:30000'}]}?rs.initiate(config);?5.配置configServer:?115116117上執(zhí)行?./mongod--configsvr--logpath/data/logs/configServer/r0.log--logappend--dbpath/data/configServer/r0--port40000--shardsvr--fork?6.啟動(dòng)路由節(jié)點(diǎn):?115上執(zhí)行:?./mongos--configdb192.168.1.115:40000,192.168.
7、1.116:40000,192.168.1.116:40000--logpath??/data/logs/serverlogs/mongos.log--logappend--port50000--fork?7.配置分片?115上執(zhí)行:?./mongo127.0.0.1:50000?useadmin?db.runCommand({addshard:"setA/192.168.1.115:10000,192.168.1.116:10000,192.168.1.117:10000",name:"ShardSetA"})db.runCommand({adds
8、hard:"setB/192.168.1.115:20000,192.168.1.116:20000,192