anyproto / any-sync-dockercompose

docker-compose for testing any-sync
MIT License
238 stars 30 forks source link

MongoDB 5.0 #29

Closed zcr268 closed 3 months ago

zcr268 commented 3 months ago

Have you read a contributing guide?

Current Behavior

MongoDB does not work on older devices above version 5.0

Expected Behavior

MongoDB does not work on older devices above version 5.0

Steps To Reproduce

MongoDB does not work on older devices above version 5.0

Environment

- OS:DSM 7.2
- Version:

Anything else?

WARNING: MongoDB 5.0+ requires a CPU with AVX support, and your current system does not appear to have that! see https://jira.mongodb.org/browse/SERVER-54407 see also https://www.mongodb.com/community/forums/t/mongodb-5-0-cpu-intel-g4650-compatibility/116610/2 see also https://github.com/docker-library/mongo/issues/485#issuecomment-891991814

zcr268 commented 3 months ago

Can I use MongoDB 4.4.29?

mighty-sponge commented 3 months ago

Hey! A fix will be released soon to allow mongo 4.x versions to be used in replica set mode.

PandaQuQ commented 3 months ago

Hey! A fix will be released soon to allow mongo 4.x versions to be used in replica set mode.

Waiting for this for a long long time TAT. Do plz release this fix soon

mighty-sponge commented 3 months ago

Sorry for the long wait! So, in older versions of Mongo, the initialization of the Replica Set was arranged differently. In order for legacy MongoDB to work, you need to do the following:

  1. in the .env file, set new values for the following variables:
    MONGO_VERSION=4.4.29
    MONGO_CONNECT=mongodb://mongo-1:${MONGO_1_PORT}
  2. Now use the new docker-compose.yml file provided below:
    
    version: "3.9"

services: mongo-1: image: "mongo:${MONGO_VERSION}" command: --replSet ${MONGO_REPLICA_SET} --port ${MONGO_1_PORT} ports:

  1. Run make start. Make sure the replica-set is initialized correctly: the command docker compose exec mongo-1 mongo --port 27001 --eval 'rs.status().ok' output must end with 1.
fb929 commented 3 months ago

now we have lighter way for use mongo 4 follow to steps:

  1. checkout to tag v3.0.0 or higher
  2. edit mongo version in .env file (.env.override for v4.0.0 or higher):
    MONGO_VERSION=4.4.29
  3. create docker-compose.override.yml with this content
    services:
     mongo-1:
       healthcheck:
         test: echo "rs.initiate({_id:'${MONGO_REPLICA_SET}',members:[{_id:0,host:\"mongo-1:${MONGO_1_PORT}\"}]}).ok || rs.status().ok" | mongo --port ${MONGO_1_PORT} --quiet
  4. start self-host
    make start