亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

【Mongodb】分片復制集環境添加新的分片

發布時間:2020-08-06 17:16:15 來源:ITPUB博客 閱讀:117 作者:小亮520cl 欄目:關系型數據庫
1.每個節點上分別創建新的shard3配置文件
  1. [root@ip-10-1-2-68 etc]# more shard3.conf
  2. logpath=/usr/local/mongodb/logs/mongo_shard3.log
  3. logappend=true # need logrotae scripts
  4. fork=true
  5. journal=true
  6. port=27017
  7. #vvvvv = true
  8. #diaglog = 3
  9. dbpath=/usr/local/mongodb/shard3
  10. pidfilepath=/usr/local/mongodb/logs/mongo_shard3.pid
  11. bind_ip=10.1.2.68    ---bind ip 修改為自己的機器
  12. replSet=shard3
  13. shardsvr=true

2. 每個節點啟動shard3 服務
  1. [root@ip-10-1-2-68 etc]# /usr/local/mongodb/bin/mongod -f shard3.conf

3.登陸第一個節點,搭建shard3的復制集
  1. [root@ip-10-1-2-32 etc]# /usr/local/mongodb/bin/mongo 10.1.2.32:27017
  2. MongoDB shell version v3.6.4
  3. connecting to: mongodb://10.1.2.32:27017/test
  4. MongoDB server version: 3.6.4
  5. Server has startup warnings:
  6. 2018-05-08T03:26:23.290+0000 I CONTROL [initandlisten]
  7. 2018-05-08T03:26:23.290+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
  8. 2018-05-08T03:26:23.290+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
  9. 2018-05-08T03:26:23.290+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
  10. 2018-05-08T03:26:23.290+0000 I CONTROL [initandlisten]
  11. 2018-05-08T03:26:23.290+0000 I CONTROL [initandlisten]
  12. 2018-05-08T03:26:23.290+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
  13. 2018-05-08T03:26:23.290+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
  14. 2018-05-08T03:26:23.290+0000 I CONTROL [initandlisten]
  15. 2018-05-08T03:26:23.290+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
  16. 2018-05-08T03:26:23.290+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
  17. 2018-05-08T03:26:23.290+0000 I CONTROL [initandlisten]
  18. > config_rs3 = {_id: 'shard3', members: [{_id: 0, host: '10.1.2.32:27017', priority:1}, {_id: 1, host: '10.1.2.68:27017'},{_id: 2, host: '10.1.2.175:27017'}]}
  19. {
  20.         "_id" : "shard3",
  21.         "members" : [
  22.                 {
  23.                         "_id" : 0,
  24.                         "host" : "10.1.2.32:27017",
  25.                         "priority" : 1
  26.                 },
  27.                 {
  28.                         "_id" : 1,
  29.                         "host" : "10.1.2.68:27017"
  30.                 },
  31.                 {
  32.                         "_id" : 2,
  33.                         "host" : "10.1.2.175:27017"
  34.                 }
  35.         ]
  36. }
  37. > rs.initiate(config_rs3);
  38. { "ok" : 1 }

