Can't connect to MongoDB

Hello,

MongoDB 4.0.11-1: 192.168.3.22
Graylog 3.0.2-1 : 192.168.3.10
ElasticSearch 6.8.2 : 192.168.3.15

On graylog3 I have this log:

2019-08-06T09:58:40.347+02:00 INFO [cluster] No server chosen by WritableServerSelector from cluster description ClusterDescription{type=REPLICA_SET, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=192.168.3.22:27017, type=REPLICA_SET_GHOST, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 0, 11]}, minWireVersion=0, maxWireVersion=7, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=1138744, setName='null', canonicalAddress=null, hosts=[], passives=[], arbiters=[], primary='null', tagSet=TagSet{[]}, electionId=null, setVersion=null, lastWriteDate=null, lastUpdateTimeNanos=330482575715619}]}. Waiting for 30000 ms before timing out

This message appear after I changer configuration on mongoDB

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# Where and how to store data.
storage:
  dbPath: /data/mongodb
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# how the process runs
processManagement:
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1,192.168.3.21


#security:
#  authorization: enabled

#operationProfiling:

replication:
  replSetName: rs01

#sharding:

## Enterprise-Only Options

#auditLog:

But mongoDB works well:

[root@mongodb data]# netstat -tlnp
Connexions Internet actives (seulement serveurs)
Proto Recv-Q Send-Q Adresse locale          Adresse distante        Etat        PID/Program name    
tcp        0      0 127.0.0.1:199           0.0.0.0:*               LISTEN      3301/snmpd          
tcp        0      0 192.168.3.22:27017       0.0.0.0:*               LISTEN      3936/mongod         
tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN      3936/mongod         
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      3302/sshd  

This is the Graylog configuration:

is_master = true
node_id_file = /etc/graylog/server/node-id
password_secret = 
root_password_sha2 = 
plugin_dir = /usr/share/graylog-server/plugin
http_bind_address = 192.168.3.10:9000
rotation_strategy = count
elasticsearch_hosts = http://192.168.3.15:9200
elasticsearch_max_docs_per_index = 50000000
elasticsearch_max_number_of_indices = 50
retention_strategy = delete
elasticsearch_shards = 4
elasticsearch_replicas = 0
elasticsearch_index_prefix = graylog
allow_leading_wildcard_searches = true
allow_highlighting = false
elasticsearch_analyzer = standard
output_batch_size = 500
output_flush_interval = 1
output_fault_count_threshold = 5
output_fault_penalty_seconds = 30
processbuffer_processors = 5
outputbuffer_processors = 3
processor_wait_strategy = blocking
ring_size = 65536
inputbuffer_ring_size = 65536
inputbuffer_processors = 2
inputbuffer_wait_strategy = blocking
message_journal_enabled = true
message_journal_dir = /var/lib/graylog-server/journal
lb_recognition_period_seconds = 3
mongodb_uri = mongodb://192.168.3.22:27017/graylog
mongodb_max_connections = 1000
mongodb_threads_allowed_to_block_multiplier = 5
content_packs_dir = /usr/share/graylog-server/contentpacks
content_packs_auto_load = grok-patterns.json
proxied_requests_thread_pool_size = 32
root_timezone = Europe/Paris

So, the problem is from mongodb, but I don’t know how to fix it.

Thank you.

Ok …

the probleme is form here :

replication:
  replSetName: rs01

I can’t have this line before completing my cluster.

It’s logical…

Thank you.

FWIW, MongoDB does not permit remote connections unless authentication is turned on and a user is created. Until you create that account, you’ll only be able to connect to the database via the primary node of the replica set and Graylog will not be able to use that MongoDB instance.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.