Skip to content

Instantly share code, notes, and snippets.

@BruceZu
Last active April 7, 2018 20:36
Show Gist options
  • Save BruceZu/6054cc22ad8a298999013f3edee14330 to your computer and use it in GitHub Desktop.
Save BruceZu/6054cc22ad8a298999013f3edee14330 to your computer and use it in GitHub Desktop.
Mongo replset in docker. Python access and verify Mongo replset.
mongo replica set 3.4.4 local docker engine (bridge)
@BruceZu
Copy link
Author

BruceZu commented May 26, 2017

=================
on sshhop prepare python environment same as the test environment : 3.5

$ sudo apt install virtualenv
$ pip install --upgrade virtualenv
$ pip install --upgrade pip
$ sudo apt install python3-venv

Reference
http://api.mongodb.com/python/current/examples/index.html
http://api.mongodb.com/python/current/api/pymongo/mongo_client.html
https://github.com/mongodb/mongo-python-driver?jmp=docs
https://stackoverflow.com/questions/22035257/django-non-rel-connecting-to-multiple-hosts-in-a-replica-set

@BruceZu
Copy link
Author

BruceZu commented May 27, 2017

connect mongo arbiter in docker

$ docker exec -it forticloudplatform_mongo_1    mongo mongodb://forticloudplatform_mongo_arbiter_1

run python from local 'worker' Docker container

$ docker exec -it $(docker ps | grep worker | cut -d" " -f 1) python

find out all place where the code need update: configuration and code

(.venv) bzu@bruce-laptop:~/project/FortiCloudPlatform$ grep -Rr "MONGODB" .  --exclude-dir=".venv" --exclude-dir=".idea" --exclude-dir=".git"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment