23. Given the following commands that are run on the same machine and represent a replica set for testing purposes: mongod --sslMode requireSSL --sslPEMKeyFile server.pem --sslCAFile ca.pem --replSet myEncryptedReplSet --dbpath=r0/db --logpath=r0/db/mongo.log --port=27017 --fork mongod --sslMode requireSSL --sslPEMKeyFile server.pem --sslCAFile ca.pem --replSet myEncryptedReplSet --dbpath=r1/db --logpath=r1/db/mongo.log --port=27018 --fork mongod --sslMode requireSSL --sslPEMKeyFile server.pem --sslCAFile ca.pem --replSet myEncryptedReplSet --dbpath=r2/db --logpath=r2/db/mongo.log --port=27019 --fork What would be the correct set of next steps to initialize this replica set? (assume all certificates are bound to localhost) Choose the best answer:
Answer options
- A.$ mongo --replSet myEncryptedReplSet > rs.initiate({"_id": 'myEncryptedReplSet', "version":1, "members": [ {"_id": 0, "host": "localhost:27017"}, {"_id": 1, "host": "localhost:27018"}, {"_id": 2, "host": "localhost:27019"} ] })
- B.$ mongo --ssl --sslPEMKEYFile client.pem --sslCAFile ca.pem > rs.initiate({"_id": "myEncryptedReplSet"})
- C.$ mongo --ssl --sslPEMKEYFile client.pem --sslCAFile ca.pem > rs.initiate({"_id": 'myEncryptedReplSet', "version":1, "members": [ {"_id": 0, "host": "localhost:27017"}, {"_id": 1, "host": "localhost:27018"}, {"_id": 2, "host": "localhost:27019"} ] })
- D.$ mongo --ssl --replSet myEncryptedReplSet > rs.initiate({"_id": "myEncryptedReplSet", "version":1, "members": [ {"_id": 0, "host": "localhost:27017"}, {"_id": 1, "host": "localhost:27018"}, {"_id": 2, "host": "localhost:27019"} ] })
- E.$ mongo --ssl --sslPEMKEYFile client.pem --sslCAFile ca.pem > rs.initiate({ members: [ {"_id": 0, "host": "localhost:27017"}, {"_id": 1, "host": "localhost:27018"}, {"_id": 2, "host": "localhost:27019"} ] })
Answer confidence: High
Correct answer: C
Explanation language: Chinese
节点以 --sslMode requireSSL 启动,客户端必须带 --ssl,并且要用 --sslPEMKeyFile/--sslCAFile 提供证书与 CA 才能与开启 TLS 的成员通信;rs.initiate 的配置还必须包含 _id、version 和三个成员。A 缺 --ssl,C 只给 _id 不会加入其余成员,D 缺 _id,只有 E 完整正确。