IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 大数据 -> Mongodb 的副本集(Replica Set)部署与配置 -> 正文阅读

[大数据]Mongodb 的副本集(Replica Set)部署与配置

前言

本文章主要介绍了 MongoDB 5.0 副本集的部署与配置,基于上一篇 MongoDB CentOS 7 安装部署

主从复制和副本集区别

主从集群和副本集最大的区别就是副本集没有固定的主节点;整个集群会选出一个主节点,当其挂掉后,又在剩下的从节点中选中其他节点为主节点,副本集总有一个主节点和一个或多个备份节点

副本集配置

架构

一主一副本一仲裁

角色ipport
Primary192.168.1.14227017
Secondary192.168.1.14327017
Arbiter192.168.1.14427017

系统配置

  1. 设置主机名
hostnamectl  set-hostname node1
  1. 在 /etc/hosts (主机名查询静态表)配置主机名与ip映射关系
vi /etc/hosts
192.168.1.142 node1
192.168.1.143 node2
192.168.1.144 node3

注意事项

  1. 副本集的集合名 replSetName 必须是相同的 这里统一为 rs
  2. 机器的防火墙要么关闭,要么将相应的端口开放

创建节点

新增修改配置文件 mongodb.conf

systemLog:
 #MongoDB发送所有日志输出的目标指定为文件
 destination: file
 #mongod或mongos应向其发送所有诊断日志记录信息的日志文件的路径
 path: "/usr/local/mongodb-5.0.2/log/mongodb.log"
 #当mongos或mongod实例重新启动时,mongos或mongod会将新条目附加到现有日志文件的末尾。
 logAppend: true
storage:
 #mongod实例存储其数据的目录。storage.dbPath设置仅适用于mongod。
 dbPath: "/usr/local/mongodb-5.0.2/data"
 journal:
   #启用或禁用持久性日志以确保数据文件保持有效和可恢复。
   enabled: true
processManagement:
 #启用在后台运行mongos或mongod进程的守护进程模式。
 fork: true
 #指定用于保存mongos或mongod进程的进程ID的文件位置,其中mongos或mongod将写入其PID
 pidFilePath: "/usr/local/mongodb-5.0.2/run/mongod.pid"
net:
 #服务实例绑定所有IP,有副作用,副本集初始化的时候,节点名字会自动设置为本地域名,而不是ip
 #bindIpAll: true
 #服务实例绑定的IP
 bindIp: 0.0.0.0
 #绑定的端口
 port: 27017
replication:
 #副本集的名称
 replSetName: rs

三台服务相同即可

启动节点服务

/usr/local/mongodb-5.0.2/bin/mongod -f /usr/local/mongodb-5.0.2/conf/mongodb.conf
[root@localhost /]# /usr/local/mongodb-5.0.2/bin/mongod -f /usr/local/mongodb-5.0.2/conf/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 38140
child process started successfully, parent exiting

三个节点以同样的方式启动即可

初始化配置副本集和主节点

使用客户端命令连接主节点

/usr/local/mongodb-5.0.2/bin/mongo --port 27017

准备初始化新的副本集

语法

rs.initiate(configuration)
ParameterTypeDescription
configurationdocumentOptional. A document that specifies configuration for the new replica set. If a configuration is not specified, MongoDB uses a default replica set configuration.

使用默认的配置初始化副本集

rs.initiate()
> rs.initiate()
{
        "info2" : "no configuration specified. Using a default configuration for the set",
        "me" : "node1:27017",
        "ok" : 1
}
rs:SECONDARY>
rs:PRIMARY>

说明:
1)“ok” 的值为 1,说明创建成功。
2)“me” 的值便是当前的 主机名+端口
3)命令行提示符发生变化,变成了一个从节点角色,此时默认不能读写。稍等片刻,回车,变成主节点

查看副本集的配置内容

返回包含当前副本集配置的文档

rs.conf(configuration)

rs.config() 是该方法的别名。
configuration:可选,如果没有配置,则使用默认主节点配置。

