Created
July 14, 2014 04:36
-
-
Save lxj5891/5485f9259b58173dcea1 to your computer and use it in GitHub Desktop.
mongodb 环境
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir -p /data/test/config/db/ | |
mkdir -p /data/test/config/log/ | |
mkdir -p /data/test/mongos/log/ | |
mkdir -p /data/test/shard1/db/ | |
mkdir -p /data/test/shard1/log/ | |
mkdir -p /data/test/shard2/db/ | |
mkdir -p /data/test/shard2/log/ | |
mongod --configsvr --dbpath /data/test/config/db --port 21000 --logpath /data/test/config/log/config.log --fork | |
mongos --configdb 10.2.9.104:21000,10.2.9.105:21000,10.2.9.106:21000 --port 20000 --logpath /data/test/mongos/log/mongos.log --fork | |
mongod --shardsvr --replSet repset1 --port 22001 --dbpath /data/test/shard1/db --logpath /data/test/shard1/log/shard1.log --fork | |
mongod --shardsvr --replSet repset2 --port 22002 --dbpath /data/test/shard2/db --logpath /data/test/shard2/log/shard2.log --fork | |
use admin | |
var config = { _id : "repset1" , members : [ | |
{_id : 0 , host :"10.2.9.104:22001" , priority : 100}, | |
{_id :1 , host :"10.2.9.105:22001" , priority : 90}, | |
{_id :2 , host :"10.2.9.106:22001" , arbiterOnly: true}, | |
{_id :3 , host :"10.2.9.107:22001" , priority:0, buildIndexes: false} | |
]}; | |
rs.initiate(config); | |
use admin | |
var config = { _id : "repset2" , members : [ | |
{_id : 0 , host : "10.2.9.104:22002" , priority : 100}, | |
{_id :1 , host :"10.2.9.105:22002" , priority : 90}, | |
{_id :2 , host :"10.2.9.106:22002" , arbiterOnly: true}, | |
{_id :3 , host :"10.2.9.107:22002" , priority:0, buildIndexes: false} | |
]}; | |
rs.initiate(config); | |
mongo 127.0.0.1:20000 | |
db.runCommand({addshard : "repset1/10.2.9.104:22001,10.2.9.105:22001,10.2.9.106:22001,10.2.9.107:22001"}); | |
db.runCommand({addshard : "repset2/10.2.9.104:22002,10.2.9.105:22002,10.2.9.106:22002,10.2.9.107:22002"}); | |
db.runCommand( { listshards : 1 } ); | |
//查看分片状态 | |
db.getSiblingDB("config").shards.find() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment