如何允许所有主机到 mongodb 中的副本集 [英] How to allow all hosts to a replica set in mongodb

查看:63
本文介绍了如何允许所有主机到 mongodb 中的副本集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我像这样从本地机器连接我的副本集时

When I am connecting my replica set from local machine like this

"mongodb://my_server_ip:27018/?readPreference=secondary&replicaSet=rs0&appname=MongoDB%20Compass&ssl=false"

它给了我一个错误 无法访问任何服务器" 和 mongo compass connect ECONNREFUSED 127.0.0.1:27018"

It gives me an error "Could not reach any servers" and on mongo compass "connect ECONNREFUSED 127.0.0.1:27018"

我认为这个错误来自副本集配置,其中主机密钥是 "localhost:27018"

I think this error comes from replica set configs, where host key is "localhost:27018"

以下是副本集成员信息:

Below is the replica set member info:

{
    "_id": 1,
    "host": "localhost:27018",
    "arbiterOnly": false,
    "buildIndexes": true,
    "hidden": false,
    "priority": 1,
    "tags": {

    },
    "slaveDelay": NumberLong(0),
    "votes": 1
}

如何允许所有主机访问此副本?

How to allow all hosts to this replica?

推荐答案

副本集必须配置有可从 RS 节点和客户端访问的主机地址.

Replica set must be configured with host addresses that are accessible from both RS nodes and the clients.

对于通过网络使用的 RS,这意味着主机节点的公共主机名/IP 地址,而不是环回地址.

For an RS used over the network, this means public hostnames/IP addresses of the host nodes rather than loopback addresses.

这篇关于如何允许所有主机到 mongodb 中的副本集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