非常感谢!参考:mongo 单机开启副本集事务
补充两点:
1. 4.2以后的版本开启副本集需要加入security.keyFile!
2. 在4.4版本测试可以动态的生成集合
security.keyFile
The path to a key file that stores the shared secret that MongoDB instances use to authenticate to each other in a sharded cluster or replica set. keyFile implies security.authorization. See Internal/Membership Authentication for more information.
Starting in MongoDB 4.2, keyfiles for internal membership authentication use YAML format to allow for multiple keys in a keyfile. The YAML format accepts content of:
生成key文件:
openssl rand -base64 756 > <path-to-keyfile>
chmod 400 <path-to-keyfile>
配置文件:
security:
keyFile:<path-to-keyfile>
replication:
replSetName:<replicaSetName>
网友评论