zoukankan      html  css  js  c++  java
  • MongoDB主备 版本3.6.5

    主数据库的启动配置文件
      dbpath = /usr/local/mongodata/data
      logpath = /usr/local/mongodata/logs/mongo.log
      logappend = true
      master=true #设置为主库
      oplogSize=2048 #同步复制的日志大小设置,单位MB
      keyFile = /usr/local/mongodata/mongodb-keyfile #当 auth = true时,设置私钥
      journal = true
      quiet = true
      fork = true
      port = 27017
      auth = true
      bind_ip = 0.0.0.0

    从数据库的启动配置文件
      dbpath = /usr/local/mongodata/data
      logpath = /usr/local/mongodata/logs/mongo.log
      logappend = true
      journal = true
      quiet = true
      slave = true #设置从库
      source = 172.16.254.129:27017 #设置主数据库来源
      keyFile = /usr/local/mongodata/mongodb-keyfile #当 auth = true时,设置私钥
      slavedelay = 10
      fork = true
      port = 27017
      auth = true
      bind_ip = 0.0.0.0
    注意:

      1.如果使用认证的方式启动服务(auth = true),那么要在主从服务器配置私钥。

        // 在一台服务器上生成私钥
        openssl rand -base64 745 > mongodb-keyfile

        // 修改私钥的权限为可读写
        chmod 600 mongodb-keyfile
        // 将私钥拷贝到其余的服务器上
        scp mongodb-keyfile root@xxx.xxx.xxx.xxx:/usr/local/mongodb/
      2.MongoDB 4.0以后的版本主备不能以该方式进行配置,因为4.0版本后不支持master/slave模式。

  • 相关阅读:
    神经网络(2)---neurons and the brain
    P2P system:How Chord tackles failures
    如何成为更好的自己
    P2P system: Chord
    P2P system: FastTrack and BitTorrent
    P2P system: GNUTELLA
    P2P system: Napster
    P2P system: Introduction
    幸福公开课(2)
    MTV与MVC 多对多表的创建方式 前后端传输数据编码格式 ajax 批量插入数据 自定义分页器
  • 原文地址:https://www.cnblogs.com/pig1314/p/11534464.html
Copyright © 2011-2022 走看看