千家信息网

MongoDB中怎么修复config配置节点

发表于:2025-11-22 作者:千家信息网编辑
千家信息网最后更新 2025年11月22日,这期内容当中小编将会给大家带来有关MongoDB中怎么修复config配置节点,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。修复流程如下:# 登录到config库,
千家信息网最后更新 2025年11月22日MongoDB中怎么修复config配置节点

这期内容当中小编将会给大家带来有关MongoDB中怎么修复config配置节点,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

修复流程如下:

  1. # 登录到config库,查看config的节点状态

  2. # 可以看到_id为2的节点状态是不可访问的


  3. [root@mongos-mq ~]# /opt/mongodb-linux-x86_64-3.2.10/bin/mongo --port 10000MongoDB shell version: 3.2.10connecting to: 127.0.0.1:10000/testconfig_rs:PRIMARY> use adminswitched to db adminconfig_rs:PRIMARY> db.auth("root", "xxx")1config_rs:PRIMARY> rs.status(){    "set" : "config_rs",    "date" : ISODate("2018-05-30T04:53:21.081Z"),    "myState" : 1,    "term" : NumberLong(1),    "configsvr" : true,    "heartbeatIntervalMillis" : NumberLong(2000),    "members" : [        {            "_id" : 0,            "name" : "192.168.210.208:10000",            "health" : 1,            "state" : 1,            "stateStr" : "PRIMARY",            "uptime" : 1112804,            "optime" : {                "ts" : Timestamp(1527656000, 1),                "t" : NumberLong(1)            },            "optimeDate" : ISODate("2018-05-30T04:53:20Z"),            "electionTime" : Timestamp(1526543249, 2),            "electionDate" : ISODate("2018-05-17T07:47:29Z"),            "configVersion" : 3,            "self" : true        },        {            "_id" : 1,            "name" : "192.168.210.209:10000",            "health" : 1,            "state" : 2,            "stateStr" : "SECONDARY",            "uptime" : 1111358,            "optime" : {                "ts" : Timestamp(1527656000, 1),                "t" : NumberLong(1)            },            "optimeDate" : ISODate("2018-05-30T04:53:20Z"),            "lastHeartbeat" : ISODate("2018-05-30T04:53:20.836Z"),            "lastHeartbeatRecv" : ISODate("2018-05-30T04:53:19.329Z"),            "pingMs" : NumberLong(0),            "syncingTo" : "192.168.210.208:10000",            "configVersion" : 3        },        {            "_id" : 2,            "name" : "192.168.210.207:10000",            "health" : 0,            "state" : 8,            "stateStr" : "(not reachable/healthy)",            "uptime" : 0,            "optime" : {                "ts" : Timestamp(0, 0),                "t" : NumberLong(-1)            },            "optimeDate" : ISODate("1970-01-01T00:00:00Z"),            "lastHeartbeat" : ISODate("2018-05-30T04:53:20.850Z"),            "lastHeartbeatRecv" : ISODate("2018-05-26T09:07:27.318Z"),            "pingMs" : NumberLong(0),            "lastHeartbeatMessage" : "Connection refused",            "configVersion" : -1        }    ],    "ok" : 1}# 在故障节点上面重新安装MongoDB,创建数据文件目录[root@tomcat-207 opt]# tar xfz mongodb-linux-x86_64-3.2.10.tgz[root@tomcat-207 opt]# mkdir -p /data/mongodb_data/config_rs1_10000# 配置参数文件[root@tomcat-207 opt]# cat /etc/mongodb/config_rs1_10000.conf systemLog:    destination: file    path: /data/mongodb_data/config_rs1_10000/mongod.logprocessManagement:    fork: truenet:    bindIp: 0.0.0.0    port: 10000security:    keyFile: /data/mongodb_data/keyfilestorage:    dbPath: /data/mongodb_data/config_rs1_10000    directoryPerDB: trueoperationProfiling:    slowOpThresholdMs: 100    mode: slowOpreplication:    replSetName: config_rssharding:    clusterRole: configsvr# 从其他config节点拷贝过来keyfile文件[root@mongos-mq opt]# scp /data/mongodb_data/keyfile root@192.168.210.207:/data/mongodb_data/# 启动Mongo[root@mongos-mq opt]# /opt/mongodb-linux-x86_64-3.2.10/bin/mongod -f /etc/mongodb/config_rs1_10000.conf about to fork child process, waiting until server is ready for connections.forked process: 3744child process started successfully, parent exiting# 查看config节点状态# 所有的config节点都恢复正常config_rs:PRIMARY> rs.status(){    "set" : "config_rs",    "date" : ISODate("2018-05-30T05:29:40.103Z"),    "myState" : 1,    "term" : NumberLong(1),    "configsvr" : true,    "heartbeatIntervalMillis" : NumberLong(2000),    "members" : [        {            "_id" : 0,            "name" : "192.168.210.208:10000",            "health" : 1,            "state" : 1,            "stateStr" : "PRIMARY",            "uptime" : 1114983,            "optime" : {                "ts" : Timestamp(1527658178, 4),                "t" : NumberLong(1)            },            "optimeDate" : ISODate("2018-05-30T05:29:38Z"),            "electionTime" : Timestamp(1526543249, 2),            "electionDate" : ISODate("2018-05-17T07:47:29Z"),            "configVersion" : 3,            "self" : true        },        {            "_id" : 1,            "name" : "192.168.210.209:10000",            "health" : 1,            "state" : 2,            "stateStr" : "SECONDARY",            "uptime" : 1113537,            "optime" : {                "ts" : Timestamp(1527658178, 4),                "t" : NumberLong(1)            },            "optimeDate" : ISODate("2018-05-30T05:29:38Z"),            "lastHeartbeat" : ISODate("2018-05-30T05:29:39.535Z"),            "lastHeartbeatRecv" : ISODate("2018-05-30T05:29:39.941Z"),            "pingMs" : NumberLong(0),            "syncingTo" : "192.168.210.208:10000",            "configVersion" : 3        },        {            "_id" : 2,            "name" : "192.168.210.207:10000",            "health" : 1,            "state" : 2,            "stateStr" : "SECONDARY",            "uptime" : 1588,            "optime" : {                "ts" : Timestamp(1527658178, 4),                "t" : NumberLong(1)            },            "optimeDate" : ISODate("2018-05-30T05:29:38Z"),            "lastHeartbeat" : ISODate("2018-05-30T05:29:39.535Z"),            "lastHeartbeatRecv" : ISODate("2018-05-30T05:29:39.691Z"),            "pingMs" : NumberLong(0),            "syncingTo" : "192.168.210.209:10000",            "configVersion" : 3        }    ],    "ok" : 1}

上述就是小编为大家分享的MongoDB中怎么修复config配置节点了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注行业资讯频道。

0