sharding one
192.168.100.208
192.168.100.209
192.168.100.210
tar zxvf mongodb-linux-x86_64-2.2.0.tgz
mv mongodb-linux-x86_64-2.2.0 /usr/local/mongo
192.168.100.208
mkdir -p /usr/local/mongo/data/shard1_1
mkdir -p /usr/local/mongo/data/shard2_1
mkdir -p /usr/local/mongo/conf
mkdir -p /usr/local/mongo/log
192.168.100.209
mkdir -p /usr/local/mongo/data/shard1_2
mkdir -p /usr/local/mongo/data/shard2_2
mkdir -p /usr/local/mongo/conf
mkdir -p /usr/local/mongo/log
192.168.100.210
mkdir -p /usr/local/mongo/data/shard1_3
mkdir -p /usr/local/mongo/data/shard2_3
mkdir -p /usr/local/mongo/conf
mkdir -p /usr/local/mongo/log
#用mongo 連線其中一台機器的27017 埠的mongod,初始化replica sets「shard1」,執行:
mongo --port 27017
mongodb shell version: 2.2.0
connecting to: 127.0.0.1:27017/test
welcome to the mongodb shell.
for interactive help, type "help".
for more comprehensive documentation, see
questions? try the support group
> config = ,,
... ,,
... ]]
... }} ,
, ] }
> rs.initiate(config)
>
shard1:primary> rs.status()rs.status() ,
, ],
"ok" : 1 }
##sharding two
#192.168.100.208
#192.168.100.209
#192.168.100.210
#用mongo 連線其中一台機器的27018 埠的mongod,初始化replica sets 「shard2」,執行:
mongo admin --port 27018
mongodb shell version: 2.2.0
connecting to: 127.0.0.1:27018/admin
welcome to the mongodb shell.
for interactive help, type "help".
for more comprehensive documentation, see
questions? try the support group
> config = ,
... ,
... ]
... }} ,
, ] }
> rs.initiate(config)
#config server
在server 192.168.100.208、192.168.100.209、192.168.100.210上執行:
#配置3 臺route process
在server 192.168.100.208、192.168.100.209、192.168.100.210上執行:
--fork
配置shard cluster
連線到其中一台機器的埠30000 的mongos 程序,並切換到admin 資料庫做以下配置
mongo admin --port 30000
mongodb shell version: 2.2.0
connecting to: 127.0.0.1:30000/admin
mongos> db.runcommand();db.runcommand();
mongos> db.runcommand();db.runcommand();
啟用資料庫及集合的分片
mongos> db.runcommand()
mongos> db.runcommand(})
插入測試資料
use andylhz
for(var i=1;i<=2000000;i++) db.users.insert();
本文完
MongoDB 主從 分片集群配置
sharding one 192.168.100.208 192.168.100.209 192.168.100.210 tar zxvf mongodb linux x86 64 2.2.0.tgz mv mongodb linux x86 64 2.2.0 usr local mongo 192...
MongoDB集群分片
什麼是sharding?說白了就是把海量資料水平擴充套件的集群系統,資料分表儲存在sharding的各個節點上。mongodb的資料分開分為chunk,每個chunk都是collection中的一段連續的資料記錄,一般為200mb,超出則生成新的資料塊。構建sharding需要三種角色,shard伺...
mongodb分片 集群
目前在乙個機器上部署,ip 10.1.2.197,埠列表如下 埠埠埠路由服務 27061 路由服務 27062 路由服務 27063 配置服務 27071 配置服務 27072 配置服務 27073 副本集1 27011 副本集2 27021 副本集3 27031 副本集1 27012 副本集2 2...