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
Mongod--shardsvr--replset shard1--port 27017--dbpath=/usr/local/mongo/data/shard1_1--logpath=/usr/local/mongo/ Logshard1_1.log--logappend--fork
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
Mongod--shardsvr--replset shard1--port 27017--dbpath=/usr/local/mongo/data/shard1_2--logpath=/usr/local/mongo/ Logshard1_2.log--logappend--fork
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
Mongod--shardsvr--replset shard1--port 27017--dbpath=/usr/local/mongo/data/shard1_3--logpath=/usr/local/mongo/ Logshard1_3.log--logappend--fork
#用mongo 27017-Port Mongod connected to one of the machines, initialize replica Sets "Shard1" and execute:
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
http://docs.mongodb.org/
Questions? Try the Support group
Http://groups.google.com/group/mongodb-user
> config = {_id: ' Shard1 ', Members: [config = {_id: ' Shard1 ', Members: [
... {_id:0, Host: ' 192.168.100.208:27017 '},{_id:0, Host: ' 192.168.100.208:27017 '},
... {_id:1, Host: ' 192.168.100.209:27017 '},{_id:1, Host: ' 192.168.100.209:27017 '},
... {_id:2, Host: ' 192.168.100.210:27017 '}] {_id:2, Host: ' 192.168.100.210:27017 '}]
... }}
{
"_id": "Shard1",
"Members": [
{
"_id": 0,
"Host": "192.168.100.208:27017"
},
{
"_id": 1,
"Host": "192.168.100.209:27017"
},
{
"_id": 2,
"Host": "192.168.100.210:27017"
}
]
}