clean.sh******************************
rm -rf /data/support/mongodb-1.8.4/data/shard1c/*
rm -rf /data/support/mongodb-1.8.4/data/shard2c/*
rm -rf /data/support/mongodb-1.8.4/data/config/*
mkdir /data/support/mongodb-1.8.4/data/shard1c
mkdir /data/support/mongodb-1.8.4/data/shard2c
mkdir /data/support/mongodb-1.8.4/data/config
stop.sh****************************************
echo `ps aux|grep mongo|grep -v grep`
SERVER_PID=`ps auxf | grep "mongo" | grep -v "grep"| awk '{print $2}'`
#echo $SERVER_PID
for i in $SERVER_PID
do
echo stop process $i
kill $i
done
start.sh*****************************************多台机器略有差别
./bin/mongod -shardsvr -replSet shard1 -port 10086 -dbpath /data/support/mongodb-1.8.4/data/shard1c -oplogSize 100 -logpath /data/support/mongodb-1.8.4/logs/shard1c.log -logappend -fork -rest
./bin/mongod -shardsvr -replSet shard2 -port 20086 -dbpath /data/support/mongodb-1.8.4/data/shard2c -oplogSize 100 -logpath /data/support/mongodb-1.8.4/logs/shard2c.log -logappend -fork -rest
#./bin/mongod -shardsvr -replSet shard3 -port 30086 -dbpath /data/support/mongodb-1.8.4/data/shard3c -oplogSize 100 -logpath /data/support/mongodb-1.8.4/logs/shard3c.log -logappend -fork -rest
./bin/mongod -configsvr -dbpath /data/support/mongodb-1.8.4/data/config -port 10087 -logpath /data/support/mongodb-1.8.4/logs/config.log -logappend -fork -rest
./bin/mongos -configdb 10.200.7.106:10087,10.200.7.221:10087,10.200.7.226:10087 -port 10088 -chunkSize 5 -logpath /data/support/mongodb-1.8.4/logs/mongos.log -logappend -fork
config.sh**********************************************
#初始化shard1
./bin/mongo -port 10086 <<EOF
config={_id:'shard1',members:[{_id:0,host:'10.200.7.106:10086'},{_id:1,host:'10.200.7.221:10086'},{_id:2,host:'10.200.7.226:10086'}]};
rs.initiate(config);
exit;
EOF
#初始化shard2
./bin/mongo -port 20086 <<EOF
config={_id:'shard2',members:[{_id:0,host:'10.200.7.106:20086'},{_id:1,host:'10.200.7.221:20086'},{_id:2,host:'10.200.7.226:20086'}]};
rs.initiate(config);
exit;
EOF
#配置分片
./bin/mongo 127.0.0.1:10088/admin <<EOF
db.runCommand({addshard: "shard1/10.200.7.106:10086,10.200.7.221:10086,10.200.7.226:10086"})
db.runCommand({addshard: "shard2/10.200.7.106:20086,10.200.7.221:20086,10.200.7.226:20086"})
db.runCommand({listshards : 1 })
db.runCommand( { enablesharding : "ISYDB_A" } )
db.runCommand( { shardcollection :"ISYDB_A.VIDEO",key : {_id: 1} })
exit;
EOF