Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoDB 5.0 #29

Closed
3 tasks done
zcr268 opened this issue Mar 16, 2024 · 5 comments
Closed
3 tasks done

MongoDB 5.0 #29

zcr268 opened this issue Mar 16, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@zcr268
Copy link

zcr268 commented Mar 16, 2024

Have you read a contributing guide?

  • I have read CONTRIBUTING.md
  • I have searched the existing issues and didn't find any that were similar
  • I have considered creating a pull request with fixes instead of a bug report and want to proceed

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 docker-library/mongo#485 (comment)

@zcr268 zcr268 added the bug Something isn't working label Mar 16, 2024
@zcr268
Copy link
Author

zcr268 commented Mar 16, 2024

Can I use MongoDB 4.4.29?

@mighty-sponge
Copy link
Contributor

mighty-sponge commented Mar 18, 2024

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

@mighty-sponge mighty-sponge self-assigned this Mar 18, 2024
@PandaQuQ
Copy link

PandaQuQ commented Apr 1, 2024

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
Copy link
Contributor

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}
  1. 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:
      - "${MONGO_1_PORT}:${MONGO_1_PORT}"
    volumes:
      - ./storage/mongo-1/:/data/db
    healthcheck:
      test: mongo --port ${MONGO_1_PORT} --eval 'rs.initiate({"_id":"${MONGO_REPLICA_SET}","members":[{"_id":0,"host":"mongo-1:${MONGO_1_PORT}"}]})'
      interval: 10s
      start_period: 30s

  redis:
    image: "redis/redis-stack-server:${REDIS_VERSION}"
    restart: always
    command: redis-server --dir /data/ --appendonly yes --maxmemory 256mb --maxmemory-policy noeviction --protected-mode no --loadmodule /opt/redis-stack/lib/redisbloom.so
    ports:
      - "${REDIS_PORT}:${REDIS_PORT}"
    volumes:
      - ./storage/redis/:/data/
    healthcheck:
      test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
      interval: 10s
      timeout: 30s
      retries: 3

  minio:
    image: "minio/minio:${MINIO_VERSION}"
    restart: always
    command: server /data --console-address ":9001"
    environment:
      MINIO_ROOT_USER: "${AWS_ACCESS_KEY_ID}"
      MINIO_ROOT_PASSWORD: "${AWS_SECRET_ACCESS_KEY}"
    ports:
      - "${MINIO_PORT}:9000"
      - "${MINIO_WEB_PORT}:9001"
    volumes:
      - ./storage/minio:/data
    healthcheck:
      test: bash -c ':> /dev/tcp/127.0.0.1/9000' || exit 1
      interval: 5s
      timeout: 10s
      retries: 3
    networks:
      default:
        aliases:
          - "${MINIO_BUCKET}.minio" # <bucket-name>.<endpoint-name>

  create-bucket:
    image: minio/mc:latest
    environment:
      MC_HOST_minio: http://${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}@minio:${MINIO_PORT}
    restart: no
    depends_on:
      - minio
    entrypoint:
      - sh
      - -c
      - mc mb minio/${MINIO_BUCKET}

  any-sync-coordinator_bootstrap:
    image: "ghcr.io/anyproto/any-sync-coordinator:${ANY_SYNC_COORDINATOR_VERSION}"
    depends_on:
      - mongo-1
    volumes:
      - ./etc/any-sync-coordinator/:/etc/any-sync-coordinator/
    restart: no
    command: bash -c "sleep 10; /bin/any-sync-confapply -c /etc/any-sync-coordinator/config.yml -n /etc/any-sync-coordinator/network.yml -e"

  any-sync-coordinator:
    image: "ghcr.io/anyproto/any-sync-coordinator:${ANY_SYNC_COORDINATOR_VERSION}"
    depends_on:
      - any-sync-coordinator_bootstrap
    ports:
      - "${ANY_SYNC_COORDINATOR_PORT}:${ANY_SYNC_COORDINATOR_PORT}"
      - "${ANY_SYNC_COORDINATOR_QUIC_PORT}:${ANY_SYNC_COORDINATOR_QUIC_PORT}"
      - 8005:8000
    volumes:
      - ./etc/any-sync-coordinator/:/etc/any-sync-coordinator/
      - ./storage/networkStore/any-sync-coordinator/:/networkStore/
    deploy:
      resources:
        limits:
          memory: 500M
    restart: on-failure
    command: bash -c "sleep 10; /bin/any-sync-coordinator -c /etc/any-sync-coordinator/config.yml"

  any-sync-filenode:
    image: "ghcr.io/anyproto/any-sync-filenode:${ANY_SYNC_FILENODE_VERSION}"
    depends_on:
      - redis
      - minio
      - any-sync-coordinator
    ports:
      - "${ANY_SYNC_FILENODE_PORT}:${ANY_SYNC_FILENODE_PORT}"
      - "${ANY_SYNC_FILENODE_QUIC_PORT}:${ANY_SYNC_FILENODE_QUIC_PORT}"
      - 8004:8000
    volumes:
      - ./etc/any-sync-filenode/:/etc/any-sync-filenode/
      - ./etc/.aws:/root/.aws:ro
      - ./storage/networkStore/any-sync-filenode/:/networkStore/
    deploy:
      resources:
        limits:
          memory: 500M
    restart: on-failure
    command: bash -c "sleep 15; /bin/any-sync-filenode -c /etc/any-sync-filenode/config.yml"

  any-sync-node-1:
    image: "ghcr.io/anyproto/any-sync-node:${ANY_SYNC_NODE_VERSION}"
    depends_on:
      - any-sync-coordinator
    ports:
      - "${ANY_SYNC_NODE_1_PORT}:${ANY_SYNC_NODE_1_PORT}"
      - "${ANY_SYNC_NODE_1_QUIC_PORT}:${ANY_SYNC_NODE_1_QUIC_PORT}"
      - 8081:8080
      - 8001:8000
    volumes:
      - ./etc/any-sync-node-1/:/etc/any-sync-node/
      - ./storage/any-sync-node-1/:/storage/
      - ./storage/networkStore/any-sync-node-1/:/networkStore/
    deploy:
      resources:
        limits:
          memory: 500M
    restart: on-failure
    command: bash -c "sleep 15; /bin/any-sync-node -c /etc/any-sync-node/config.yml"

  any-sync-node-2:
    image: "ghcr.io/anyproto/any-sync-node:${ANY_SYNC_NODE_VERSION}"
    depends_on:
      - any-sync-coordinator
    ports:
      - "${ANY_SYNC_NODE_2_PORT}:${ANY_SYNC_NODE_2_PORT}"
      - "${ANY_SYNC_NODE_2_QUIC_PORT}:${ANY_SYNC_NODE_2_QUIC_PORT}"
      - 8082:8080
      - 8002:8000
    volumes:
      - ./etc/any-sync-node-2/:/etc/any-sync-node/
      - ./storage/any-sync-node-2/:/storage/
      - ./storage/networkStore/any-sync-node-2/:/networkStore/
    deploy:
      resources:
        limits:
          memory: 500M
    restart: on-failure
    command: bash -c "sleep 15; /bin/any-sync-node -c /etc/any-sync-node/config.yml"

  any-sync-node-3:
    image: "ghcr.io/anyproto/any-sync-node:${ANY_SYNC_NODE_VERSION}"
    depends_on:
      - any-sync-coordinator
    ports:
      - "${ANY_SYNC_NODE_3_PORT}:${ANY_SYNC_NODE_3_PORT}"
      - "${ANY_SYNC_NODE_3_QUIC_PORT}:${ANY_SYNC_NODE_3_QUIC_PORT}"
      - 8083:8080
      - 8003:8000
    volumes:
      - ./etc/any-sync-node-3/:/etc/any-sync-node/
      - ./storage/any-sync-node-3/:/storage/
      - ./storage/networkStore/any-sync-node-3/:/networkStore/
    deploy:
      resources:
        limits:
          memory: 500M
    restart: on-failure
    command: bash -c "sleep 15; /bin/any-sync-node -c /etc/any-sync-node/config.yml"

  any-sync-consensusnode:
    image: "ghcr.io/anyproto/any-sync-consensusnode:${ANY_SYNC_CONSENSUSNODE_VERSION}"
    depends_on:
      - any-sync-coordinator
    ports:
      - "${ANY_SYNC_CONSENSUSNODE_PORT}:${ANY_SYNC_CONSENSUSNODE_PORT}"
      - "${ANY_SYNC_CONSENSUSNODE_QUIC_PORT}:${ANY_SYNC_CONSENSUSNODE_QUIC_PORT}"
      - 8006:8000
    volumes:
      - ./etc/any-sync-consensusnode/:/etc/any-sync-consensusnode/
      - ./storage/networkStore/any-sync-consensusnode/:/networkStore/
    deploy:
      resources:
        limits:
          memory: 500M
    restart: on-failure
    command: bash -c "sleep 15; /bin/any-sync-consensusnode -c /etc/any-sync-consensusnode/config.yml"

  any-sync-admin:
    image: "ghcr.io/anyproto/any-sync-admin:${ANY_SYNC_ADMIN_VERSION}"
    depends_on:
      - redis
      - mongo-1
    ports:
      - "${EXTERNAL_ANY_SYNC_ADMIN_PORT}:${ANY_SYNC_ADMIN_PORT}"
    volumes:
      - ./etc/any-sync-admin/:/etc/any-sync-admin/
    restart: on-failure

The replica-set initalization command has been changed here and the mongo-2 and mongo-3 services have been removed.

  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
Copy link
Collaborator

fb929 commented Apr 5, 2024

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
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants