Skip to content

Mongodb can not init replica on new serwer

Summary

When starting fresh server with no data, mongo must be initialize, unfortunetly it sometimes happen that database container did not start and replica init fails.

Expected behavior

Mongo and rocketchat shuld start.

Actual behavior

Mongodb starts but replica is not set.

Relevant logs and/or screenshots

logs from docker replica init container

[root@rocketchat kszym]# docker logs -f docker-rocketchat_database-init-replica_1 
MongoDB shell version v4.0.20
connecting to: mongodb://database:27017/rocketchat?gssapiServiceName=mongodb
2020-12-02T08:45:37.221+0000 E QUERY    [js] Error: couldn't connect to server database:27017, connection attempt failed: SocketException: Error connecting to database:27017 (172.27.0.2:27017) :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:344:17
@(connect):2:6
exception: connect failed

Possible fixes

Replica init command should be executed in for loop until it is succesfull as in compose example → https://github.com/RocketChat/Rocket.Chat/blob/develop/docker-compose.yml#L47

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information