New in version 7.0.在版本7.0中新增。
Cluster members can use X.509 certificates for membership authentication to identify other servers in the same deployment. 集群成员可以使用X.509证书进行成员身份验证,以识别同一部署中的其他服务器。This tutorial describes how to perform a rolling update to migrate from using certificate Distinguished Name (DN) attributes to using extension values to identify members of a cluster.本教程介绍如何执行滚动更新,以从使用证书可分辨名称(DN)属性迁移到使用扩展值来标识集群成员。
When a server configured with the 当配置了net.tls.clusterAuthX509.extensionValue setting receives a connection request, it compares the the extension value string of the presented certificates to the configured values of the extensionValue setting and tlsClusterAuthX509Override parameter. If the values match, it treats the connection as a cluster member.net.tls.clusterAuthX509.extensionValue设置的服务器收到连接请求时,它会将所提供证书的扩展值字符串与extensionValue设置和tlsClusterAuthX509Override参数的配置值进行比较。如果值匹配,则将连接视为集群成员。
Clusters adopting new certificates can use the 采用新证书的群集可以在证书轮换过程中使用tlsClusterAuthX509Override parameter to accept X.509 certificates with different DN attributes during the certificate rotation procedure. Once all members use certificates with the new value, remove the override to begin rejecting the now out of date certificates.tlsClusterAuthX509Override参数接受具有不同DN属性的X.509证书。一旦所有成员使用具有新值的证书,请删除覆盖以开始拒绝现已过期的证书。
About This Task关于此任务
Consider a replica set where member certificates, set using the 考虑一个副本集,其中使用clusterFile and certificateKeyFile settings, have Distinguished Name (DN) attributes that use the MongoDB organization and MongoDB Server organizational unit. clusterFile和certificateKeyFile设置设置的成员证书具有使用MongoDB组织和MongoDB Server组织单位的可分辨名称(DN)属性。These DN attributes are set using the 这些DN属性是使用net.tls.clusterAuthX509.attributes setting.net.tls.clusterAuthX509.attributes属性设置设置的。
security:
clusterAuthMode: x509
net:
tls:
mode: requireTLS
certificateKeyFile: /etc/mycerts/10gen-server1.pem
CAFile: /etc/mycerts/ca.pem
clusterFile: /etc/mycerts/10gen-cluster1.pem
clusterCAFile: /etc/mycerts/ca.pem
clusterAuthX509:
attributes: O=MongoDB, OU=MongoDB Server
Note
The following procedure assumes that the new X.509 certificates meet membership certificate and all other requirements and that the cluster configuration identifies peer certificates using Distinguished Name (DN) values. 以下过程假设新的X.509证书满足成员证书和所有其他要求,并且集群配置使用可分辨名称(DN)值标识对等证书。For more information, see Member Certificate Requirements.有关更多信息,请参阅会员证书要求。
Steps步骤
These steps update member certificates to use new X.509 certificates on a cluster configured with the 这些步骤更新成员证书,以便在配置了attributes setting.attributes设置的集群上使用新的X.509证书。
Initially, the clusters identify members using DN values. With the new certificates, the servers instead identify members using the 最初,集群使用DN值标识成员。使用新证书,服务器将使用mongodb://example.mongodb.net extension value and ignore certificate attributes.mongodb://example.mongodb.net扩展值,忽略证书属性。
Update the TLS Cluster Membership Configuration更新TLS群集成员资格配置
Update the configuration file of each server:更新每台服务器的配置文件:
Change the通过将clusterAuthX509setting to match the new certificate by replacing theattributessetting with the theextensionValuesetting.attributes设置替换为extensionValue设置,更改clusterAuthX509设置以匹配新证书。Set the设置tlsClusterAuthX509Overrideparameter to use the DN attributes of the old certificate.tlsClusterAuthX509Override参数以使用旧证书的DN属性。
For example:例如:
net:
tls:
mode: requireTLS
certificateKeyFile: /etc/mycerts/mongodb-server1.pem
CAFile: /etc/mycerts/ca.pem
clusterFile: /etc/mycerts/mongodb-cluster1.pem
clusterCAFile: /etc/mycerts/ca.pem
clusterAuthX509:
extensionValue: mongodb://example.mongodb.net
security:
clusterAuthMode: x509
setParameter:
tlsClusterAuthX509Override: "{ attributes: 'O=MongoDB, OU=MongoDB Server' }"Restart Secondary Cluster Members重新启动辅助群集成员
Restart each secondary cluster member:重新启动每个次群集成员:
Use使用mongoshto connect to each secondary cluster member, then use thedb.shutdownServer()method to stop the server:mongosh连接到每个辅助集群成员,然后使用db.shutdownServer()方法停止服务器:use admin
db.shutdownServer()Restart the server.重新启动服务器。Use the使用rs.status()method to determine the member state:rs.status()方法确定成员状态:rs.status().membersWait for the等待此成员的stateStrfield for this member to show a value ofSECONDARY, then restart the next secondary.stateStr字段显示SECONDARY值,然后重新启动下一个辅助。
Secondary servers in the replica set now accept peer connections from members using certificates with the new extension values as well as the old DN attributes.副本集中的辅助服务器现在使用具有新扩展值和旧DN属性的证书接受来自成员的对等连接。
Restart Primary Cluster Member重新启动主群集成员
Restart the primary member:重新启动主成员:
Connect to the primary using使用mongosh, then use thers.stepDown()method to step the member down as the primary:mongosh连接到主节点,然后使用rs.stepDown()方法将该成员降级为主节点:rs.stepDown()The cluster promotes a secondary with the new certificate to serve as the new primary.集群使用新证书升级次要证书作为新的主要证书。Use the使用db.shutdownServer()method to shut the server down:db.shutdownServer()方法关闭服务器:use admin
db.shutdownServer()Restart the server.重新启动服务器。
The primary server in the replica set steps down and restarts as a secondary that now accepts peer connections from members using certificates with the new extension value as well as the old DN attributes.副本集中的主服务器会关闭并作为辅助服务器重新启动,该辅助服务器现在使用具有新扩展值和旧DN属性的证书接受来自成员的对等连接。
Update the TLS Certificates更新TLS证书
Update the configuration file of each server:更新每台服务器的配置文件:
Change the更改net.tls.certificateKeyFilesetting to use the new certificate.net.tls.certificateKeyFile设置以使用新证书。Change the更改net.tls.clusterFilesetting to use the new certificate.net.tls.clusterFile设置以使用新证书。
For example:例如:
net:
tls:
mode: requireTLS
certificateKeyFile: /etc/mycerts/mongodb-server2.pem
CAFile: /etc/mycerts/ca.pem
clusterFile: /etc/mycerts/mongodb-cluster2.pem
clusterCAFile: /etc/mycerts/ca.pem
clusterAuthX509:
extensionValue: mongodb://example.mongodb.net
security:
clusterAuthMode: x509
setParameter:
tlsClusterAuthX509Override: "{ attributes: 'O=MongoDB, OU=MongoDB Server' }"Restart Secondary Cluster Members重新启动辅助群集成员
Restart each secondary cluster member:重新启动每个次群集成员:
Use使用mongoshto connect to each secondary cluster member, then use thedb.shutdownServer()method to stop the server:mongosh连接到每个辅助集群成员,然后使用db.shutdownServer()方法停止服务器:use admin
db.shutdownServer()Restart the server.重新启动服务器。Use the使用rs.status()method to determine the member state:rs.status()方法确定成员状态:rs.status().membersWait for the等待此成员的stateStrfield for this member to show a value ofSECONDARY, then restart the next secondary.stateStr字段显示SECONDARY值,然后重新启动下一个辅助。
Secondary servers in the replica set now use the new X.509 certificates.副本集中的辅助服务器现在使用新的X.509证书。
Restart Primary Cluster Member重新启动主群集成员
Restart the primary member:重新启动主成员:
Connect to the primary using使用mongosh, then use thers.stepDown()method to step the member down as the primary:mongosh连接到主节点,然后使用rs.stepDown()方法将该成员降级为主节点:rs.stepDown()The cluster promotes a secondary with the new certificate to serve as the new primary.集群使用新证书升级次要证书作为新的主要证书。Use the使用db.shutdownServer()method to shut the server down:db.shutdownServer()方法关闭服务器:use admin
db.shutdownServer()Restart the server.重新启动服务器。
The primary server in the replica set steps down and restarts as a secondary that uses the new X.509 certificate.副本集中的主服务器会关闭并作为使用新X.509证书的辅助服务器重新启动。
Remove the DN Certification Override Configuration删除DN证书覆盖配置
With all members of the cluster now using the new X.509 certificate, update the configuration file to remove the 由于集群的所有成员现在都使用了新的X.509证书,请更新配置文件以删除setParameter settings for the tlsClusterAuthX509Override parameter.tlsClusterAuthX509Override参数的setParameter设置。
For example:例如:
net:
tls:
mode: requireTLS
certificateKeyFile: /etc/mycerts/mongodb-server1.pem
CAFile: /etc/mycerts/ca.pem
clusterFile: /etc/mycerts/mongodb-cluster1.pem
clusterCAFile: /etc/mycerts/ca.pem
clusterAuthX509:
extensionValue: mongodb://example.mongodb.net
security:
clusterAuthMode: x509
This ensures that the server doesn't configure the old certificate settings on startup.这可确保服务器在启动时不会配置旧的证书设置。
Restart Secondary Cluster Members重新启动辅助群集成员
Restart each secondary cluster member:重新启动每个次群集成员:
Use使用mongoshto connect to each secondary cluster member, then use thedb.shutdownServer()method to stop the server:mongosh连接到每个辅助集群成员,然后使用db.shutdownServer()方法停止服务器:use admin
db.shutdownServer()Restart the server.重新启动服务器。Use the使用rs.status()method to determine the member state:rs.status()方法确定成员状态:rs.status().membersWait for the等待此成员的stateStrfield for this member to show a value ofSECONDARY, then restart the next secondary.stateStr字段显示SECONDARY值,然后重新启动下一个辅助。
Secondary servers in the replica set restart and no longer accept connections from the old X.509 certificates.副本集中的辅助服务器重新启动,不再接受来自旧X.509证书的连接。
Restart Primary Cluster Member重新启动主群集成员
Restart the primary member:重新启动主成员:
Connect to the primary using使用mongosh, then use thers.stepDown()method to step the member down as the primary:mongosh连接到主节点,然后使用rs.stepDown()方法将该成员降级为主节点:rs.stepDown()The cluster promotes a secondary with the new certificate to serve as the new primary.集群使用新证书升级次要证书作为新的主要证书。Use the使用db.shutdownServer()method to shut the server down:db.shutdownServer()方法关闭服务器:use admin
db.shutdownServer()Restart the server.重新启动服务器。
The primary server steps down and restarts as a secondary that no longer accepts connections from the old X.509 certificates.主服务器停止运行,并作为不再接受旧X.509证书连接的辅助服务器重新启动。
Learn More了解更多
- x.509
Use X.509 Certificates for Membership Authentication with Self-Managed MongoDB使用X.509证书进行自我管理MongoDB的成员身份验证Upgrade Self-Managed MongoDB from Keyfile Authentication to X.509 Authentication将自管理MongoDB从键文件身份验证升级到X.509身份验证Rotate X.509 Certificates with clusterAuthX509 Attributes on Self-Managed Clusters在自我管理集群上旋转具有clusterAuthX509属性的X.509证书