4.登陸第一個節點的mongs端口,將shard3分片加入分片組
  1. [root@ip-10-1-2-32 etc]# /usr/local/mongodb/bin/mongo 10.1.2.32:30000
  2. MongoDB shell version v3.6.4
  3. connecting to: mongodb://10.1.2.32:30000/test
  4. MongoDB server version: 3.6.4
  5. Server has startup warnings:
  6. 2018-05-03T07:47:09.379+0000 I CONTROL [main]
  7. 2018-05-03T07:47:09.379+0000 I CONTROL [main] ** WARNING: Access control is not enabled for the database.
  8. 2018-05-03T07:47:09.379+0000 I CONTROL [main] ** Read and write access to data and configuration is unrestricted.
  9. 2018-05-03T07:47:09.379+0000 I CONTROL [main] ** WARNING: You are running this process as the root user, which is not recommended.
  10. 2018-05-03T07:47:09.379+0000 I CONTROL [main]

  11. mongos> use admin;
  12. switched to db admin
  13. mongos> db.runCommand({ addshard: 'shard3/10.1.2.32:27017,10.1.2.68:27017,10.1.2.175:27017'})
  14. {
  15.         "shardAdded" : "shard3",
  16.         "ok" : 1,
  17.         "$clusterTime" : {
  18.                 "clusterTime" : Timestamp(1525750332, 7),
  19.                 "signature" : {
  20.                         "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
  21.                         "keyId" : NumberLong(0)
  22.                 }
  23.         },
  24.         "operationTime" : Timestamp(1525750332, 7)
  25. }
  26. mongos> db.printShardingStatus(); ---查看新的分片信息
  27. --- Sharding Status ---
  28.   sharding version: {
  29.         "_id" : 1,
  30.         "minCompatibleVersion" : 5,
  31.         "currentVersion" : 6,
  32.         "clusterId" : ObjectId("5aeabc4db192a4fefca1c888")
  33.   }
  34.   shards:
  35.         { "_id" : "shard1", "host" : "shard1/10.1.2.175:27019,10.1.2.32:27019,10.1.2.68:27019", "state" : 1 }
  36.         { "_id" : "shard2", "host" : "shard2/10.1.2.175:27018,10.1.2.32:27018,10.1.2.68:27018", "state" : 1 }
  37.         { "_id" : "shard3", "host" : "shard3/10.1.2.175:27017,10.1.2.32:27017,10.1.2.68:27017", "state" : 1 }
  38.   active mongoses:
  39.         "3.6.4" : 3
  40.   autosplit:
  41.         Currently enabled: yes
  42.   balancer:
  43.         Currently enabled: yes
  44.         Currently running: no
  45.         Failed balancer rounds in last 5 attempts: 0
  46.         Migration Results for the last 24 hours:
  47.                 No recent migrations
  48.   databases:
  49.         { "_id" : "config", "primary" : "config", "partitioned" : true }
  50.                 config.system.sessions
  51.                         shard key: { "_id" : 1 }
  52.                         unique: false
  53.                         balancing: true
  54.                         chunks:
  55.                                 shard1 1
  56.                         { "_id" : { "$minKey" : 1 } } -->> { "_id" : { "$maxKey" : 1 } } on : shard1 Timestamp(1, 0)
  57.         { "_id" : "test", "primary" : "shard2", "partitioned" : true }
  58.                 test.users
  59.                         shard key: { "_id" : 1 }
  60.                         unique: false
  61.                         balancing: true
  62.                         chunks:
  63.                                 shard2 1
  64.                         { "_id" : { "$minKey" : 1 } } -->> { "_id" : { "$maxKey" : 1 } } on : shard2 Timestamp(1, 0)


5、設置均衡器
  1. # 查看狀態

  2. mongos> sh.isBalancerRunning();

  3. false


  4.  

  5. # 設置均衡器

  6. mongos> sh.setBalancerState(true);

  7. mongos> sh.enableBalancing("bg")
  8. mongos> sh.getBalancerState()
    true


參考:https://docs.mongodb.com/manual/reference/method/sh.getBalancerState/





向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

望谟县| 五指山市| 昭觉县| 阳原县| 天长市| 上饶县| 海阳市| 石景山区| 昭苏县| 亚东县| 阿拉尔市| 娄底市| 永济市| 赫章县| 徐州市| 云龙县| 镇沅| 讷河市| 习水县| 望都县| 孝昌县| 六枝特区| 长海县| 吉隆县| 临夏县| 永吉县| 北票市| 根河市| 库伦旗| 哈巴河县| 赤峰市| 常熟市| 马鞍山市| 舟山市| 登封市| 昔阳县| 张家口市| 马关县| 樟树市| 广西| 会同县|