自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

MongoDB AutoSharding+Replication sets穩(wěn)定性測(cè)試

數(shù)據(jù)庫 其他數(shù)據(jù)庫 數(shù)據(jù)庫運(yùn)維 MongoDB
如果插入2000W條數(shù)據(jù),163和164相同大小,165屬于分片數(shù)據(jù)。如何進(jìn)行穩(wěn)定性測(cè)試,會(huì)如何呢?

單Replication sets設(shè)計(jì):

如圖所示,10.9.3.228只啟動(dòng)Mongos和config兩個(gè)服務(wù)

  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服務(wù)的ip和端口

先進(jìn)性配置AutoSharding

163的shardv已經(jīng)啟動(dòng)了,只要啟動(dòng)下165服務(wù)器的autoSharding服務(wù)

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

再在228服務(wù)器上進(jìn)行相應(yīng)Sharding配置

use admin

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

然后分別在163和164服務(wù)器上啟動(dòng)rep服務(wù),163要單獨(dú)啟動(dòng)shard服務(wù)

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   

繼續(xù)配置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配置成功!

至此AutoSharding+Rep配置成功。然后進(jìn)行測(cè)試穩(wěn)定性階段。(剛才注意 應(yīng)該先配sharding再配Replication)

先看下結(jié)果:

可以看到,總共插入2000W條數(shù)據(jù),163和164相同大小 165屬于分片 數(shù)據(jù)。

我現(xiàn)在進(jìn)行穩(wěn)定性測(cè)試:

斷掉163服務(wù)器。

Mongos那再相應(yīng)進(jìn)行查詢:

  1. > db.users.find()   
  2. error: { "$err" : "error querying server: 10.10.21.163:27018""code" : 13633 }   
  3. > db.users.find()   
  4. error: {   
  5.         "$err" : "DBClientBase::findOne: transport error: 10.10.21.163:27018 query: { setShardVersion: \"test.users\", configdb: \"10.7.3.228:27019\", version: Timestamp 11000|1, serverID: ObjectId('4e2f64af98dd90fed26585a4'), shard: \"shard0000\", shardHost: \"10.10.21.163:27018\" }",   
  6.         "code" : 10276   
  7. }   
  8. > db.users.find()                                                                              
  9. error: { "$err" : "socket exception""code" : 11002 }   

直接出現(xiàn)錯(cuò)誤!

再進(jìn)行手動(dòng)添加164服務(wù)器!

  1. > db.runCommand({addshard:"10.10.21.164:27017"});    
  2. {   
  3.         "ok" : 0,   
  4.         "errmsg" : "host is part of set: set163164 use replica set url format <setname>/<server1>,<server2>,...."   
  5. }   

還是出錯(cuò)!

可見這樣配置是有問題的!

文章未完,繼續(xù)更新中!

原文鏈接:http://blog.csdn.net/crazyjixiang/article/details/6636671

【編輯推薦】

  1. 教你如何利用MySQL學(xué)習(xí)MongoDB
  2. 說說MongoDB的基礎(chǔ)
  3. 如何用Java操作MongoDB
  4. MongoDB分布式自動(dòng)分片(Auto-sharding)研究
  5. MongoDB 1000W級(jí)數(shù)據(jù)Insert和Query性能測(cè)試
責(zé)任編輯:艾婧 來源: Crazybaby's blog
相關(guān)推薦

2023-04-26 18:36:13

2009-02-04 09:22:40

穩(wěn)定性服務(wù)器測(cè)試

2019-06-17 15:48:51

服務(wù)器測(cè)試方法軟件

2022-09-15 08:33:27

安全生產(chǎn)系統(tǒng)Review

2023-09-07 15:16:06

軟件開發(fā)測(cè)試

2023-06-30 08:43:36

2010-08-14 09:46:05

2011-04-27 21:54:45

2009-07-27 10:08:14

2011-12-21 09:46:46

程序員

2011-08-01 11:03:15

2020-07-13 08:10:13

軟件設(shè)計(jì)系統(tǒng)

2020-07-28 08:07:14

ElasticSear

2009-10-30 18:10:05

2013-11-01 11:16:16

蘋果OS XOS X Maveri

2024-12-12 09:18:21

2009-12-23 18:18:04

2013-05-23 16:00:20

負(fù)載均衡網(wǎng)絡(luò)優(yōu)化網(wǎng)絡(luò)升級(jí)

2022-05-05 19:20:24

數(shù)據(jù)系統(tǒng)穩(wěn)定性峰會(huì)數(shù)據(jù)系統(tǒng)

2023-10-09 07:24:58

數(shù)據(jù)穩(wěn)定性治理數(shù)據(jù)處理
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)