zoukankan      html  css  js  c++  java
  • MongoDB的"副本“数据库服务器

    1.假设1数据库服务器为活跃服务器(主服务器),2和3为备份服务器,当1出现故障的时候,那么会在2和3中推选出一个(根据权重的等规则)作为活跃服务器,而当1又恢复正常了之后呢,它将以备份服务器的身份出现;

    2.设值数据库服务器(配置文件中要设置成闭环):

     比如设置1,2,3三个数据库的副本集群:

      数据库1:dbpath= D:/AA/AA/1

                   port= 1111 #端口号

                   bind_ip= 127.0.0.1 #服务器的IP地址

                   replSet= child/127.0.0.1:2222 #备份的服务器同伴

      位于1.conf配置文件中;

      

      数据库2:dbpath= D:/AA/AA/2

                   port= 2222 #端口号

                   bind_ip= 127.0.0.1 #服务器的IP地址

                   replSet= child/127.0.0.1:3333 #备份的服务器同伴

      位于2.conf配置文件中;

      数据库3:dbpath= D:/AA/AA/3

                   port= 333 #端口号

                   bind_ip= 127.0.0.1 #服务器的IP地址

                   replSet= child/127.0.0.1:1111 #备份的服务器同伴

      位于3.conf配置文件中;

      ***然后在1,2,3对应的服务器启动的批处理文件中对应好  如1数据库启动服务器   mongod  --config 1.conf 其他的同理即可***;

      ***在shell中 如1数据库服务器直接输入:mongo 127.0.0.1:1111  其他同理即可;***

    3.想要以上配置的副本集群起作用必须执行一下命令:

       3.1 use 数据库名  输入:db.runCommand({"replSetInitiate" :

                          {

                                                                   "_id" : "child",

                               "menbers" : [{"_id" : 1, "host" : "127.0.0.1:1111"},{"_id" : 1, "host" : "127.0.0.1:2222"},{"_id" : 1, "host" : "127.0.0.1:3333"}]

                                                                 }

                          });

    4.使用 rs.status() 来查看副本集群数据库服务器的状态;

       

  • 相关阅读:
    总结(yst)
    iOS 中 OC项目使用swift第三方工具(OC、swift 混合)
    iOS Appstore 版本更新
    软件设计模式
    iOS huhuProject积累
    iOS暴力禁用navigationviewcontroller右滑手势和手势的优先级
    ios 真机调试支持包的路径
    ios 沙盒路径
    Undefined symbols for architecture x86_64 "_OBJC_CLASS_$_类名",referenced fromobjc-class in .o
    pako.js GZIP定义解压和压缩的方法
  • 原文地址:https://www.cnblogs.com/zzq-include/p/4291206.html
Copyright © 2011-2022 走看看