CloudFormation创建了一个空的DocumentDB。

0

【以下的问题经过翻译处理】 亲爱的各位,

首先我想说我是DocuemntDB的新手。

https://docs.aws.amazon.com/documentdb/latest/developerguide/quick_start_cfn.html的帮助下,我使用CloudFormation创建了一个由3个实例组成的DocumentDB。部署没有出现错误。我尝试使用模板中配置的根用户名和密码进行连接,但没有成功:

E QUERY    [js] Error: Authentication failed. :

然后我尝试不使用任何用户名/密码,我成功连接:

$ mongo --ssl --host XYZ.docdb.amazonaws.com:27017 --sslCAFile rds-combined-ca-bundle.pem 
MongoDB shell version v4.0.28
connecting to: mongodb://XYZ.docdb.amazonaws.com:27017/admin?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("11254a7a-6610-4db0-a545-3a8bc4e5cf99") }
MongoDB server version: 4.0.0
rs0:PRIMARY> show dbs;
rs0:PRIMARY>

正如您所看到的,DB中没有内容。

CF是否会创建这样一个空的DB是期望的?根据来自群集描述的连接字符串,我应该使用

--username MyUserName --password <insertYourPassword>

我的代码没有什么特别之处:

  DBCluster:
    Type: AWS::DocDB::DBCluster
    Properties:
      DeletionProtection: True
      BackupRetentionPeriod : 7
      DBClusterIdentifier : !Ref DBClusterName
      DBClusterParameterGroupName : !Ref DBParameterGroup
      DBSubnetGroupName : !Ref DBSubnetGroup
      MasterUsername : MyUserName 
      MasterUserPassword : !Ref DocDBSecret
      Port : "27017"
      PreferredBackupWindow : "23:00-23:59"
      PreferredMaintenanceWindow : "sun:00:00-sun:05:00"
      VpcSecurityGroupIds:
        - !Ref DBSecurityGroup
      StorageEncrypted : true
      EngineVersion: 4.0.0

(如果需要,我可以粘贴我的模板的其他部分)

这种行为是否是预期的?

TIA

profile picture
エキスパート
質問済み 8ヶ月前38ビュー
1回答
0

【以下的回答经过翻译处理】 好的,对不起,现在我理解了情况。 允许无用户名和密码的登录,但没有权限查看任何内容。 使用用户名和密码登录可以获得管理员访问权限:

[ec2-user@ip-10-8-54-91 ~]$ mongo --ssl --host docdb-2023-02-02-07-35-01.cluster-XYZ.us-east-1.docdb.amazonaws.com:27017 --sslCAFile rds-combined-ca-bundle.pem --username root --password passwd
MongoDB shell version v4.0.28
connecting to: mongodb://docdb-2023-02-02-07-35-01.cluster-XYZ.us-east-1.docdb.amazonaws.com:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("8e65f1c3-8512-4e68-9b2d-37a2a8eaf581") }
MongoDB server version: 4.0.0

Warning: Non-Genuine MongoDB Detected

This server or service appears to be an emulation of MongoDB rather than an official MongoDB product.

Some documented MongoDB features may work differently, be entirely missing or incomplete, or have unexpected performance characteristics.

To learn more please visit: https://dochub.mongodb.org/core/non-genuine-mongodb-server-warning.

rs0:PRIMARY> use admin
switched to db admin
rs0:PRIMARY> db.getUsers()
[
        {
                "_id" : "serviceadmin",
                "user" : "serviceadmin",
                "db" : "admin",
                "roles" : [
                        {
                                "db" : "admin",
                                "role" : "root"
                        }
                ]
        },
        {
                "_id" : "root",
                "user" : "root",
                "db" : "admin",
                "roles" : [
                        {
                                "db" : "admin",
                                "role" : "root"
                        }
                ]
        }
]
profile picture
エキスパート
回答済み 8ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