rs:PRIMARY> rs.conf()
{
        "_id" : "rs",
        "version" : 1,
        "term" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "host" : "node1:27017",
                        "arbiterOnly" : false,
                        "buildIndexes" : true,
                        "hidden" : false,
                        "priority" : 1,
                        "tags" : {

                        },
                        "secondaryDelaySecs" : NumberLong(0),
                        "votes" : 1
                }
        ],
        "protocolVersion" : NumberLong(1),
        "writeConcernMajorityJournalDefault" : true,
        "settings" : {
                "chainingAllowed" : true,
                "heartbeatIntervalMillis" : 2000,
                "heartbeatTimeoutSecs" : 10,
                "electionTimeoutMillis" : 10000,
                "catchUpTimeoutMillis" : -1,
                "catchUpTakeoverDelayMillis" : 30000,
                "getLastErrorModes" : {

                },
                "getLastErrorDefaults" : {
                        "w" : 1,
                        "wtimeout" : 0
                },
                "replicaSetId" : ObjectId("614585a268fddfacd19367d0")
        }
}

说明:
1) “_id” : “rs” :副本集的配置数据存储的主键值,默认就是副本集的名字
2) “members” :副本集成员数组,此时只有一个: “host” : “node1:27017” ,该成员不是仲裁节点: “arbiterOnly” : false ,优先级(权重值): “priority” : 1,
3) “settings” :副本集的参数配置。

【提示】
副本集配置的查看命令,本质是查询的是 system.replset 的表中的数据

master:PRIMARY> use local
switched to db local
master:PRIMARY> show collections
oplog.rs
replset.election
replset.initialSyncId
replset.minvalid
replset.oplogTruncateAfterPoint
startup_log
system.replset
system.rollback.id
system.tenantMigration.oplogView
system.views
master:PRIMARY> db.system.replset.find()
{ "_id" : "master", "version" : 1, "term" : 1, "members" : [ { "_id" : 0, "host" : "localhost.localdomain:27017", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 1, "tags" : {  }, "secondaryDelaySecs" : NumberLong(0), "votes" : 1 } ], "protocolVersion" : NumberLong(1), "writeConcernMajorityJournalDefault" : true, "settings" : { "chainingAllowed" : true, "heartbeatIntervalMillis" : 2000, "heartbeatTimeoutSecs" : 10, "electionTimeoutMillis" : 10000, "catchUpTimeoutMillis" : -1, "catchUpTakeoverDelayMillis" : 30000, "getLastErrorModes" : {  }, "getLastErrorDefaults" : { "w" : 1, "wtimeout" : 0 }, "replicaSetId" : ObjectId("614486497c0afbdf3172ebfe") } }

查看副本集状态

检查副本集状态
说明:
返回包含状态信息的文档。此输出使用从副本集的其他成员发送的心跳包中获得的数据反映副本集的当
前状态。
语法:

