0

I have mogodb cluster with 4 nodes, all nodes work on standard 27017 port. I found weird things in my mongod.log on a secondary node:

{"t":{"$date":"2022-03-26T23:22:34.593+03:00"},"s":"I",  "c":"NETWORK",  "id":22944,   "ctx":"conn12132","msg":"Connection ended","attr":{"remote":"<PRIMARY_IP>:42994","connectionId":12132,"connectionCount":143}}
{"t":{"$date":"2022-03-26T23:22:35.065+03:00"},"s":"I",  "c":"NETWORK",  "id":22944,   "ctx":"conn12133","msg":"Connection ended","attr":{"remote":"<PRIMARY_IP>:43004","connectionId":12133,"connectionCount":142}}
{"t":{"$date":"2022-03-26T23:22:35.106+03:00"},"s":"I",  "c":"NETWORK",  "id":22944,   "ctx":"conn12129","msg":"Connection ended","attr":{"remote":"<PRIMARY_IP>:41906","connectionId":12129,"connectionCount":141}}
{"t":{"$date":"2022-03-26T23:22:41.555+03:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"<PRIMARY_IP>:57280","connectionId":12202,"connectionCount":142}}
{"t":{"$date":"2022-03-26T23:22:41.560+03:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn12202","msg":"client metadata","attr":{"remote":"<PRIMARY_IP>:57280","client":"conn12202","doc":{"driver":{"name":"PyMongo","version":"4.0.1"},"os":{"type":"Linux","name":"Linux","architecture":"x86_64","version":"5.4.0-67-generic"},"platform":"CPython 3.9.4.final.0"}}}
{"t":{"$date":"2022-03-26T23:22:41.611+03:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"<PRIMARY_IP>:57296","connectionId":12203,"connectionCount":143}}
{"t":{"$date":"2022-03-26T23:22:41.612+03:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn12203","msg":"client metadata","attr":{"remote":"<PRIMARY_IP>:57296","client":"conn12203","doc":{"driver":{"name":"PyMongo","version":"4.0.1"},"os":{"type":"Linux","name":"Linux","architecture":"x86_64","version":"5.4.0-67-generic"},"platform":"CPython 3.9.4.final.0"}}}
{"t":{"$date":"2022-03-26T23:22:41.755+03:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"<PRIMARY_IP>:57312","connectionId":12204,"connectionCount":144}}
{"t":{"$date":"2022-03-26T23:22:41.756+03:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn12204","msg":"client metadata","attr":{"remote":"<PRIMARY_IP>:57312","client":"conn12204","doc":{"driver":{"name":"PyMongo","version":"4.0.1"},"os":{"type":"Linux","name":"Linux","architecture":"x86_64","version":"5.4.0-67-generic"},"platform":"CPython 3.9.4.final.0"}}}
{"t":{"$date":"2022-03-26T23:22:41.807+03:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"<PRIMARY_IP>:57324","connectionId":12205,"connectionCount":145}}
{"t":{"$date":"2022-03-26T23:22:41.808+03:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn12205","msg":"client metadata","attr":{"remote":"<PRIMARY_IP>:57324","client":"conn12205","doc":{"driver":{"name":"PyMongo","version":"4.0.1"},"os":{"type":"Linux","name":"Linux","architecture":"x86_64","version":"5.4.0-67-generic"},"platform":"CPython 3.9.4.final.0"}}}

I see some weird connections on different ports, and i don't understand what is it. Is it normal?


Servers are protected by ufw firewall, but my nodes have full access (on any port) to each other. Port 27017 is opened from outside.

This is /etc/mongod.conf, it's the same on all nodes:

storage:
  dbPath: /mnt/data
net:
  port: 27017
  bindIp: 0.0.0.0
security:
  authorization: enabled
  keyFile: /mnt/data/mongodb.key
replication:
  replSetName: rs0
systemLog:
  path: /mnt/data/mongod.log
  destination: file
  logAppend: true
operationProfiling:
  mode: slowOp
  slowOpThresholdMs: 50

ufw stauts:

22                         LIMIT       Anywhere  
27017                      ALLOW       Anywhere                  
Anywhere                   ALLOW       <MY_ANOTHER_SERVER_IP>  
Anywhere                   ALLOW       <MY_ANOTHER_SERVER_IP>
Anywhere                   ALLOW       <MY_ANOTHER_SERVER_IP>
Anywhere                   ALLOW       <MY_ANOTHER_SERVER_IP>                    
22 (v6)                    LIMIT       Anywhere (v6)  
27017 (v6)                 ALLOW       Anywhere (v6)
Antonio
  • 169
  • 1
  • 11

1 Answers1

0

There are ephimeral ports used by MongoDB:

https://en.wikipedia.org/wiki/Ephemeral_port