MongoDB Cluster Setting up [replSet + Sharding]
来源:互联网 发布:php员工管理系统源代码 编辑:程序博客网 时间:2024/05/22 10:59
step 1 [on each server]
sudo mkdir -p /data/mongodbwsdc/mongos/logsudo mkdir -p /data/mongodbwsdc/config/datasudo mkdir -p /data/mongodbwsdc/config/logsudo mkdir -p /data/mongodbwsdc/mongos/logsudo mkdir -p /data/mongodbwsdc/shard1/datasudo mkdir -p /data/mongodbwsdc/shard1/logsudo mkdir -p /data/mongodbwsdc/shard2/datasudo mkdir -p /data/mongodbwsdc/shard2/logsudo mkdir -p /data/mongodbwsdc/shard3/datasudo mkdir -p /data/mongodbwsdc/shard3/log
step 2 [on each server]
sudo ./mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongod --configsvr --dbpath /data/mongodbwsdc/config/data --port 21000 --logpath /data/mongodbwsdc/config/log/config.log --forksudo ./mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongos --configdb 10.10.2.151:21000,10.10.2.152:21000,10.10.2.159:21000 --port 20000 --logpath /data/mongodbwsdc/mongos/log/mongos.log --fork
step 3 [on each server]
sudo ./mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongod --shardsvr --replSet shard1 --port 22001 --dbpath /data/mongodbwsdc/shard1/data --logpath /data/mongodbwsdc/shard1/log/shard1.log --fork --nojournal --oplogSize 10sudo ./mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongod --shardsvr --replSet shard2 --port 22002 --dbpath /data/mongodbwsdc/shard2/data --logpath /data/mongodbwsdc/shard2/log/shard2.log --fork --nojournal --oplogSize 10sudo ./mongodb-linux-x86_64-ubuntu1404-3.2.0/bin/mongod --shardsvr --replSet shard3 --port 22003 --dbpath /data/mongodbwsdc/shard3/data --logpath /data/mongodbwsdc/shard3/log/shard3.log --fork --nojournal --oplogSize 10
step 4 [on one server]
> mongo 10.10.2.151:22001> use admin> config = { _id:"shard1", members:[{_id:0,host:"10.10.2.151:22001"},{_id:1,host:"10.10.2.152:22001"},{_id:2,host:"10.10.2.159:22001",arbiterOnly:true}]}> rs.initiate(config);> mongo 10.10.2.151:22002> use admin> config = { _id:"shard2", members:[{_id:0,host:"10.10.2.151:22002"},{_id:1,host:"10.10.2.152:22002"},{_id:2,host:"10.10.2.159:22002",arbiterOnly:true}]}> rs.initiate(config);> mongo 10.10.2.151:22003> use admin> config = { _id:"shard3", members:[{_id:0,host:"10.10.2.151:22003"},{_id:1,host:"10.10.2.152:22003"},{_id:2,host:"10.10.2.159:22003",arbiterOnly:true}]}> rs.initiate(config);
step 5 [on one server]
> mongo 10.10.2.151:20000> use admin> db.runCommand( { addshard : "shard1/10.10.2.151:22001,10.10.2.152:22001,10.10.2.159:22001"});> db.runCommand( { addshard : "shard2/10.10.2.151:22002,10.10.2.152:22002,10.10.2.159:22002"});> db.runCommand( { addshard : "shard3/10.10.2.151:22003,10.10.2.152:22003,10.10.2.159:22003"});> db.runCommand( { listshards : 1 } );
set which database to use shsarding
> db.runCommand( { enablesharding :"testdb"});> db.runCommand( { shardcollection : "testdb.table1",key : {id: 1} } )
varify whether succeeded
> use testdb;> for (var i = 1; i <= 100000; i++)> db.table1.save({id:i,"test1":"testval1"});> db.table1.stats();
Check original post here: http://www.lanceyan.com/tech/arch/mongodb_shard1.html
0 0
- MongoDB Cluster Setting up [replSet + Sharding]
- Linux Mongodb Sharding replset 集群
- Setting Up Redis Cluster
- Setting up a Storm Cluster
- mongodb sharding cluster(分片集群)
- MongoDB ReplSet + Sharding 分片集群,主从同步配置
- MongoDB---replSet
- mongodb replSet
- Setting up SSH for a Hadoop cluster
- Hadoop: Setting up a Single Node Cluster
- 配置mongodb分片群集(sharding cluster)
- 配置mongodb分片群集(sharding cluster)
- 配置mongodb分片群集(sharding cluster)
- 配置mongodb分片群集(sharding cluster)
- 配置mongodb分片群集(sharding cluster)
- 配置mongodb分片群集(sharding cluster)
- 配置mongodb分片群集(sharding cluster)
- MongoDB分片(Sharding)集群(Cluster)
- 一段代码,求解数独(九宫格)游戏
- UVa 508
- 黑马程序员---Java基础---字节流和字符流
- libsvm安装测试步骤
- Docker 1.9 官方中文手册
- MongoDB Cluster Setting up [replSet + Sharding]
- JDK配置完成以后,“.jar”文件双击依旧不能运行的问题
- 深度分析 Java 的 ClassLoader 机制(源码级别)
- CAS 单点登陆配置
- stdafx.h的作用以及原理
- 关键业务系统的JVM启动参数推荐http://calvin1978.blogcn.com/articles/jvmoption-2.html
- cas server端的login-webflow详细流程
- 第14周 项目3 - 是否二叉排序树?
- java web中使用log4j路径的事