MongoDB (AutoSharding + Replication sets stability test)

Source: Internet
Author: User

Single Replication sets design:


, 10.9.3.228, only Mongos and config services are started.

  1. Pai_^ [root @:/usr/local/mongodb/bin] # cat runServerConfig. sh
  2. ./Mongod -- configsvr -- dbpath = ../data/config -- logpath = ../data/config. log -- fork
  3. Pai_^ [root @:/usr/local/mongodb/bin] # cat runServerMongos. sh
  4. ./Mongos -- configdb 10.7.3.228: 27019 -- logpath = ../data/mongos. log -- logappend -- fork
Note: The ip addresses and ports in Mongos are the ip addresses and ports of the config service.

Advanced Configuration AutoSharding

163 of shardv has been started, as long as the autoSharding service of the 165 server is started

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

Configure 163 and 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. shocould 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.1962890625 GB
  46. Set163164: PRIMARY> use local
  47. Switched to db local
  48. Set16.04: 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. }

So far, Replication sets are configured successfully!

Configure the Sharding on the 228 server.

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}

Then, start the rep service on the 163 and 164 servers respectively, and the 163 server should start the shard service separately.

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 set162134
So far, AutoSharding + Rep is successfully configured. Then perform the stability test.

First look at the result:



We can see that a total of 163 pieces of data are inserted, and 164 and 165 of the same size are part data.

  • 1
  • 2
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.