rs.status()
rs:PRIMARY> rs.status()
{
        "set" : "rs",
        "date" : ISODate("2021-09-18T06:27:46.387Z"),
        "myState" : 1,
        "term" : NumberLong(1),
        "syncSourceHost" : "",
        "syncSourceId" : -1,
        "heartbeatIntervalMillis" : NumberLong(2000),
        "majorityVoteCount" : 1,
        "writeMajorityCount" : 1,
        "votingMembersCount" : 1,
        "writableVotingMembersCount" : 1,
        "optimes" : {
                "lastCommittedOpTime" : {
                        "ts" : Timestamp(1631946456, 1),
                        "t" : NumberLong(1)
                },
                "lastCommittedWallTime" : ISODate("2021-09-18T06:27:36.551Z"),
                "readConcernMajorityOpTime" : {
                        "ts" : Timestamp(1631946456, 1),
                        "t" : NumberLong(1)
                },
                "appliedOpTime" : {
                        "ts" : Timestamp(1631946456, 1),
                        "t" : NumberLong(1)
                },
                "durableOpTime" : {
                        "ts" : Timestamp(1631946456, 1),
                        "t" : NumberLong(1)
                },
                "lastAppliedWallTime" : ISODate("2021-09-18T06:27:36.551Z"),
                "lastDurableWallTime" : ISODate("2021-09-18T06:27:36.551Z")
        },
        "lastStableRecoveryTimestamp" : Timestamp(1631946436, 1),
        "electionCandidateMetrics" : {
                "lastElectionReason" : "electionTimeout",
                "lastElectionDate" : ISODate("2021-09-18T06:22:26.463Z"),
                "electionTerm" : NumberLong(1),
                "lastCommittedOpTimeAtElection" : {
                        "ts" : Timestamp(0, 0),
                        "t" : NumberLong(-1)
                },
                "lastSeenOpTimeAtElection" : {
                        "ts" : Timestamp(1631946146, 1),
                        "t" : NumberLong(-1)
                },
                "numVotesNeeded" : 1,
                "priorityAtElection" : 1,
                "electionTimeoutMillis" : NumberLong(10000),
                "newTermStartDate" : ISODate("2021-09-18T06:22:26.470Z"),
                "wMajorityWriteAvailabilityDate" : ISODate("2021-09-18T06:22:26.476Z")
        },
        "members" : [
                {
                        "_id" : 0,
                        "name" : "node1:27017",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 388,
                        "optime" : {
                                "ts" : Timestamp(1631946456, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDate" : ISODate("2021-09-18T06:27:36Z"),
                        "syncSourceHost" : "",
                        "syncSourceId" : -1,
                        "infoMessage" : "",
                        "electionTime" : Timestamp(1631946146, 2),
                        "electionDate" : ISODate("2021-09-18T06:22:26Z"),
                        "configVersion" : 1,
                        "configTerm" : 1,
                        "self" : true,
                        "lastHeartbeatMessage" : ""
                }
        ],
        "ok" : 1,
        "$clusterTime" : {
                "clusterTime" : Timestamp(1631946456, 1),
                "signature" : {
                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                        "keyId" : NumberLong(0)
                }
        },
        "operationTime" : Timestamp(1631946456, 1)
}

说明:
1) “set” : “rs” :副本集的名字
2) “myState” : 1:说明状态正常
3) “members” :副本集成员数组,此时只有一个: “name” : “node1:27017” ,该成员的角色是 “stateStr” : “PRIMARY”, 该节点是健康的: “health” : 1

添加副本从节点

在主节点添加从节点,将其他成员加入到副本集
语法:

rs.add(host, arbiterOnly)
ParameterTypeDescription
hoststring or document要添加到副本集的新成员。 指定为字符串或配置文档:1)如 果是一个字符串,则需要指定新成员的主机名和可选的端口 号;2)如果是一个文档,请指定在members数组中找到的副 本集成员配置文档。 您必须在成员配置文档中指定主机字段。 有关文档配置字段的说明,详见下方文档:“主机成员的配置文档”
arbiterOnlyboolean可选的。 仅在 值为字符串时适用。 如果为true,则添加的主机是仲裁者。

【示例】
将 192.168.1.143 的副本节点添加到副本集中

rs:PRIMARY> rs.add("node2:27017")
{
        "ok" : 1,
        "$clusterTime" : {
                "clusterTime" : Timestamp(1631948744, 1),
                "signature" : {
                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                        "keyId" : NumberLong(0)
                }
        },
        "operationTime" : Timestamp(1631948744, 1)
}

说明:
ok : 1 说明添加成功 但并不代表指定的副本节点已经正常添加到副本集中

查看副本集状态

