Javi

MongoDB: replica + sharding

Apr 7th, 2015
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 4.40 KB | None | 0 0
  1. md c:\data\cluster\config\c0 c:\data\cluster\config\c1 c:\data\cluster\config\c2
  2. md c:\data\cluster\shard0\m0 c:\data\cluster\shard0\m1 c:\data\cluster\shard0\arb
  3. md c:\data\cluster\shard1\m0 c:\data\cluster\shard1\m1 c:\data\cluster\shard1\arb
  4. md c:\data\cluster\shard2\m0 c:\data\cluster\shard2\m1 c:\data\cluster\shard2\arb
  5. md c:\data\cluster\s0 c:\data\cluster\s1
  6.  
  7. rem ===========================================================================
  8.  
  9. rem  Shard 0 - Primary
  10. start mongod --replSet shard0 --smallfiles --nojournal --noprealloc --dbpath /data/cluster/shard0/m0 --logpath /data/cluster/shard0/m0/mongod.log --port 27107
  11.  
  12. rem  Shard 0 - Secondary
  13. start mongod --replSet shard0 --smallfiles --nojournal --noprealloc --dbpath /data/cluster/shard0/m1 --logpath /data/cluster/shard0/m1/mongod.log --port 27108
  14.  
  15. rem  Shard 0 - Árbitro
  16. start mongod --replSet shard0 --smallfiles --nojournal --noprealloc --dbpath /data/cluster/shard0/arb --logpath /data/cluster/shard0/arb/mongod.log --port 27109
  17.  
  18. mongo --port 27107 --eval " rs.initiate(); sleep(3000); rs.add ('WIWI:27108'); rs.addArb('WIWI:27109')"
  19.  
  20. rem ==========================================================================
  21.  
  22. rem  Shard 1 - Primary
  23. start mongod --replSet shard1 --smallfiles --nojournal --noprealloc --dbpath /data/cluster/shard1/m0 --logpath /data/cluster/shard1/m0/mongod.log --port 27117
  24.  
  25. rem  Shard 1 - Secondary
  26. start mongod --replSet shard1 --smallfiles --nojournal --noprealloc --dbpath /data/cluster/shard1/m1 --logpath /data/cluster/shard1/m1/mongod.log --port 27118
  27.  
  28. rem  Shard 1 - Árbitro
  29. start mongod --replSet shard1 --smallfiles --nojournal --noprealloc --dbpath /data/cluster/shard1/arb --logpath /data/cluster/shard1/arb/mongod.log --port 27119
  30.  
  31. mongo --port 27117 --eval " rs.initiate(); sleep(3000); rs.add ('WIWI:27118'); rs.addArb('WIWI:27119')"
  32.  
  33. rem ==========================================================================
  34.  
  35. rem  Shard 2 - Primary
  36. start mongod --replSet shard2 --smallfiles --nojournal --noprealloc --dbpath /data/cluster/shard2/m0 --logpath /data/cluster/shard2/m0/mongod.log --port 27127
  37.  
  38. rem  Shard 2 - Secondary
  39. start mongod --replSet shard2 --smallfiles --nojournal --noprealloc --dbpath /data/cluster/shard2/m1 --logpath /data/cluster/shard2/m1/mongod.log --port 27128
  40.  
  41. rem  Shard 2 - Árbitro
  42. start mongod --replSet shard2 --smallfiles --nojournal --noprealloc --dbpath /data/cluster/shard2/arb --logpath /data/cluster/shard2/arb/mongod.log --port 27129
  43.  
  44. mongo --port 27127 --eval " rs.initiate(); sleep(3000); rs.add ('WIWI:27128'); rs.addArb('WIWI:27129')"
  45.  
  46. rem ==========================================================================
  47. rem Config servers
  48.  
  49. rem  config1
  50. start mongod --smallfiles --nojournal --noprealloc --dbpath /data/cluster/config/c0 --logpath /data/cluster/config/c0/mongod.log --port 27227 --configsvr
  51.  
  52. rem  config2
  53. start mongod --smallfiles --nojournal --noprealloc --dbpath /data/cluster/config/c1 --logpath /data/cluster/config/c1/mongod.log --port 27228 --configsvr
  54.  
  55. rem  config3
  56. start mongod --smallfiles --nojournal --noprealloc --dbpath /data/cluster/config/c2 --logpath /data/cluster/config/c2/mongod.log --port 27229 --configsvr
  57.  
  58. rem ==========================================================================
  59. rem mongos
  60.  
  61. rem  mongos1
  62. start mongos --logpath /data/cluster/s0/mongos.log --port 27017 --configdb WIWI:27227,WIWI:27228,WIWI:27229
  63.  
  64. rem  mongos2
  65. start mongos --logpath /data/cluster/s1/mongos.log  --port 27018 --configdb WIWI:27227,WIWI:27228,WIWI:27229
  66.  
  67. rem ==========================================================================
  68.  
  69. echo 'sh.addShard( "shard0/WIWI:27107" );  sh.addShard("shard1/WIWI:27117" );  sh.addShard( "shard2/WIWI:27127" ); sh.status()' | mongo
  70.  
  71.  
  72. rem ==========================================================================
  73.  
  74.  
  75. echo 'sh.enableSharding("test"); \
  76.       sh.shardCollection("test.testcol", { a : 1, b : 1 } )' | mongo
  77.  
  78.  
  79. return
  80.  
  81. rem ==========================================================================
  82.  
  83. for (i=0; i<10000; i++) {
  84.     docArr = [];
  85.     for (j=0; j<1000; j++) {
  86.         docArr.push( { a : i, b : j, c : "Filler String 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" } )  
  87.     };    
  88.     db.testcol.insert(docArr) ;
  89. }
  90.  
  91. rem ==========================================================================
  92.  
  93. sh.status()
Advertisement
Add Comment
Please, Sign In to add comment