mongodb shard

启动 202.173.8.57 (Shard1) ./mongod --port 30001 --dbpath /home/mongodb/workspace/db/shard1 --logpath /home/mongodb/workspace/db/log/shard1.log --shardsvr --logappend --fork  202.173.8.59 (Shard2) ./mongod --port 30002 --dbpath /home/mongodb/workspace/db/shard2 --logpath /home/mongodb/workspace/db/log/shard2.log --shardsvr --logappend --fork 202.173.8.57 (Config) ./mongod --port 30003 --dbpath /home/mongodb/workspace/db/config --logpath /home/mongodb/workspace/db/log/config.log --configsvr --logappend --fork 202.173.8.57 (Mongos) ./mongos --port 30004  --logpath /home/mongodb/workspace/db/log/mongos.log  --logappend --configdb "202.173.8.57:30003"  --chunkSize 800 --fork 202.173.8.59 (Mongos) ./mongos --port 30005  --logpath /home/mongodb/workspace/db/log/mongos.log  --logappend --configdb "202.173.8.57:30003"  --chunkSize 800 --fork #login set shard ./mongo 202.173.9.57:30004/admin 配置shard db.runCommand( { addshard : "202.173.8.57:30001" } ); db.runCommand( { addshard : "202.173.8.59:30002" } ); 指定用户为分片 db.runCommand( { enablesharding : "mongodb_test" } ); 指定Key 1 为order asc -1 为desc db.runCommand( { shardcollection : "mongodb_test.student_0", key : { stuId: 1,name:1 } } ) db.runCommand( { shardcollection : "mongodb_test.student_1", key : { stuId: 1,name:1 } } ) db.runCommand( { shardcollection : "mongodb_test.student_2", key : { stuId: 1,name:1 } } ) db.runCommand( { shardcollection : "mongodb_test.student_3", key : { stuId: 1,name:1 } } ) db.runCommand( { shardcollection : "mongodb_test.student_4", key : { stuId: 1,name:1 } } ) for  (var  i  =  1;  i  <=  500000;  i++)  db.student_0.insert({stuId:i,  name:"wangwenlong"+i,  addr:"Beijing",  country:"China"})  更新到其它机器,更新配置信息 mongos> use config switched to db config mongos> db.shards.find() { "_id" : "shard0000", "host" : "202.173.8.57:30001" } { "_id" : "shard0001", "host" : "202.173.8.59:30002" } 查看统计数据 ./mongostat -host ip -port 20001  连接sharding的端口 连接mongos  ./mongo ip:端口/admin                    ./mongo ip:端口/kx_monitor use admin     数据已经导入测试环境(17号至19号的快照数据),导入方法如下:   1. ISODate("2013-02-17T08:00:00.000Z").valueOf() ------------------------> xxxxxxxxxxxxxxxxxxx(时间戳)     ISODate("2013-02-19T08:00:00.000Z").valueOf() ------------------------> xxxxxxxxxxxxxxxxxxx(时间戳)   2 ./mongoexport -h 202.173.8.37 --port 30000 -d km_mongodb -c snapshot_0 -q '{executeTime:{$gte:new Date(xxxxxxxxxxxxxx),$lt:new Date(xxxxxxxxxxxxxx)}}' -o 20130322_snapshot_0.json    ./mongoexport -h 202.173.8.37 --port 30000 -d km_mongodb -c snapshotResult_0 -q '{executeTime:{$gte:new Date(xxxxxxxxxxxxxx),$lt:new Date(xxxxxxxxxxxxxx)}}' -o 20130322_snapshotResult_0.json   3 ./mongoimport -h 202.173.8.57 --port 30000 -d km_mongodb -c snapshotResult_0 --file 20130322_snapshotResult_0.json     ./mongoimport -h 202.173.8.57 --port 30000 -d km_mongodb -c snapshot_0 --file 20130322_snapshot_0.json             ./mongoimport -h 202.173.8.57 --port 30000 -d km_mongodb -c snapshot_0 --file 201209070202019275_snapshot_5.json  mongos> ISODate("2013-02-05T23:59:00Z").valueOf() 1360108740000 mongos> ISODate("2013-02-19T00:01:00Z").valueOf() 1361232060000 ./mongoimport -h 202.173.8.57 --port 30000 -d km_mongodb -c snapshot_5 --file 20130228/snapshot/05_19_snapshot_5.json


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部