Details
-
Type:
Monitor
-
Status: Closed
-
Priority:
Major
-
Resolution: Done
-
Affects Version/s: None
-
Fix Version/s: 2021
-
Component/s: FIWARE-TECH-HELP
-
Labels:
-
HD-Enabler:Cygnus
Description
Created question in FIWARE Q/A platform on 26-04-2018 at 17:04
Please, ANSWER this question AT https://stackoverflow.com/questions/50046646/cygnus-and-mongodb-authentication-failed
Question:
Cygnus and mongodb: Authentication failed
Description:
I'm trying to use cygnus and mongdb with docker.
My docker-compose:
cygnus:
image: fiware/cygnus-ngsi:1.7.1
hostname: cygnus
container_name: cygnus
volumes:
- ./config/cygnus/agent.conf:/opt/apache-flume/conf/agent.conf
links: - mysql-cygnus:mysql-cygnus
external_links: - mongodb:mongodb
expose: - "5050"
ports: - "5050:5050"
environment: - CYGNUS_MONGO_HOSTS=mongodb:27017
- CYGNUS_MONGO_USER=cygnus
- CYGNUS_MONGO_PASS=f10t_Mongo
- CYGNUS_LOG_LEVEL=INFO
...
mongodb:
image: mongo:3.4.7
hostname: mongodb
image: aashreys/mongo-auth:latest
expose:
- "27017"
ports: - "27017:27017"
environment: - AUTH=yes
- MONGODB_ADMIN_USER=admin_cygnus
- MONGODB_ADMIN_PASS=admin_cygnus
expose: - "27017"
ports: - "27017:27017"
My agent.conf
cygnus-ngsi.sinks.mongo-sink.mongo_hosts = mongodb:27017
cygnus-ngsi.sinks.mongo-sink.mongo_username = cygnus
cygnus-ngsi.sinks.mongo-sink.mongo_password = f10t_Mongo
But I got in cygnus log:
msg=com.telefonica.iot.cygnus.sinks.NGSISink[533] : Persistence error.
Message: -, Timed out after 30000 ms while waiting for a server that matches PrimaryServerSelector.
Client view of cluster state is {type=UNKNOWN, servers=[{address=mongodb:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=null, userName='cygnus', source='cygnus_imd', password=<hidden>, mechanismProperties={}}}, caused by {com.mongodb.MongoCommandException:
Command failed with error 18: 'Authentication failed.' on server mongodb:27017. The full response is
}}]
and mongo log:
2018-04-25T20:59:19.684+0000 I ACCESS [conn136] SCRAM-SHA-1 authentication failed for cygnus on cygnus_imd from client 172.18.0.4:37250 ; UserNotFound: Could not find user cygnus@cygnus_imd
I resolved the problem creating the user inside the database cygnus_imd:
use cygnus_imd
db.createUser(
);
But I don't think that is a good solution, because I can't create a user for each dataset of my cygnus, it should be done automatically. I think that the authentication doesn't work with a database empty. But at the begin, all databases are empties. So I don't know how fix it.
2018-04-26 18:05|CREATED monitor | # answers= 0, accepted answer= False