スポンサーサイト

2023.04.20 Thursday
0

    一定期間更新がないため広告を表示しています

    category:- | by:スポンサードリンク | - | - | -

    mongodbで ERROR: The SCRAM_SHA_256 authentication mechanism requires libmongoc built with ENABLE_SSL {"exception":"[object] (MongoDB¥¥Driver¥¥Exception¥¥AuthenticationException(code: 11): The SCRAM_SHA_256 authentication mechan

    2020.06.15 Monday 01:24
    0
      docker上で、php+laravelコンテナと、mongodbコンテナをセットしてシステム構築した際に出たエラー

      ■エラー内容
      [2020-06-14 12:23:00] local.ERROR: The SCRAM_SHA_256 authentication mechanism requires libmongoc built with ENABLE_SSL {"exception":"[object] (MongoDB¥¥Driver¥¥Exception¥¥AuthenticationException(code: 11): The SCRAM_SHA_256 authentication mechanism requires libmongoc built with ENABLE_SSL at ./vendor/mongodb/mongodb/src/Operation/ListCollections.php:132)

      ■原因
      ssl系パッケージがなかった
      phpinfoでみると、disabledになってたり、一部足りなかったりしてる

      ■エラー内容
      phpコンテナ側 dockerfileに以下を追加
      ・これでいかた
      RUN apt-get install -y --no-install-recommends ¥
      libssl-dev ¥
      openssl ¥
      ssl-cert ¥
      ・・・


      ■おまけ
      mongodb コマンドラインでのデータ参照確認
      mongodb コンテナから検索

      # mongo -u hoge -p hoge
      > show dbs ;
      > use hogedb

      件数確認
      > hogedb.hogecollection.count()

      数件だけ確認
      > db.hogecollection.find().limit(2)

      category:mongodb | by:ittoocomments(0) | - | -

      mongodbで ERROR: command listCollections requires authentication {"exception":"[object] (MongoDB¥¥Driver¥¥Exception¥¥CommandException(code: 13): command listCollections requires authentication at ./vendor/mongodb/mongodb/src/O

      2020.06.15 Monday 01:22
      0
        docker上で、php+laravelコンテナと、mongodbコンテナをセットしてシステム構築した際に出たエラー


        ■エラー内容
        [2020-06-14 11:53:47] local.ERROR: command listCollections requires authentication {"exception":"[object]
        (MongoDB¥¥Driver¥¥Exception¥¥CommandException(code: 13): command listCollections requires authentication at ./vendor/mongodb/mongodb/src/Operation/ListCollections.php:132)
        [stacktrace]
        #0 ./vendor/mongodb/mongodb/src/Operation/ListCollections.php(132): MongoDB¥¥Driver¥¥Server->executeCommand('kabudb', Object(MongoDB¥¥Driver¥¥Command), Array)
        #1 ./vendor/mongodb/mongodb/src/Operation/ListCollections.php(89): MongoDB¥¥Operation¥¥ListCollections->executeCommand(Object(MongoDB¥¥Driver¥¥Server))
        #2 ./vendor/mongodb/mongodb/src/Database.php(343): MongoDB¥¥Operation¥¥ListCollections->execute(Object(MongoDB¥¥Driver¥¥Server))
        #3 ./vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Schema/Builder.php(44): MongoDB¥¥Database->listCollections()
        #4 ./vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Schema/Builder.php(58): Jenssegers¥¥Mongodb¥¥Schema¥¥Builder->hasCollection('data_types')
        #5 ./vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(223): Jenssegers¥¥Mongodb¥¥Schema¥¥Builder->hasTable('data_types')
        #6 ./vendor/tcg/voyager/src/VoyagerServiceProvider.php(260): Illuminate¥¥Support¥¥Facades¥¥Facade::__callStatic('hasTable', Array)
        #7 ./vendor/tcg/voyager/src/VoyagerServiceProvider.php(107): TCG¥¥Voyager¥¥VoyagerServiceProvider->registerGates()
        #8 [internal function]: TCG¥¥Voyager¥¥VoyagerServiceProvider->boot(Object(Illuminate¥¥Routing¥¥Router), Object(Illuminate¥¥Events¥¥Dispatcher))
        #9 ./vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
        #10 ./vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate¥¥Container¥¥BoundMethod::Illuminate¥¥Container¥¥{closure}()
        #11 ./vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate¥¥Container¥¥BoundMethod::callBoundMethod(Object(Illuminate¥¥Foundation¥¥Ap


        ■エラー原因
        .env のパラメータと、config/database.phpのパラメータが結びついてなかった
        コメントアウトになってたのできちんと設定


        ■対応内容
        .env
        DB_USERNAME=hoge
        DB_PASSWORD=hoge

        config/database.php
        'username' => env('DB_USERNAME'),
        'password' => env('DB_PASSWORD'),
        category:mongodb | by:ittoocomments(0) | - | -

        mongodbで ERROR: No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling ismaster on '127.0.0.1:27017'] {"exception":"[object] (MongoDB¥¥Driver¥¥Exception¥¥ConnectionTimeoutException(code: 13053):

        2020.06.15 Monday 01:20
        0
          docker上で、php+laravelコンテナと、mongodbコンテナをセットしてシステム構築した際に出たエラー

          ■エラー内容
          [2020-06-14 11:43:40] local.ERROR: No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling ismaster on '127.0.0.1:27017'] {"exception":"[object] (MongoDB¥¥Driver¥¥Exception¥¥ConnectionTimeoutException(code: 13053): No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling ismaster on '127.0.0.1:27017'] at ./vendor/mongodb/mongodb/src/Database.php:341)
          [stacktrace]
          #0 ./vendor/mongodb/mongodb/src/Database.php(341): MongoDB¥¥Driver¥¥Manager->selectServer(Object(MongoDB¥¥Driver¥¥ReadPreference))
          #1 ./vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Schema/Builder.php(44): MongoDB¥¥Database->listCollections()
          #2 ./vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Schema/Builder.php(58): Jenssegers¥¥Mongodb¥¥Schema¥¥Builder->hasCollection('data_types')
          #3 ./vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(223): Jenssegers¥¥Mongodb¥¥Schema¥¥Builder->hasTable('data_types')
          #4 ./vendor/tcg/voyager/src/VoyagerServiceProvider.php(260): Illuminate¥¥Support¥¥Facades¥¥Facade::__callStatic('hasTable', Array)
          #5 ./vendor/tcg/voyager/src/VoyagerServiceProvider.php(107): TCG¥¥Voyager¥¥VoyagerServiceProvider->registerGates()
          #6 [internal function]: TCG¥¥Voyager¥¥VoyagerServiceProvider->boot(Object(Illuminate¥¥Routing¥¥Router), Object(Illuminate¥¥Events¥¥Dispatcher))
          #7 ./vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
          #8 ./vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate¥¥Container¥¥BoundMethod::Illuminate¥¥Container¥¥{clos


          ■対応
          .envでの、DB_HOSTが間違っていた
          mongodb用に用意したコンテナ名を指定する

          DB_HOST=mongo
          に修正

          category:mongodb | by:ittoocomments(0) | - | -

          mongodb ERROR: Class 'MongoDB¥Driver¥Manager' not found {"exception":"[object] (Symfony¥¥Component¥¥Debug¥¥Exception¥¥FatalThrowableError(code: 0): Class 'MongoDB¥¥Driver¥¥Manager' not found at

          2020.06.15 Monday 01:18
          0
            ■エラー内容
            docker上で、php+laravelコンテナと、mongodbコンテナをセットしてシステム構築した際に出たエラー

            local.ERROR: Class 'MongoDB¥Driver¥Manager' not found {"exception":"[object]
            (Symfony¥¥Component¥¥Debug¥¥Exception¥¥FatalThrowableError(code: 0): Class 'MongoDB¥¥Driver¥¥Manager' not found at
            ./vendor/mongodb/mongodb/src/Client.php:87)

            [stacktrace]
            #0 ./vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Connection.php(141): MongoDB¥¥Client->__construct('mongodb://127.0...', Array, Array)
            #1 ./vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Connection.php(41): Jenssegers¥¥Mongodb¥¥Connection->createConnection('mongodb://127.0...', Array, Array)
            #2 ./vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/MongodbServiceProvider.php(30): Jenssegers¥¥Mongodb¥¥Connection->__construct(Array)
            #3 [internal function]: Jenssegers¥¥Mongodb¥¥MongodbServiceProvider->Jenssegers¥¥Mongodb¥¥{closure}(Array, 'mongodb')
            #4 ./vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(109): call_user_func(Object(Closure), Array, 'mongodb')
            #5 ./vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(74): Illuminate¥¥Database¥¥DatabaseManager->makeConnection('mo


            ■phpinfoで、php側コンテナを確認すると前のバージョンで、mongodbがはいってるのに今回はなかった
            今回の環境はdocker上でphpとmongodbを別コンテナに管理してる。
            でもって、phpのコンテナ側にMongoDBドライバがなかったのが原因っぽい、

            なのでphp環境にもMongoDBドライバを追加

            ■実行コマンド
            # pecl install mongodb

            もしくは Dockerfileに以下を追加

            RUN apt-get install -y --no-install-recommends ¥
            pecl install mongodb && ¥

            ■確認
            # pecl list
            Installed packages, channel pecl.php.net:
            =========================================
            Package Version State
            mongodb 1.7.4 stable

            あと、php.iniにextension=mongodb.soを追加
            You should add "extension=mongodb.so" to php.ini

            ちなみに古いバージョンだと名前が違うみたい
            category:mongodb | by:ittoocomments(0) | - | -

            mongodbにデータ一括インサートで error connecting to host: could not connect to server: connection() : auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed. のエラーでた

            2020.06.14 Sunday 15:55
            0
              新しく環境構築しててmongodbにデータ一括インサートしようとすると
              error connecting to host: could not connect to server: connection() : auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed.
              のエラーがでた。

              ナニコレ?
              前の環境ではこんなんでたっけな?
              それともversion新しくなって変わったのか?docker上でつくってるからなのか?

              結論としては mongoimport コマンド使用時に、
              ユーザ、
              パスワード、
              ユーザ管理者でMongoDBに接続する場合、--authenticationDatabase adminが必要らしい
              ので上記を追加したら実行できたよ


              ■ mongodbにデータ一括投入NGパターン
              ・--authenticationDatabase admin をつけないと以下のエラーになる
              # mongoimport --db hogedb --collection hogecollection --drop --file insert_hoge.json -u hogeuser -p hogepassword

              2020-06-14T06:30:03.245+0000 error connecting to host: could not connect to server: connection() : auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed.



              ■ mongodbにデータ一括投入OKパターン
              ・user と password も指定するよ あと --authenticationDatabase admin もね
              # mongoimport --db hogedb --collection hogecollection --drop --authenticationDatabase admin --file insert_hoge.json -u hogeuser -p hogepassword

              2020-06-14T06:37:08.132+0000 connected to: mongodb://localhost/
              2020-06-14T06:37:08.133+0000 dropping: hogedb.hogecollection
              2020-06-14T06:37:08.901+0000 6238 document(s) imported successfully. 0 document(s) failed to import.
              category:mongodb | by:ittoocomments(0) | - | -

              ad
              Calender
                   12
              3456789
              10111213141516
              17181920212223
              24252627282930
              31      
              << March 2024 >>
              Selected entry
              PR
              Category
              Archives
              Recommend
              Link
              Profile
              Search
              Others
              Mobile
              qrcode
              Powered
              無料ブログ作成サービス JUGEM