doutangtan6386 2017-09-05 14:11
浏览 313
已采纳

AuthenticationFailed:分片MongoDB上的用户文档中缺少MONGODB-CR凭据:无法连接到:queryrouter0.example.com:27017:

I have a sharded MongoDB setup.

I'm trying to connect to it from my Laravel application

Before I sharded my database I was using laravel-mongodb to connect to my regular mongodb instance.

This was my previous config

'mongodb' => array(
        'driver'   => 'mongodb',
        'host'     => env('MONGODB_HOST', 'localhost'),
        'port'     => env('MONGODB_PORT', 27017),
        'username' => env('MONGODB_USERNAME', ''),
        'password' => env('MONGODB_PASSWORD', ''),
        'database' => env('MONGODB_DATABASE', ''),
        'options' => array(
            'db' => env('MONGODB_AUTHDATABASE', '') //Sets the auth DB
        )
    )

I tried to update the MONGODB_HOST to the sharded query router hostname but I am now getting the error

[MongoConnectionException] Failed to connect to: queryrouter0.example.com:27017: Authentication failed on database 'admin' with username 'maxrosecollins': auth failed`

I can see in the logs on the queryrouter0.example.com server

2017-09-05T14:42:36.558+0000 I NETWORK [thread2] connection accepted from 45.32.144.169:33086 #41615 (1 connection now open) 2017-09-05T14:42:36.560+0000 I ACCESS [conn41615] authenticate db: admin { authenticate: 1, user: "maxrosecollins", nonce: "xxx", key: "xxx" }

2017-09-05T14:42:36.562+0000 I ACCESS [conn41615] Failed to authenticate maxrosecollins@admin with mechanism MONGODB-CR: AuthenticationFailed: MONGODB-CR credentials missing in the user document

2017-09-05T14:42:36.563+0000 I - [conn41615] end connection 45.32.144.169:33086 (1 connection now open)

I can connect to the query router using the following. This is on the same server I am getting the auth failed error when using laravel. I have double checked passwords and usernames

mongo queryrouter0.example.com:27017 -u "maxrosecollins" -p "password" --authenticationDatabase "admin"
  • 写回答

2条回答 默认 最新

  • douluolan9101 2017-09-12 09:43
    关注

    I worked out my laravel-mongodb install was version 2 which doesn't support the SCRAM-SHA-1 authentication mechanism.

    I used composer updateto upgrade to version 3 which also meant upgrading the php mongo adapter along with a lot of other dependencies.

    I then ran db.adminCommand({authSchemaUpgrade: 1}); see upgrading auth

    After this I could authenticate with my mongo query router

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 iqoo11 如何下载安装工程模式
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?