我在docker下設置Graylog2有一些麻煩。一切工作,直到我嘗試使用驗證。我所得到的是永久重複的以下錯誤。Graylog容器無法連接到MongoDB容器
試用root
和graylog
用戶(在graylog
和admin
db中)給出了相同的結果。
來自mongodb的日誌說這兩個用戶都是在安裝過程中創建的。但是graylog說它在數據庫graylog
中找不到graylog
用戶。與用戶root
相同。
我是新來的MongoDB,不知道身份驗證如何工作。但從我所瞭解的身份驗證(類似於--auth
參數)在爲root帳戶(https://github.com/docker-library/mongo/pull/145)提供用戶/密碼時被激活。
Graylog是否可能採用與MongoDB不同的驗證機制?見線#158在pasted log
錯誤消息作爲根用戶
mongodb_1 | 2017-04-16T13:27:52.486+0000 I NETWORK [thread1] connection accepted from 172.18.0.4:46566 #12 (1 connection now open) mongodb_1 | 2017-04-16T13:27:52.495+0000 I NETWORK [conn12] received client metadata from 172.18.0.4:46566 conn12: { driver: { name: "mongo-java-driver", version: "unknown" }, os: { type: "Linux", name: "Linux", architecture: "amd64", version: "4.4.0-72-generic" }, platform: "Java/Oracle Corporation/1.8.0_72-internal-b15" } mongodb_1 | 2017-04-16T13:27:52.525+0000 I ACCESS [conn12] SCRAM-SHA-1 authentication failed for root on graylog from client 172.18.0.4:46566 ; UserNotFound: Could not find user [email protected] mongodb_1 | 2017-04-16T13:27:52.543+0000 I - [conn12] end connection 172.18.0.4:46566 (1 connection now open)
錯誤消息作爲graylog用戶(Full log on pastebin)
mongodb_1 | 2017-04-16T15:47:48.404+0000 I NETWORK [thread1] connection accepted from 172.18.0.4:41602 #7 (1 connection now open) mongodb_1 | 2017-04-16T15:47:48.410+0000 I NETWORK [conn7] received client metadata from 172.18.0.4:41602 conn7: { driver: { name: "mongo-java-driver", version: "unknown" }, os: { type: "Linux", name: "Linux", architecture: "amd64", version: "4.4.0-72-generic" }, platform: "Java/Oracle Corporation/1.8.0_72-internal-b15" } mongodb_1 | 2017-04-16T15:47:48.418+0000 I ACCESS [conn7] SCRAM-SHA-1 authentication failed for graylog on graylog from client 172.18.0.4:41602 ; UserNotFound: Could not find user [email protected] mongodb_1 | 2017-04-16T15:47:48.423+0000 I - [conn7] end connection 172.18.0.4:41602 (1 connection now open)
這是我的./docker- composer.yml
version: '2' services: mongodb: build: ./mongodb volumes: - /docker/mongodb/data:/data/db elasticsearch: image: "elasticsearch:2" command: "elasticsearch -Des.cluster.name='graylog'" volumes: - /docker/elasticsearch/data:/usr/share/elasticsearch/data graylog: image: graylog2/server volumes: - /docker/graylog/journal:/usr/share/graylog/data/journal - /docker/graylog/config:/usr/share/graylog/data/config environment: #GRAYLOG_MONGODB_URI: mongodb://root:[email protected]:27017/graylog GRAYLOG_MONGODB_URI: mongodb://graylog:[email protected]:27017/graylog depends_on: - mongodb - elasticsearch ports: - "9000:9000"
./mongodb/Dockerfile
FROM mongo:3 ENV MONGO_INITDB_ROOT_USERNAME: root ENV MONGO_INITDB_ROOT_PASSWORD: drUqGGCMh ADD grayloguser.js /docker-entrypoint-initdb.d/grayloguser.js
./mogodb/grayloguser.js
db.getSiblingDB('graylog'); db.createUser( { user: "graylog", pwd: "vWGzncmBe9", roles: [ { role: "dbOwner", db: "graylog" } ] } );
看起來像'UserNotFound:找不到用戶root @ graylog'。我們在'graylog' db中有'root'用戶嗎?當你嘗試與'graylog'用戶連接時,你看到同樣的錯誤嗎? – Veeram
我得到用JS腳本創建的graylog用戶的excact錯誤。我錯誤地認爲dbOwner應該足夠了嗎?我也認爲root用戶根據init腳本應該能夠做到一切? –
現在我認爲角色不是問題。看起來像創建的用戶沒有被看到。你是如何啓用授權的?你想要做什麼樣的手術? – Veeram