mongodb脚本自动化部署副本集和分片
发布于 4 年前 作者 TimLiu1 4210 次浏览 来自 分享
背景

我们在本地做mongodb测试开发时,如果需要mongodb的状态是副本集或则分片集群的话,部署副本集或则分片集群需要花费大量的时间,所以写写了两个脚本一件部署副本集或则分片集群

github地址

shell to quickly deploy mongodb replica set and sharding

Environment install mongodb

 mongodb version >= 3.4 

Replica Set Deployment

bash replica-set.sh
check deploy status
mongo --port 27017
rs.status()
rs.config()

all data store in ~/srv/mongodb/replicaset

Deploy a Sharded Cluster

bash sharded-cluster.sh

config ports 30000~30002

shard_one ports 30003~30005

shard_two ports 30006~30008

mongos port 30009

shard db: db_test

shard collection: student

shard key: age

check deploy status
mongo --port 30009
sh.status()

all data store in ~/srv/mongodb

回到顶部