- 浏览: 2486565 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
MongoDB Docker and Raspberry Pi
1 Set up MongoDB in Docker
Simple Make file
IMAGE=sillycat/public
TAG=raspberrypi-mongodb
NAME=raspberrypi-mongodb
docker-context:
build: docker-context
docker build -t $(IMAGE):$(TAG) .
run-init:
docker run -d -p 27017:27017 -p 28017:28017 -v /mnt/driver1/data/mongodb:/var/lib/mongodb -v /opt/mongodb/log:/var/log/mongodb -e RUNNING_MODULE=INIT --name $(NAME) $(IMAGE):$(TAG)
run:
docker run -d -p 27017:27017 -p 28017:28017 -v /mnt/driver1/data/mongodb:/var/lib/mongodb -v /opt/mongodb/log:/var/log/mongodb -e RUNNING_MODULE=RUN --name $(NAME) $(IMAGE):$(TAG)
debug:
docker run -ti -p 27017:27017 -p 28017:28017 -v /mnt/driver1/data/mongodb:/var/lib/mongodb -v /opt/mongodb/log:/var/log/mongodb --name $(NAME) $(IMAGE):$(TAG) /bin/bash
clean:
docker stop ${NAME}
docker rm ${NAME}
logs:
docker logs ${NAME}
publish:
docker push ${IMAGE}:${TAG}
fetch:
docker pull ${IMAGE}:${TAG}
Docker file is also simple, because it is an apt-get install
#Set up FTP in Docker
#Prepre the OS
FROM resin/rpi-raspbian:jessie
MAINTAINER Carl Luo <luohuazju@gmail.com>
ENV DEBIAN_FRONTEND noninteractive
ENV DAEMONUSER root
RUN echo "deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi\n\
deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi\n\
" > /etc/apt/sources.list
RUN apt-get -y update
RUN apt-get -y dist-upgrade
#install mongod soft
RUN apt-get -y install mongodb-server
#configure the server
ADD conf/mongodb.conf /etc/
ADD conf/mongodb_auth.conf /etc/mongodb_auth.conf
ADD conf/mongodb_noauth.conf /etc/mongodb_noauth.conf
#start the application
EXPOSE 27017 28017
RUN mkdir -p /app/
ADD start.sh /app/
WORKDIR /app/
CMD [ "./start.sh" ]
For the configuration mongoldb.conf, I only change the auth and bind_ip
bind_ip = 0.0.0.0
port = 27017
The flow will be system start mongo, add admin user, enable auth and restart the mongoDB
start.sh is as follow:
#!/bin/sh -ex
if [ "$RUNNING_MODULE" = "INIT" ]; then
#start non auth server
/etc/init.d/mongodb start
#sleep 2 minutes
sleep 2m
# add user
mongo admin --eval "db.addUser('supper', ‘password')"
# set auth and restart
cp /etc/mongodb_auth.conf /etc/mongodb.conf
/etc/init.d/mongodb restart
else
# set auth
cp /etc/mongodb_auth.conf /etc/mongodb.conf
# start server
/etc/init.d/mongodb start
fi
# Run mongo as the running process, this is required to keep the docker process running
tail -f /dev/null
Check mongoDB AUTH
> show dbs
admin 0.0625GB
local 0.03125GB
mydb 0.0625GB
test 0.0625GB
2 Switch to use admin DB
> use admin
switched to db admin
check if there is any users in DB
> db.system.users.find();
add user in admin
> db.addUser("super","password")
Verify auth
> db.auth("super","password")
1
Login to the auth user with command
> mongo --host sillycat.ddns.net --port 27017 -usuper -ppassword --authenticationDatabase admin
It may required username and password with params
-u username -p password
Connect to my server
> mongo --host sillycat.ddns.net --port 27017
Choose database
> use mydb;
New/Save/Query data
> j = {name:"mongo"};
> db.things.save(j);
> db.things.find();
dump command all the database
> mongodump -h sillycat.ddns.net -o ~/data/mongodb/
restore all the database
> mongorestore -h sillycat.ddns.net ~/data/mongodb/ --drop
References:
mongoDB
http://yannickloriot.com/2016/04/install-mongodb-and-node-js-on-a-raspberry-pi/
http://blog.51yip.com/nosql/1573.html
http://www.runoob.com/mongodb/mongodb-mongodump-mongorerstore.html
redis
http://andreas-kongelstad.tumblr.com/post/51622770030/part-2-installing-redis-on-raspberry-pi
mongoDB AUTH
http://bubkoo.com/2014/02/07/mongodb-authentication/
http://stackoverflow.com/questions/10743905/how-can-i-use-a-script-to-create-users-in-mongodb
http://stackoverflow.com/questions/22682891/create-a-mongodb-user-from-commandline
1 Set up MongoDB in Docker
Simple Make file
IMAGE=sillycat/public
TAG=raspberrypi-mongodb
NAME=raspberrypi-mongodb
docker-context:
build: docker-context
docker build -t $(IMAGE):$(TAG) .
run-init:
docker run -d -p 27017:27017 -p 28017:28017 -v /mnt/driver1/data/mongodb:/var/lib/mongodb -v /opt/mongodb/log:/var/log/mongodb -e RUNNING_MODULE=INIT --name $(NAME) $(IMAGE):$(TAG)
run:
docker run -d -p 27017:27017 -p 28017:28017 -v /mnt/driver1/data/mongodb:/var/lib/mongodb -v /opt/mongodb/log:/var/log/mongodb -e RUNNING_MODULE=RUN --name $(NAME) $(IMAGE):$(TAG)
debug:
docker run -ti -p 27017:27017 -p 28017:28017 -v /mnt/driver1/data/mongodb:/var/lib/mongodb -v /opt/mongodb/log:/var/log/mongodb --name $(NAME) $(IMAGE):$(TAG) /bin/bash
clean:
docker stop ${NAME}
docker rm ${NAME}
logs:
docker logs ${NAME}
publish:
docker push ${IMAGE}:${TAG}
fetch:
docker pull ${IMAGE}:${TAG}
Docker file is also simple, because it is an apt-get install
#Set up FTP in Docker
#Prepre the OS
FROM resin/rpi-raspbian:jessie
MAINTAINER Carl Luo <luohuazju@gmail.com>
ENV DEBIAN_FRONTEND noninteractive
ENV DAEMONUSER root
RUN echo "deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi\n\
deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi\n\
" > /etc/apt/sources.list
RUN apt-get -y update
RUN apt-get -y dist-upgrade
#install mongod soft
RUN apt-get -y install mongodb-server
#configure the server
ADD conf/mongodb.conf /etc/
ADD conf/mongodb_auth.conf /etc/mongodb_auth.conf
ADD conf/mongodb_noauth.conf /etc/mongodb_noauth.conf
#start the application
EXPOSE 27017 28017
RUN mkdir -p /app/
ADD start.sh /app/
WORKDIR /app/
CMD [ "./start.sh" ]
For the configuration mongoldb.conf, I only change the auth and bind_ip
bind_ip = 0.0.0.0
port = 27017
The flow will be system start mongo, add admin user, enable auth and restart the mongoDB
start.sh is as follow:
#!/bin/sh -ex
if [ "$RUNNING_MODULE" = "INIT" ]; then
#start non auth server
/etc/init.d/mongodb start
#sleep 2 minutes
sleep 2m
# add user
mongo admin --eval "db.addUser('supper', ‘password')"
# set auth and restart
cp /etc/mongodb_auth.conf /etc/mongodb.conf
/etc/init.d/mongodb restart
else
# set auth
cp /etc/mongodb_auth.conf /etc/mongodb.conf
# start server
/etc/init.d/mongodb start
fi
# Run mongo as the running process, this is required to keep the docker process running
tail -f /dev/null
Check mongoDB AUTH
> show dbs
admin 0.0625GB
local 0.03125GB
mydb 0.0625GB
test 0.0625GB
2 Switch to use admin DB
> use admin
switched to db admin
check if there is any users in DB
> db.system.users.find();
add user in admin
> db.addUser("super","password")
Verify auth
> db.auth("super","password")
1
Login to the auth user with command
> mongo --host sillycat.ddns.net --port 27017 -usuper -ppassword --authenticationDatabase admin
It may required username and password with params
-u username -p password
Connect to my server
> mongo --host sillycat.ddns.net --port 27017
Choose database
> use mydb;
New/Save/Query data
> j = {name:"mongo"};
> db.things.save(j);
> db.things.find();
dump command all the database
> mongodump -h sillycat.ddns.net -o ~/data/mongodb/
restore all the database
> mongorestore -h sillycat.ddns.net ~/data/mongodb/ --drop
References:
mongoDB
http://yannickloriot.com/2016/04/install-mongodb-and-node-js-on-a-raspberry-pi/
http://blog.51yip.com/nosql/1573.html
http://www.runoob.com/mongodb/mongodb-mongodump-mongorerstore.html
redis
http://andreas-kongelstad.tumblr.com/post/51622770030/part-2-installing-redis-on-raspberry-pi
mongoDB AUTH
http://bubkoo.com/2014/02/07/mongodb-authentication/
http://stackoverflow.com/questions/10743905/how-can-i-use-a-script-to-create-users-in-mongodb
http://stackoverflow.com/questions/22682891/create-a-mongodb-user-from-commandline
发表评论
-
Update Site will come soon
2021-06-02 04:10 1609I am still keep notes my tech n ... -
Stop Update Here
2020-04-28 09:00 260I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 430NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 310Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 321Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 291Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 378Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 373Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 326Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 397VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 334Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 415NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 359Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 291Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 207GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 390GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 274GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 263Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 259Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 251Serverless with NodeJS and Tenc ...
相关推荐
详细介绍了在docker下部署mongodb的方法以及启动命令及设置容器开机自启动的命令。文章末还介绍了“当使用docker容器的时候有可能出现以下情况:IPv4转发已禁用”解决方法。
bitnami-docker-mongodb:Bitnami MongoDB Docker映像
不幸的是,VirtualBox用于在主机系统和Docker容器之间共享文件夹的机制与MongoDB使用的内存映射文件不兼容(请参阅 , 和相关的 )。 这意味着无法运行将数据目录映射到主机的MongoDB容器。 – Docker Hub( 或) ...
被归类为NoSQL数据库的MongoDB避开了传统的基于表的关系数据库结构,转而使用具有动态模式的JSON类文档(MongoDB称为BSON格式),从而使数据在某些类型的应用程序中的集成更加容易和快捷。 MongoDB是在GNU Affero...
仅22.7M的docker mongodb镜像 很方便的创建mongodb数据库容器 使用方式:docker load -i mongodb_3.2.4-image.tar.gz 容器内使用busybox环境
docker run --name mongodb -v ~/docker/mongo:/data/db -p 27017:27017 -d mongo 执行上述命令之后, 一个挂载了 mongo镜像的容器就开始运行了 其中 --name 设置了容器的名字 -v 设置了路径的映射, 将本地路径映射...
主机上的/data/db )以避免图像被破坏时数据丢失基本图像[mpangrazzi:debian]安装docker pull mpangrazzi/mongodb 或者: docker build -t="mpangrazzi/mongodb" github.com/mpangrazzi/docker-mongodb 用法首先,...
基于Python+Flask+MongoDB+Docker的个人博客系统-毕业设计源码+使用文档(高分优秀项目) 该项目是个人高分毕业设计项目源码,已获导师指导认可通过,答辩评审分达到97分,在window10/11测试环境严格调试,下载即用...
我们正在使用 MongoDB 启动 3 个 docker 容器,它们在端口27017 、 27018和27019 。 指示 克隆这个仓库 $ git clone git@github.com:klivan/docker-mongodb-replicaset.git 从 Dockerfile 构建 docker 镜像 $ cd ...
Build an interactive and full-featured web application from scratch using Node.js and MongoDB About This Book Configure your development environment to use Node.js and MongoDB Use Node.js to connect ...
MongoDB_and_Python.pdf
节点Express MongoDB Docker 一个参考项目,用于使用Docker容器化Node Express应用程序,以及使用MongoDB的持久数据库 在本地构建/运行 在项目根目录中,运行以下命令: docker build -t node-express-mongodb-...
在开发板上解压,直接./install.sh运行脚本,将会自动安装mongodb
MongoDB and Python Patterns and processes for the popular document-oriented database
使用python脚本和docker部署mongodb集群, 支持多种角色, 并且支持, 复制集群和分片集群. 具体参数配置看脚本
ubuntu docker 下mongodb集群和分片.rar
有关如何使用此Docker映像的完整自述文件以及有关贡献和问题的信息,请参阅。 的是在生成/维护的,尤其是。 看到此处合并的更改尚未出现在Docker Hub上吗? 有关完整的正式映像更改生命周期的更多信息,请参阅 。...
These binaries do NOT support SSL and only run under Raspian Stretch on a Raspberry Pi 3. [UPDATE — 2018 Mar 22] I have confirmed that these binaries work on the latest Raspberry Pi 3 Model B+ with ...
sudo docker pull mongo 运行 mongodb 服务 sudo docker run -p 27017:27017 -v /tmp/db:/data/db -d mongo 运行 mongodb 客户端 sudo docker run -it mongo mongo --host <宿主机IP地址> --port 27017 > ...
docker mongodb