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.您可以互换使用这些命令。WarningAvoid deploying more than one arbiter in a replica set.避免在副本集中部署多个仲裁器。See Concerns with Multiple Arbiters.请参阅与多个仲裁器有关的问题。To add an arbiter to an existing replica set:要将仲裁器添加到现有副本集,请执行以下操作:Typically, if there are two or fewer data-bearing members in the replica set, you might need to first set the cluster wide write concern for the replica set.通常,如果副本集中有两个或更少的数据承载成员,则可能需要首先为副本集设置集群范围的写入关注。See cluster wide write concern for more information on why you might need to set the cluster wide write concern.有关为什么可能需要设置集群范围的写入关注的更多信息,请参阅集群范围的写入关注。
You do not need to change the cluster wide write concern before starting a new replica set with an arbiter.在使用仲裁器启动新的副本集之前,不需要更改集群范围内的写入关注。TipSee also:另请参阅:Thers.addArb()
method takes the following parameter:rs.addArb()
方法采用以下参数:Parameter参数Type类型Description描述host
string Specifies the hostname and optionally the port number of the arbiter member to add to replica set.指定要添加到副本集中的仲裁器成员的主机名和端口号(可选)。For the following MongoDB versions,对于以下MongoDB版本,与带有仲裁器的副本集的pv1
increases the likelihood ofw:1
rollbacks compared topv0
(no longer supported in MongoDB 4.0+) for replica sets with arbiters:pv0
(在MongoDB 4.0+中不再支持)相比,pv1
增加了w:1
回滚的可能性:- MongoDB 3.4.1
- MongoDB 3.4.0
- MongoDB 3.2.11 or earlier
IP BindingIP绑定
Before you bind your instance to a publicly-accessible IP address, you must secure 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, MongoDB二进制文件mongod
and mongos
, bind to localhost by default. mongod
和mongos
默认绑定到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
命令行选项,则二进制文件将额外绑定到localhost ipv6地址。
By default 默认情况下,绑定到localhost的mongod
and mongos
that are bound to localhost only accept connections from clients that are running on the same computer. mongod
和mongos
只接受来自在同一台计算机上运行的客户端的连接。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 要覆盖默认绑定并绑定到其他IP地址,请使用net.bindIp
configuration file setting or the --bind_ip
command-line option to specify a list of hostnames or IP addresses.net.bindIp
配置文件设置或--bind_ip
命令行选项指定主机名或IP地址列表。
Starting in MongDB 5.0, split horizon DNS从MongDB 5.0开始,仅配置有IP地址的拆分域DNS nodes that are only configured with an IP address fail startup validation and report an error.
节点无法通过启动验证并报告错误。
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
实例绑定到localhost和主机名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 为了连接到此实例,远程客户端必须指定主机名或其关联的IP地址198.51.100.1
:198.51.100.1
:
mongosh --host My-Example-Associated-Hostname
mongosh --host 198.51.100.1
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 MongoDB 5.0, nodes that are only configured with an IP address will fail startup validation and will not start.从MongoDB 5.0开始,只配置了IP地址的节点将无法通过启动验证,也不会启动。