MongoDB(AutoSharding+Replication sets 穩定性測試 )

來源:互聯網
上載者:User

單Replication sets設計:


,10.9.3.228隻啟動Mongos和config兩個服務

  1. ^_^[root@:/usr/local/mongodb/bin]#cat runServerConfig.sh   
  2. ./mongod --configsvr --dbpath=../data/config --logpath=../data/config.log --fork   
  3. ^_^[root@:/usr/local/mongodb/bin]#cat runServerMongos.sh   
  4. ./mongos --configdb 10.7.3.228:27019 --logpath=../data/mongos.log --logappend --fork  
注意:Mongos裡面的ip和連接埠是config服務的ip和連接埠

先進性配置AutoSharding

163的shardv已經啟動了,只要啟動下165伺服器的autoSharding服務

  1. [root@localhost bin]# cat runServerShard.sh   
  2. ./mongod --shardsvr -dbpath=../data/mongodb --logpath=../data/shardsvr_logs.txt --fork  

配置163和164的Replication

  1. [root@localhost bin]# ./mongo 10.10.21.163:27018  
  2. MongoDB shell version: 1.8.2  
  3. connecting to: 10.10.21.163:27018/test  
  4. > cfg={_id:"set163164",members:[                              
  5. ... {_id:0,host:"10.10.21.163:27018"},  
  6. ... {_id:1,host:"10.10.21.164:27017"}  
  7. ... ]}  
  8. {  
  9.         "_id" : "set163164",  
  10.         "members" : [  
  11.                 {  
  12.                         "_id" : 0,  
  13.                         "host" : "10.10.21.163:27018"  
  14.                 },  
  15.                 {  
  16.                         "_id" : 1,  
  17.                         "host" : "10.10.21.164:27017"  
  18.                 }  
  19.         ]  
  20. }  
  21. > rs.initiate(cfg)  
  22. {  
  23.         "info" : "Config now saved locally.  Should come online in about a minute.",  
  24.         "ok" : 1  
  25. }  
  26. > rs.conf()  
  27. {  
  28.         "_id" : "set163164",  
  29.         "version" : 1,  
  30.         "members" : [  
  31.                 {  
  32.                         "_id" : 0,  
  33.                         "host" : "10.10.21.163:27018"  
  34.                 },  
  35.                 {  
  36.                         "_id" : 1,  
  37.                         "host" : "10.10.21.164:27017"  
  38.                 }  
  39.         ]  
  40. }  
  41. set163164:PRIMARY>   
  42. set163164:PRIMARY>   
  43. set163164:PRIMARY> show dbs  
  44. admin   (empty)  
  45. local   14.1962890625GB  
  46. set163164:PRIMARY> use local  
  47. switched to db local  
  48. set163164:PRIMARY> show collections  
  49. oplog.rs  
  50. system.replset  
  51. set163164:PRIMARY> db.system.replset.find()  
  52. { "_id" : "set163164", "version" : 1, "members" : [  
  53.         {  
  54.                 "_id" : 0,  
  55.                 "host" : "10.10.21.163:27018"  
  56.         },  
  57.         {  
  58.                 "_id" : 1,  
  59.                 "host" : "10.10.21.164:27017"  
  60.         }  
  61. ] }  
  62. set163164:PRIMARY> rs.isMaster()  
  63. {  
  64.         "setName" : "set163164",  
  65.         "ismaster" : true,  
  66.         "secondary" : false,  
  67.         "hosts" : [  
  68.                 "10.10.21.163:27018",  
  69.                 "10.10.21.164:27017"  
  70.         ],  
  71.         "maxBsonObjectSize" : 16777216,  
  72.         "ok" : 1  
  73. }  

至此Replication sets配置成功!

再在228伺服器上進行相應Sharding配置

use admin

  1. > db.runCommand({addshard:"set163164/10.10.21.163:27018,10.10.21.165:27018"});   
  2. { "shardAdded" : "set163164", "ok" : 1 }  
  3. > db.runCommand({enableSharding:"test"})    
  4. { "ok" : 1 }  
 
  1. > db.runCommand({shardcollection:"test.users",key:{_id:1}})    
  2. { "collectionsharded" : "test.users", "ok" : 1 }  

然後分別在163和164伺服器上啟動rep服務,163要單獨啟動shard服務

163:

  1. [root@localhost bin]# cat runServerShard.sh   
  2. ./mongod --shardsvr --dbpath=../data/mongodb --logpath=../data/shardsvr_logs.txt --fork --replSet set163164  

164:

  1. [root@localhost bin]# cat runServerShard.sh   
  2. ./mongod --dbpath=../data --logpath=../data/shardsvr_logs.txt --fork --replSet set163164   
至此AutoSharding+Rep配置成功。然後進行測試穩定性階段。

先看下結果:



可以看到,總共插入2000W條資料,163和164相同大小 165屬於分區 資料。

  • 1
  • 2
  • 下一頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.