backup.linux.sh 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. 192.168.1.107 nowledgedata-n1
  2. 192.168.1.106 nowledgedata-n2
  3. 192.168.1.116 nowledgedata-n3
  4. 192.168.1.115 nowledgedata-n4
  5. JVM_ARGS="-Xmx2G -Xms2G -Xmn1G -XX:MaxPermSize=256m -XX:PermSize=256m -DzkHost=nowledgedata-n4:2181 -Dbootstrap_conf=true -DnumShards=3 -Djetty.port=8983"
  6. JAVA_OPTS="$JAVA_OPTS $JVM_ARGS"
  7. JVM_ARGS="-Xmx2G -Xms2G -Xmn1G -XX:MaxPermSize=256m -XX:PermSize=256m -Djetty.port=8983 -DzkHost=nowledgedata-n4:2181"
  8. JAVA_OPTS="$JAVA_OPTS $JVM_ARGS"
  9. bin/mongos -configdb 192.168.1.107:37017,192.168.1.106:37017,192.168.1.116:37017 -port 30000 -chunkSize 64 -logpath /data/mongos/mongos.log --fork
  10. bin/mongo 192.168.1.107:30000/admin
  11. db.runCommand({"addshard":"192.168.1.107:27017"})
  12. db.runCommand({"addshard":"192.168.1.106:27017"})
  13. db.runCommand({"addshard":"192.168.1.116:27017"})
  14. db.runCommand({"addshard":"192.168.1.115:27017"})
  15. db.runCommand({"enablesharding": "ndmongo"})
  16. db.runCommand({"shardcollection":"nsmongo.postStore", "key":{"postUrn":1}})
  17. db.runCommand({"shardcollection":"nsmongo.userStore", "key":{"userUrn":1}})
  18. # User Operator
  19. db.userStore.ensureIndex({userUrn: 1}, {unique: true})
  20. db.userStore.ensureIndex({"userId": 1, "dwEntitySectionUrn": 1})
  21. # Post Operator
  22. db.postStore.ensureIndex({postUrn: 1}, {unique: true})
  23. db.postStore.ensureIndex({"postId": 1, "dwEntitySectionUrn": 1})
  24. db.postStore.ensureIndex({"createdAt": -1})
  25. db.postStore.ensureIndex({"comboKey": -1})
  26. 192.168.1.15 nowledgedata-s1
  27. 192.168.1.16 nowledgedata-s2
  28. 192.168.1.17 nowledgedata-s3
  29. 192.168.1.18 nowledgedata-s4
  30. mkdir -p ~/mongodata/shard1/data
  31. mkdir ~/mongodata/shard1/logs
  32. mkdir ~/mongodata/shard1/data
  33. mkdir ~/mongodata/shard2/logs
  34. mkdir ~/mongodata/config/data
  35. mkdir ~/mongodata/config/logs
  36. mkdir ~/mongodata/mongos
  37. wget http://192.168.1.15/disk/mongodb-linux-x86_64-2.4.1.tgz
  38. bin/mongod -shardsvr -replSet shard1 -port 35017 -oplogSize 100 -dbpath /home/ndyc/mongodata/shard1/data -logpath /home/ndyc/mongodata/shard1/logs/shard1.log -logappend -fork -rest
  39. bin/mongod -shardsvr -replSet shard1 -port 35017 -oplogSize 100 -dbpath /home/mongodb/mongodata/shard1/data -logpath /home/mongodb/mongodata/shard1/logs/shard1.log -logappend -fork -rest
  40. bin/mongod -shardsvr -replSet shard1 -port 35017 -oplogSize 100 -dbpath /home/mongodb/mongodata/shard1/data -logpath /home/mongodb/mongodata/shard1/logs/shard1.log -logappend -fork -rest
  41. bin/mongod -shardsvr -replSet shard1 -port 35017 -oplogSize 100 -dbpath /home/monitor/mongodata/shard1/data -logpath /home/monitor/mongodata/shard1/logs/shard1.log -logappend -fork -rest
  42. bin/mongod -shardsvr -replSet shard2 -port 35018 -oplogSize 100 -dbpath /home/ndyc/mongodata/shard2/data -logpath /home/ndyc/mongodata/shard2/logs/shard2.log -logappend -fork -rest
  43. bin/mongod -shardsvr -replSet shard2 -port 35018 -oplogSize 100 -dbpath /home/mongodb/mongodata/shard2/data -logpath /home/mongodb/mongodata/shard2/logs/shard2.log -logappend -fork -rest
  44. bin/mongod -shardsvr -replSet shard2 -port 35018 -oplogSize 100 -dbpath /home/mongodb/mongodata/shard2/data -logpath /home/mongodb/mongodata/shard2/logs/shard2.log -logappend -fork -rest
  45. bin/mongod -shardsvr -replSet shard2 -port 35018 -oplogSize 100 -dbpath /home/monitor/mongodata/shard2/data -logpath /home/monitor/mongodata/shard2/logs/shard2.log -logappend -fork -rest
  46. Init:
  47. config = {
  48. _id : "shard1",
  49. members : [
  50. {_id : 0, host : 192.168.1.15:35017 },
  51. {_id : 1, host : 192.168.1.16:35017 },
  52. {_id : 2, host : 192.168.1.17:35017 },
  53. {_id : 3, host : 192.168.1.18:35017 }
  54. ]
  55. }
  56. config = { "_id" : "shard1", "members" : [ {"_id" : 0, "host" : "192.168.1.15:35017" },{"_id" : 1, "host" : "192.168.1.16:35017" }, {"_id" : 2, "host" : "192.168.1.17:35017" },{"_id" : 3, "host" : "192.168.1.18:35017" } ]}
  57. rs.initiate(config);
  58. config = {
  59. _id : "shard2",
  60. members : [
  61. {_id : 0, host : 192.168.1.15:35018 },
  62. {_id : 1, host : 192.168.1.16:35018 },
  63. {_id : 2, host : 192.168.1.17:35018 },
  64. {_id : 3, host : 192.168.1.18:35018 },
  65. ]
  66. }
  67. config = {"_id" : "shard2", "members" : [{"_id" : 0, "host" : "192.168.1.15:35018" }, {"_id" : 1, "host" : "192.168.1.16:35018" }, {"_id" : 2, "host" : "192.168.1.17:35018" }, {"_id" : 3, "host" : "192.168.1.18:35018" }]}
  68. rs.initiate(config);
  69. Config:
  70. bin/mongod --configsvr --port 36000 --dbpath /home/mongodb/mongodata/config/data --logpath /home/mongodb/mongodata/config/logs/config.log --logappend --fork
  71. bin/mongod --configsvr --port 36000 --dbpath /home/mongodb/mongodata/config/data --logpath /home/mongodb/mongodata/config/logs/config.log --logappend --fork
  72. bin/mongod --configsvr --port 36000 --dbpath /home/monitor/mongodata/config/data --logpath /home/monitor/mongodata/config/logs/config.log --logappend --fork
  73. Mongos:
  74. bin/mongos --configdb 192.168.1.16:36000,192.168.1.17:36000,192.168.1.18:36000 --port 40000 --chunkSize 100 -logpath /home/ndyc/mongodata/mongos/mongos.log --logappend --fork
  75. Admin:
  76. bin/mongo 192.168.1.15:40000/admin
  77. db.runCommand({"addshard" : "shard1/192.168.1.15:35017,192.168.1.16:35017,192.168.1.17:35017,192.168.1.18:35017", name : "shard1", allowLocal : true});
  78. db.runCommand({"addshard" : "shard2/192.168.1.15:35018,192.168.1.16:35018,192.168.1.17:35018,192.168.1.18:35018", name : "shard2", allowLocal : true});
  79. db.runCommand({"enablesharding": "nsmongo"})
  80. db.runCommand({"shardcollection":"nsmongo.postStore", "key":{"postUrn":1}})
  81. db.runCommand({"shardcollection":"nsmongo.userStore", "key":{"userUrn":1}})
  82. db.runCommand({ listshards : 1 })
  83. Query:
  84. bin/mongo 192.168.1.18:40000/nsmongo
  85. wget http://192.168.1.15/disk/apache-tomcat-6.0.36.tar.gz
  86. JVM_ARGS="-Xmx2G -Xms2G -Xmn1G -XX:MaxPermSize=256m -XX:PermSize=256m -DzkHost=nowledgedata-n3:2181 -Dbootstrap_conf=true -DnumShards=3 -Djetty.port=8828"
  87. JAVA_OPTS="$JAVA_OPTS $JVM_ARGS"
  88. JVM_ARGS="-Xmx2G -Xms2G -Xmn1G -XX:MaxPermSize=256m -XX:PermSize=256m -Djetty.port=8828 -DzkHost=nowledgedata-s3:2181"
  89. JAVA_OPTS="$JAVA_OPTS $JVM_ARGS"