• MongoDB——linux下mongo4.4分片配置文件备份


    下载地址:

    https://downloads.mongodb.com/linux/mongodb-linux-x86_64-enterprise-rhel70-4.4.2.tgz

    都下载到目录  /root/data/soft/mongodb4.4/

     

    4台机器a b c d

    a部署mongos,端口为 26000

    b、c、d部署configserver三节点副本集,端口为 26100

    b、c、d部署shard1三节点副本集,端口为 26101

    b、c、d部署shard2三节点副本集,端口为 26102

    b、c、d部署shard3三节点副本集,端口为 26103

     

    配置文件:

    mongos/mongodb.conf 

    logpath=/root/data/soft/mongodb4.4/mongos/log/mongodb.log
    
    pidfilepath = /root/data/soft/mongodb4.4/mongos/m.pid
    
    logappend=true
    
    bind_ip = 0.0.0.0
    
    port = 26000
    
    fork = true
    
    maxConns = 1000
    
    configdb=config_repl_set/172.31.140.157:26100,172.31.140.158:26100,172.31.140.159:26100

     

    configsvr/mongodb.conf

    dbpath=/root/data/soft/mongodb4.4/configsvr/db/
    
    logpath=/root/data/soft/mongodb4.4/configsvr/log/mongodb.log
    
    pidfilepath=/root/data/soft/mongodb4.4/configsvr/m.pid
    
    logappend=true
    
    bind_ip = 0.0.0.0
    
    port = 26100
    
    fork = true
    
    maxConns = 1000
    
    journal = true
    
    syncdelay = 60
    
    oplogSize = 1000
    
    auth = false
    
    storageEngine = wiredTiger
    
    wiredTigerEngineConfigString = cache_size=64M
    
    configsvr = true
    
    replSet=config_repl_set

    shard1/mongodb.conf

    dbpath=/root/data/soft/mongodb4.4/shard1/db/
    
    logpath=/root/data/soft/mongodb4.4/shard1/log/mongodb.log
    
    pidfilepath=/root/data/soft/mongodb4.4/shard1/m.pid
    
    logappend=true
    
    bind_ip = 0.0.0.0
    
    port = 26101
    
    fork = true
    
    maxConns = 1000
    
    journal = true
    
    syncdelay = 60
    
    oplogSize = 1000
    
    auth = false
    
    storageEngine = wiredTiger
    
    wiredTigerEngineConfigString = cache_size=64M
    
    shardsvr = true
    
    replSet=shard1_repl_set

    shard2/mongodb.conf 

    dbpath=/root/data/soft/mongodb4.4/shard2/db/
    
    logpath=/root/data/soft/mongodb4.4/shard2/log/mongodb.log
    
    pidfilepath=/root/data/soft/mongodb4.4/shard2/m.pid
    
    logappend=true
    
    bind_ip = 0.0.0.0
    
    port = 26102
    
    fork = true
    
    maxConns = 1000
    
    journal = true
    
    syncdelay = 60
    
    oplogSize = 1000
    
    auth = false
    
    storageEngine = wiredTiger
    
    wiredTigerEngineConfigString = cache_size=64M
    
    shardsvr = true
    
    replSet=shard2_repl_set

    shard3/mongodb.conf 

    dbpath=/root/data/soft/mongodb4.4/shard3/db/
    
    logpath=/root/data/soft/mongodb4.4/shard3/log/mongodb.log
    
    pidfilepath=/root/data/soft/mongodb4.4/shard3/m.pid
    
    logappend=true
    
    bind_ip = 0.0.0.0
    
    port = 26103
    
    fork = true
    
    maxConns = 1000
    
    journal = true
    
    syncdelay = 60
    
    oplogSize = 1000
    
    auth = false
    
    storageEngine = wiredTiger
    
    wiredTigerEngineConfigString = cache_size=64M
    
    shardsvr = true
    
    replSet=shard3_repl_set

    启动命令:

    [root@izm5eb28tnyvb00rm7as8sz mongodb4.4]# cat run-shard1.sh
    
    /root/data/soft/mongodb4.4/mongodb-linux-x86_64-enterprise-rhel70-4.4.2/bin/mongod -f /root/data/soft/mongodb4.4/shard1/mongodb.conf
    
    
    [root@izm5eb28tnyvb00rm7as8sz mongodb4.4]# cat run-shard2.sh
    
    /root/data/soft/mongodb4.4/mongodb-linux-x86_64-enterprise-rhel70-4.4.2/bin/mongod -f /root/data/soft/mongodb4.4/shard2/mongodb.conf
    
    
    [root@izm5eb28tnyvb00rm7as8sz mongodb4.4]# cat run-shard3.sh
    
    /root/data/soft/mongodb4.4/mongodb-linux-x86_64-enterprise-rhel70-4.4.2/bin/mongod -f /root/data/soft/mongodb4.4/shard3/mongodb.conf
    
    
    [root@izm5eb28tnyvb00rm7as8sz mongodb4.4]# cat run-configsvr.sh 
    
    /root/data/soft/mongodb4.4/mongodb-linux-x86_64-enterprise-rhel70-4.4.2/bin/mongod -f /root/data/soft/mongodb4.4/configsvr/mongodb.conf
    [root@izm5eb28tnyvb00rm7as8wz mongodb4.4]# cat run-mongos.sh 
    
    /root/data/soft/mongodb4.4/mongodb-linux-x86_64-enterprise-rhel70-4.4.2/bin/mongos -f /root/data/soft/mongodb4.4/mongos/mongodb.conf

    初始化config副本集:

    /root/data/soft/mongodb4.4/mongodb-linux-x86_64-enterprise-rhel70-4.4.2/bin/mongo 172.31.140.157:26000

    config = {
        _id : "config_repl_set",
         members : [
             {_id : 0, host : "172.31.140.157:26100" },
             {_id : 1, host : "172.31.140.158:26100" },
             {_id : 2, host : "172.31.140.159:26100" }
         ]
     }
    
    rs.initiate(config)

    初始化shard副本集,以shard1为例:

    /root/data/soft/mongodb4.4/mongodb-linux-x86_64-enterprise-rhel70-4.4.2/bin/mongo 172.31.140.157:26001

    config = {
        _id : "shard1_repl_set",
         members : [
             {_id : 0, host : "172.31.140.157:26101" },
             {_id : 1, host : "172.31.140.158:26101" },
             {_id : 2, host : "172.31.140.159:26101" }
         ]
     }
    
    rs.initiate(config)

    添加分片:

    /root/data/soft/mongodb4.4/mongodb-linux-x86_64-enterprise-rhel70-4.4.2/bin/mongo 127.0.0.1:26000

    sh.status()
    
    sh.addShard("shard1_repl_set/172.31.140.157:26101,172.31.140.158:26101,172.31.140.159:26101")
    
    sh.addShard("shard2_repl_set/172.31.140.157:26102,172.31.140.158:26102,172.31.140.159:26102")
    
    sh.addShard("shard3_repl_set/172.31.140.157:26103,172.31.140.158:26103,172.31.140.159:26103")

     

  • 相关阅读:
    《学习之道》第二章学习方法7看视频
    《学习之道》第二章学习6阅读书籍
    反射详解一
    spring 初始化和销毁的三种方法
    文件读取
    JdbcTemplate 详解二
    JdbcTemplate 详解一
    JdbcTemplate 详解三
    常用commons 工具类依赖配置
    java 8 stream
  • 原文地址:https://www.cnblogs.com/xingchong/p/14102576.html
Copyright © 2020-2023  润新知