{"id":15195023,"url":"https://github.com/auth0/coreos-mongodb","last_synced_at":"2025-10-02T10:31:32.299Z","repository":{"id":21906746,"uuid":"25230791","full_name":"auth0/coreos-mongodb","owner":"auth0","description":"CoreOS MongoDB units ","archived":true,"fork":false,"pushed_at":"2016-02-04T12:59:21.000Z","size":194,"stargazers_count":52,"open_issues_count":5,"forks_count":18,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-09-28T23:05:30.127Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/auth0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-14T23:24:50.000Z","updated_at":"2023-01-28T18:40:12.000Z","dependencies_parsed_at":"2022-07-17T01:15:59.068Z","dependency_job_id":null,"html_url":"https://github.com/auth0/coreos-mongodb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fcoreos-mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fcoreos-mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fcoreos-mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fcoreos-mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/auth0","download_url":"https://codeload.github.com/auth0/coreos-mongodb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234974912,"owners_count":18916143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-27T23:05:38.535Z","updated_at":"2025-10-02T10:31:31.971Z","avatar_url":"https://github.com/auth0.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"Deploy a replicaset to coreos like a boss.\nAuto-discover new members via etcd.\n\n## Deploy\n\n```\nfleetctl destroy mongo@{1..3}.service  mongo-replica-config.service \n\netcdctl set /mongo/replica/name myreplica\n\nfleetctl start mongo@{1..3}.service mongo-replica-config.service\n```\n\n## Connect\n\nYou can test connecting to your replica from one of your nodes as follows:\n\n```\nfleetctl-ssh\n\nCOREOS_PRIVATE_IPV4=xx.xx.xx.xxx; echo $COREOS_PRIVATE_IPV4\n\nSITE_USR_ADMIN_PWD=$(etcdctl get /mongo/replica/siteUserAdmin/pwd); echo $SITE_USR_ADMIN_PWD\n\nSITE_ROOT_PWD=$(etcdctl get /mongo/replica/siteRootAdmin/pwd); echo $SITE_ROOT_PWD\n\ndocker run -it --rm mongo:2.6 mongo $COREOS_PRIVATE_IPV4/admin  -u siteRootAdmin -p $SITE_ROOT_PWD\n\n\n$ Welcome to the MongoDB shell.\n```\n\n\n### Trouble shooting\n\nIn my shell rc file (~/.zsh_aliases)\n```\nfleetctl-switch(){\n  ssh-add ~/.docker/certs/key.pem\n  DOCKER_HOST=tcp://$1:2376\n  export FLEETCTL_TUNNEL=$1:22\n  alias etcdctl=\"ssh -A core@$1 'etcdctl'\"\n  alias fleetctl-ssh=\"fleetctl ssh $(fleetctl list-machines | cut -c1-8 | sed -n 2p)\"\n  RPROMPT=\"%{$fg[magenta]%}[fleetctl:$1]%{$reset_color%}\"\n}\ndestroy_mongo_replica() {\n  export FLEETCTL_TUNNEL=$1:22\n  fleetctl destroy mongo@{1..3}.service\n  fleetctl destroy mongo@.service\n  fleetctl destroy mongo-replica-config.service\n\n  etcdctl rm /mongo/replica/siteRootAdmin --recursive\n  etcdctl rm /mongo/replica/siteUserAdmin --recursive\n  etcdctl rm /mongo/replica --recursive\n  etcdctl set /mongo/replica/name myreplica\n\n  echo 'Listing etcd /mongo dirs...'\n  ssh -A core@$1 'etcdctl ls /mongo --recursive';\n\n  echo Listing $1 /var/mongo\n  ssh -A core@$1 'sudo rm -rf /var/mongo/*'\n  ssh -A core@$1 'ls /var/mongo/'\n\n  echo Listing $2 /var/mongo\n  ssh -A core@$2 'sudo rm -rf /var/mongo/*'\n  ssh -A core@$2 'ls /var/mongo/'\n\n  echo Listing $3 /var/mongo\n  ssh -A core@$3 'sudo rm -rf /var/mongo/*'\n  ssh -A core@$3 'ls /var/mongo/'\n}\n```\n\nTo start,\n```\nfleetctl-switch xx.xx.xx.xx\nfleetctl start mongo@{1..3}.service mongo-replica-config.service\n```\n\nTo see what's going on in a server,\n```\nfleetctl-ssh\n```\n\nTo delete all mongodb files,\n```\ndestroy_mongo_replica \u003ccluser ip 1\u003e \u003ccluser ip 2\u003e \u003ccluser ip 3\u003e\n```\n\n## How it works?\n\nThe units follow the process explained in this [tutorial](http://docs.mongodb.org/manual/tutorial/deploy-replica-set-with-auth/).\n\nI've split the process in 3 different phases.\n\n### Phase 1\n\nDuring the initial phase, mongo needs to be run without the authentication option and without the keyFile.\n\nWe just run the first node of the replicaset while the other are waiting the key file in etcd.\n\n-  The `siteUserAdmin` and `siteRootAdmin` are created on the first node with random passwords stored in etcd.\n-  The keyfile is generated and added to etcd.\n-  All mongodb are started.\n\n### Phase 2\n\nDuring the second phase, we have all the nodes of the replica running and ready to bind each other.\n\n-  `rs.initiate` is run in the first node.\n-  `rs.add` is run for every node except the fisrt one which is automatically added.\n\n### Phase 3\n\nThe third phase is the final state, we keep watching etcd for new nodes and these new nodes.\n\n## Destroy and revert everything\n\n```\n# remove all units\n$ fleetctl destroy mongo@{1..3}.service\n$ fleetctl destroy mongo-replica-config.service\n# or\n$ fleetctl list-units --no-legend | awk '{print $1}' | xargs -I{} fleetctl destroy {}\n\n# clean directories\n$ fleetctl list-machines --fields=\"machine\" --full --no-legend | xargs -I{} fleetctl ssh {} \"sudo rm -rf /var/mongo/*\"\n\n(from inside one of the nodes)\n$ etcdctl rm /mongo/replica/key\n$ etcdctl rm --recursive /mongo/replica/siteRootAdmin\n$ etcdctl rm --recursive /mongo/replica/siteUserAdmin\n$ etcdctl rm --recursive /mongo/replica/nodes\n```\n\n## License\n\nMIT - Copyright (c) 2014 AUTH0 INC.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0%2Fcoreos-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauth0%2Fcoreos-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0%2Fcoreos-mongodb/lists"}