标签:remember password possible server change
在Docker中安装mongodb
采用的mongodb镜像:https://registry.hub.docker.com/u/tutum/mongodb/
以该镜像启动一个容器(注意此时mongodb是standalone模式):
docker run -d --name=mongodb -p 27017:27017 -p 28017:28017 tutum/mongodb:3.0
docker logs mongodb
输出信息:
========================================================================
You can now connect to this MongoDB server using:
mongo admin -u admin -p 5elsT6KtjrqV --host <host> --port <port>
Please remember to change the above password as soon as possible!
========================================================================
mongo admin -u admin -p 5elsT6KtjrqV
# set a password for admin when running a container
docker run -d --name=mongodb -p 27017:27017 -p 28017:28017 -e MONGODB_PASS="mypass" tutum/mongodb
# set empty password when running a container
docker run -d --name=mongodb -p 27017:27017 -p 28017:28017 -e AUTH=no tutum/mongodb
# login mongodb and change password
mongo admin -u admin -p vJQ6u0dshdn7 --host <host> --port <port>
> db.changeUserPassword("USERNAME", "PASSWORD")
在Docker中部署mongodb集群
以replset模式启动mongodb容器(所有节点):
docker run -d --name mongodb -p 27017:27017 -p 28017:28017 tutum/mongodb:3.0 mongod --replSet "rs0"
登录进容器,连接mongodb,并创建集群:(只需要在主节点执行)
docker exec -it mongodb /bin/bash
mongo
> rs.initiate()
> rs.add("node002.example.com")
> rs.add("node003.example.com")
> rs.status()
本文出自 “烟花易冷” 博客,请务必保留此出处http://yuanhuan.blog.51cto.com/3367116/1649386
标签:remember password possible server change
原文地址:http://yuanhuan.blog.51cto.com/3367116/1649386