rs:PRIMARY> rs.status()
{
        "set" : "rs",
        "date" : ISODate("2021-09-18T08:03:52.132Z"),
        "myState" : 1,
        "term" : NumberLong(1),
        "syncSourceHost" : "",
        "syncSourceId" : -1,
        "heartbeatIntervalMillis" : NumberLong(2000),
        "majorityVoteCount" : 2,
        "writeMajorityCount" : 2,
        "votingMembersCount" : 2,
        "writableVotingMembersCount" : 2,
        "optimes" : {
                "lastCommittedOpTime" : {
                        "ts" : Timestamp(1631952227, 1),
                        "t" : NumberLong(1)
                },
                "lastCommittedWallTime" : ISODate("2021-09-18T08:03:47.058Z"),
                "readConcernMajorityOpTime" : {
                        "ts" : Timestamp(1631952227, 1),
                        "t" : NumberLong(1)
                },
                "appliedOpTime" : {
                        "ts" : Timestamp(1631952227, 1),
                        "t" : NumberLong(1)
                },
                "durableOpTime" : {
                        "ts" : Timestamp(1631952227, 1),
                        "t" : NumberLong(1)
                },
                "lastAppliedWallTime" : ISODate("2021-09-18T08:03:47.058Z"),
                "lastDurableWallTime" : ISODate("2021-09-18T08:03:47.058Z")
        },
        "lastStableRecoveryTimestamp" : Timestamp(1631952207, 1),
        "electionCandidateMetrics" : {
                "lastElectionReason" : "electionTimeout",
                "lastElectionDate" : ISODate("2021-09-18T06:22:26.463Z"),
                "electionTerm" : NumberLong(1),
                "lastCommittedOpTimeAtElection" : {
                        "ts" : Timestamp(0, 0),
                        "t" : NumberLong(-1)
                },
                "lastSeenOpTimeAtElection" : {
                        "ts" : Timestamp(1631946146, 1),
                        "t" : NumberLong(-1)
                },
                "numVotesNeeded" : 1,
                "priorityAtElection" : 1,
                "electionTimeoutMillis" : NumberLong(10000),
                "newTermStartDate" : ISODate("2021-09-18T06:22:26.470Z"),
                "wMajorityWriteAvailabilityDate" : ISODate("2021-09-18T06:22:26.476Z")
        },
        "members" : [
                {
                        "_id" : 0,
                        "name" : "node1:27017",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 6154,
                        "optime" : {
                                "ts" : Timestamp(1631952227, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDate" : ISODate("2021-09-18T08:03:47Z"),
                        "syncSourceHost" : "",
                        "syncSourceId" : -1,
                        "infoMessage" : "",
                        "electionTime" : Timestamp(1631946146, 2),
                        "electionDate" : ISODate("2021-09-18T06:22:26Z"),
                        "configVersion" : 15,
                        "configTerm" : 1,
                        "self" : true,
                        "lastHeartbeatMessage" : ""
                },
                {
                        "_id" : 1,
                        "name" : "node2:27017",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 667,
                        "optime" : {
                                "ts" : Timestamp(1631952227, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDurable" : {
                                "ts" : Timestamp(1631952227, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDate" : ISODate("2021-09-18T08:03:47Z"),
                        "optimeDurableDate" : ISODate("2021-09-18T08:03:47Z"),
                        "lastHeartbeat" : ISODate("2021-09-18T08:03:50.682Z"),
                        "lastHeartbeatRecv" : ISODate("2021-09-18T08:03:51.135Z"),
                        "pingMs" : NumberLong(0),
                        "lastHeartbeatMessage" : "",
                        "syncSourceHost" : "node1:27017",
                        "syncSourceId" : 0,
                        "infoMessage" : "",
                        "configVersion" : 15,
                        "configTerm" : 1
                }
        ],
        "ok" : 1,
        "$clusterTime" : {
                "clusterTime" : Timestamp(1631952227, 1),
                "signature" : {
                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                        "keyId" : NumberLong(0)
                }
        },
        "operationTime" : Timestamp(1631952227, 1)
}

可以看到 members 数组 变成了 两位
【注意】
若 optimeDate optimeDurableDate lastHeartbeatRecv 是 1970 的 则是因为 从服务器 无法连通主服务器
我这边地原因是 vi /etc/hosts 第一次只是配置的本机的 主机名和 ip ,将三个节点全部添加是即可解决

若 stateStr 的 值 没有 变为 SECONDARY 也是节点之间网络环境的问题

更多副本集命令

rs:PRIMARY> rs.help()
        rs.status()                                     { replSetGetStatus : 1 } checks repl set status
        rs.initiate()                                   { replSetInitiate : null } initiates set with default settings
        rs.initiate(cfg)                                { replSetInitiate : cfg } initiates set with configuration cfg
        rs.conf()                                       get the current configuration object from local.system.replset
        rs.reconfig(cfg, opts)                          updates the configuration of a running replica set with cfg, using the given opts (disconnects)
        rs.reconfigForPSASet(memberIndex, cfg, opts)    updates the configuration of a Primary-Secondary-Arbiter (PSA) replica set while preserving majority writes
                                                            memberIndex: index of the node being updated; cfg: the desired new config; opts: options passed in with the reconfig
                                                            Not to be used with every configuration
        rs.add(hostportstr)                             add a new member to the set with default attributes (disconnects)
        rs.add(membercfgobj)                            add a new member to the set with extra attributes (disconnects)
        rs.addArb(hostportstr)                          add a new member which is arbiterOnly:true (disconnects)
        rs.stepDown([stepdownSecs, catchUpSecs])        step down as primary (disconnects)
        rs.syncFrom(hostportstr)                        make a secondary sync from the given member
        rs.freeze(secs)                                 make a node ineligible to become primary for the time specified
        rs.remove(hostportstr)                          remove a host from the replica set (disconnects)
        rs.secondaryOk()                                allow queries on secondary nodes

        rs.printReplicationInfo()                       check oplog size and time range
        rs.printSecondaryReplicationInfo()              check replica set members and replication lag
        db.isMaster()                                   check who is primary
        db.hello()                                      check who is primary

        reconfiguration helpers disconnect from the database so the shell will display
        an error, even if the command succeeds.

添加仲裁节点

rs.addArb("node3:27017")

添加仲裁节点一直无响应,很长时间后返回错误信息
“errmsg” : “Reconfig attempted to install a config that would change the implicit default write concern. Use the setDefaultRWConcern command to set a cluster-wide write concern and try the reconfig again.”

rs:PRIMARY> rs.addArb("node3:27017")
assert.soon failed: function() {
        var cfg = hostport;

        var local = db.getSiblingDB("local");
        assert(local.system.replset.count() <= 1,
               "error: local.system.replset has unexpected contents");
        var c = local.system.replset.findOne();
        assert(c, "no config object retrievable from local.system.replset");

        const attemptedVersion = c.version++;

        var max = 0;
        for (var i in c.members) {
            // Omit 'newlyAdded' field if it exists in the config.
            delete c.members[i].newlyAdded;
            if (c.members[i]._id > max)
                max = c.members[i]._id;
        }
        if (isString(hostport)) {
            cfg = {_id: max + 1, host: hostport};
            if (arb)
                cfg.arbiterOnly = true;
        } else if (arb == true) {
            throw Error(
                "Expected first parameter to be a host-and-port string of arbiter, but got " +
                tojson(hostport));
        }

        if (cfg._id == null) {
            cfg._id = max + 1;
        }
        c.members.push(cfg);

        res = self._runCmd({replSetReconfig: c});
        if (res === "") {
            // _runCmd caught an exception.
            return true;
        }
        if (res.ok) {
            return true;
        }
        if (res.code === ErrorCodes.ConfigurationInProgress ||
            res.code === ErrorCodes.CurrentConfigNotCommittedYet) {
            return false;  // keep retrying
        }
        if (res.code === ErrorCodes.NewReplicaSetConfigurationIncompatible) {
            // We will retry only if this error was due to our config version being too low.
            const cfgState = local.system.replset.findOne();
            if (cfgState.version >= attemptedVersion) {
                return false;  // keep retrying
            }
        }
        // Take no action on other errors.
        return true;
    } : {
        "ok" : 0,
        "errmsg" : "Reconfig attempted to install a config that would change the implicit default write concern. Use the setDefaultRWConcern command to set a cluster-wide write concern and try the reconfig again.",
        "code" : 103,
        "codeName" : "NewReplicaSetConfigurationIncompatible",
        "$clusterTime" : {
                "clusterTime" : Timestamp(1631968111, 1),
                "signature" : {
                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                        "keyId" : NumberLong(0)
                }
        },
        "operationTime" : Timestamp(1631968111, 1)
} The hang analyzer is automatically called in assert.soon functions. If you are *expecting* assert.soon to possibly fail, call assert.soon with {runHangAnalyzer: false} as the fifth argument (you can fill unused arguments with `undefined`). Running hang analyzer from assert.soon.
Skipping runHangAnalyzer: no TestData (not running from resmoke)
Error: assert.soon failed: function() {
        var cfg = hostport;

        var local = db.getSiblingDB("local");
        assert(local.system.replset.count() <= 1,
               "error: local.system.replset has unexpected contents");
        var c = local.system.replset.findOne();
        assert(c, "no config object retrievable from local.system.replset");

        const attemptedVersion = c.version++;

        var max = 0;
        for (var i in c.members) {
            // Omit 'newlyAdded' field if it exists in the config.
            delete c.members[i].newlyAdded;
            if (c.members[i]._id > max)
                max = c.members[i]._id;
        }
        if (isString(hostport)) {
            cfg = {_id: max + 1, host: hostport};
            if (arb)
                cfg.arbiterOnly = true;
        } else if (arb == true) {
            throw Error(
                "Expected first parameter to be a host-and-port string of arbiter, but got " +
                tojson(hostport));
        }

        if (cfg._id == null) {
            cfg._id = max + 1;
        }
        c.members.push(cfg);

        res = self._runCmd({replSetReconfig: c});
        if (res === "") {
            // _runCmd caught an exception.
            return true;
        }
        if (res.ok) {
            return true;
        }
        if (res.code === ErrorCodes.ConfigurationInProgress ||
            res.code === ErrorCodes.CurrentConfigNotCommittedYet) {
            return false;  // keep retrying
        }
        if (res.code === ErrorCodes.NewReplicaSetConfigurationIncompatible) {
            // We will retry only if this error was due to our config version being too low.
            const cfgState = local.system.replset.findOne();
            if (cfgState.version >= attemptedVersion) {
                return false;  // keep retrying
            }
        }
        // Take no action on other errors.
        return true;
    } : {
        "ok" : 0,
        "errmsg" : "Reconfig attempted to install a config that would change the implicit default write concern. Use the setDefaultRWConcern command to set a cluster-wide write concern and try the reconfig again.",
        "code" : 103,
        "codeName" : "NewReplicaSetConfigurationIncompatible",
        "$clusterTime" : {
                "clusterTime" : Timestamp(1631968111, 1),
                "signature" : {
                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                        "keyId" : NumberLong(0)
                }
        },
        "operationTime" : Timestamp(1631968111, 1)
} The hang analyzer is automatically called in assert.soon functions. If you are *expecting* assert.soon to possibly fail, call assert.soon with {runHangAnalyzer: false} as the fifth argument (you can fill unused arguments with `undefined`). :
doassert@src/mongo/shell/assert.js:20:14
assert.soon@src/mongo/shell/assert.js:382:17
rs.add@src/mongo/shell/utils.js:1626:5
rs.addArb@src/mongo/shell/utils.js:1698:12
@(shell):1:1

解决办法 在 主节点 设置

db.adminCommand({
  "setDefaultRWConcern" : 1,
  "defaultWriteConcern" : {
    "w" : 2
  }
})

参考地址 MongoDB 官网
解决无法添加仲裁节点
天宇轩-王

  大数据 最新文章
实现Kafka至少消费一次
亚马逊云科技:还在苦于ETL?Zero ETL的时代
初探MapReduce
【SpringBoot框架篇】32.基于注解+redis实现
Elasticsearch:如何减少 Elasticsearch 集
Go redis操作
Redis面试题
专题五 Redis高并发场景
基于GBase8s和Calcite的多数据源查询
Redis——底层数据结构原理
上一篇文章      下一篇文章      查看所有文章
加:2021-09-19 08:02:49  更:2021-09-19 08:04:53 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/23 20:08:24-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码