rs.addArb()

On this page本页内容

Description描述

rs.addArb(host)

Adds a new arbiter to an existing replica set.将新仲裁器添加到现有副本集。

rs.add(<host>, true) is functionally the same as rs.addArb(<host>). 在功能上与rs.addArb(<host>)相同。You can use these commands interchangeably.您可以互换使用这些命令。

Warning警告

Avoid deploying more than one arbiter in a replica set. 避免在副本集中部署多个仲裁器See Concerns with Multiple Arbiters.请参见关注多个仲裁器

To add an arbiter to an existing replica set:要向现有副本集添加仲裁器,请执行以下操作:

You do not need to change the cluster wide write concern before starting a new replica set with an arbiter.在使用仲裁器启动新的副本集之前,无需更改群集范围的写入问题。

The rs.addArb() method takes the following parameter:rs.addArb()方法采用以下参数:

Parameter参数Type类型Description描述
hoststringSpecifies the hostname and optionally the port number of the arbiter member to add to replica set. 指定要添加到副本集的仲裁器成员的主机名和端口号(可选)。

For the following MongoDB versions, pv1 increases the likelihood of w:1 rollbacks compared to pv0(no longer supported in MongoDB 4.0+) for replica sets with arbiters:对于以下MongoDB版本,与带有仲裁器的副本集的pv0(MongoDB 4.0+不再支持)相比,pv1增加了w:1回滚的可能性:

  • MongoDB 3.4.1
  • MongoDB 3.4.0
  • MongoDB 3.2.11 or earlier

See Replica Set Protocol Version.请参见副本集协议版本

IP BindingIP绑定

Warning警告

Before binding to a non-localhost (e.g. publicly accessible) IP address, ensure you have secured your cluster from unauthorized access. 在绑定到非本地主机(例如,可公开访问的)IP地址之前,请确保已保护您的集群免受未经授权的访问。For a complete list of security recommendations, see Security Checklist. 有关安全建议的完整列表,请参阅安全检查表At minimum, consider enabling authentication and hardening network infrastructure.至少要考虑启用身份验证加强网络基础设施

MongoDB binaries, mongod and mongos, bind to localhost by default. MongoDB二进制文件mongodmongos默认绑定到localhost。If the net.ipv6 configuration file setting or the --ipv6 command line option is set for the binary, the binary additionally binds to the localhost IPv6 address.如果为二进制文件设置了net.ipv6配置文件设置或--ipv6命令行选项,则该二进制文件还将绑定到本地主机ipv6地址。

By default mongod and mongos that are bound to localhost only accept connections from clients that are running on the same computer. 默认情况下,绑定到localhost的mongodmongos只接受来自同一台计算机上运行的客户端的连接。This binding behavior includes mongosh and other members of your replica set or sharded cluster. 这种绑定行为包括mongosh和复制集或分片集群的其他成员。Remote clients cannot connect to binaries that are bound only to localhost.远程客户端无法连接到仅绑定到localhost的二进制文件。

To override the default binding and bind to other IP addresses, use the net.bindIp configuration file setting or the --bind_ip command-line option to specify a list of hostnames or IP addresses.要覆盖默认绑定并绑定到其他IP地址,请使用net.bindIp配置文件设置或--bind_ip命令行选项指定主机名或IP地址列表。

Warning警告

Starting in MongDB 5.0, split horizon DNS nodes that are only configured with an IP address fail startup validation and report an error. 从MongDB 5.0开始,仅配置了IP地址的拆分地平线DNS节点无法启动验证并报告错误。See disableSplitHorizonIPCheck.请参见disableSplitHorizonIPCheck

For example, the following mongod instance binds to both the localhost and the hostname My-Example-Associated-Hostname, which is associated with the IP address 198.51.100.1:例如,以下mongod实例绑定到本地主机和主机名My-Example-Associated-Hostname,该主机名与IP地址198.51.100.1关联:

mongod --bind_ip localhost,My-Example-Associated-Hostname

In order to connect to this instance, remote clients must specify the hostname or its associated IP address 198.51.100.1:为了连接到此实例,远程客户端必须指定主机名或其关联的IP地址198.51.100.1

mongosh --host My-Example-Associated-Hostname
mongosh --host 198.51.100.1
Important重要

To avoid configuration updates due to IP address changes, use DNS hostnames instead of IP addresses. 为了避免由于IP地址更改而导致的配置更新,请使用DNS主机名而不是IP地址。It is particularly important to use a DNS hostname instead of an IP address when configuring replica set members or sharded cluster members.在配置副本集成员或分片群集成员时,使用DNS主机名而不是IP地址尤为重要。

Use hostnames instead of IP addresses to configure clusters across a split network horizon. 使用主机名而不是IP地址来跨拆分的网络范围配置群集。Starting in MongDB 5.0, nodes that are only configured with an IP address will fail startup validation and will not start.从MongDB 5.0开始,仅配置IP地址的节点将无法启动验证,无法启动。

←  rs.add()rs.conf() →