Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 7 Current »

In /opt/zw-vmmc-docker/mongo you need to create entrypoint.sh:

  1. Create file:

    vim /opt/zw-vmmc-docker/mongo/entrypoint.sh
    chmod +x entrypoint.sh
  2. And paste the next lines:

    #!/bin/sh
    sleep 20
    
    echo "Restoring databases..."
    mongorestore --host mongo --port 27017 --username <mongo-user> --password <mongo-password> --authenticationDatabase admin --gzip --archive=/backups/db1-backup.gz
    mongorestore --host mongo --port 27017 --username <mongo-user> --password <mongo-password> --authenticationDatabase admin --gzip --archive=/backups/dbLog-backup.gz
    mongorestore --host mongo --port 27017 --username <mongo-user> --password <mongo-password> --authenticationDatabase admin --gzip --archive=/backups/dbOthers-backup.gz
    
    echo "creating users..."
    mongosh --host mongo --port 27017 --username gaspar --password gaspar --authenticationDatabase admin  <<EOF
    
    use admin
    db.createUser(
        {
            user: "<user>",
            pwd: "<password>",
            mechanisms: ["SCRAM-SHA-1"],
    	roles: [
                {
                    role: "readWrite",
                    db: "db1"
                },
                {
                    role: "readWrite",
                    db: "dbOthers"
                },
                {
                    role: "readWrite",
                    db: "dbLog"
                },
            ]
        }
    );
    use db1
    db.createUser(
        {
            user: "<user>",
            pwd: "<password>",
            mechanisms: ["SCRAM-SHA-1"],
    	roles: [
                {
                    role: "readWrite",
                    db: "db1"
                },
                {
                    role: "readWrite",
                    db: "dbOthers"
                },
                {
                    role: "readWrite",
                    db: "dbLog"
                },
            ]
        }
    );
    use dbOthers
    db.createUser(
        {
            user: "<user>",
            pwd: "<password>",
            mechanisms: ["SCRAM-SHA-1"],
    	roles: [
                {
                    role: "readWrite",
                    db: "db1"
                },
                {
                    role: "readWrite",
                    db: "dbOthers"
                },
                {
                    role: "readWrite",
                    db: "dbLog"
                },
            ]
        }
    );
    use dbLog
    db.createUser(
        {
            user: "<user>",
            pwd: "<password>",
            mechanisms: ["SCRAM-SHA-1"],
    	roles: [
                {
                    role: "readWrite",
                    db: "db1"
                },
                {
                    role: "readWrite",
                    db: "dbOthers"
                },
                {
                    role: "readWrite",
                    db: "dbLog"
                },
            ]
        }
    );
    
    exit
    
  3. You will need to replace “<user>” and “<pwd>” with the user and password existing here: mongo-user

  4. You will also need to download backups log-backup.gz, prod-backup.gz and dbOthers-backup.gz. Temporally, you can get them from api-dev.psi-connect.org, in the next path: /opt/tomcat/mongo-test-backups And paste in /opt/zw-vmmc-docker/mongo/backups

About the Mongo configuration, we will finish the configuration when we focus on the docker-compose.yml file.


Next: Tomcat folder ➡️

  • No labels