- 浏览: 2551368 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
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=xxxxxxt/public
TAG=xxxxx-mongodb
NAME=xxxxx-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=xxxxxxt/public
TAG=xxxxx-mongodb
NAME=xxxxx-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
发表评论
-
Stop Update Here
2020-04-28 09:00 315I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 475NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 367Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 368Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 336Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 430Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 435Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 373Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 454VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 384Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 477NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 422Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 337Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 246GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 450GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 326GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 313Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 317Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 292Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 311Serverless with NodeJS and Tenc ...
相关推荐
9. **部署与运维**:学习如何在Raspberry Pi上部署应用程序,可能涉及到Docker容器化、自动化部署工具如Ansible等。 10. **文档编写**:良好的项目文档是必不可少的,包括设计文档、用户手册和开发者指南等。 通过...
《RaspberryShop:基于Raspberry Pi灵感的电子商务平台构建详解》 在当今的数字化时代,电子商务平台已经成为商业运作的重要组成部分。而"RaspberryShop"是一个独特的项目,它以树莓派(Raspberry Pi)为灵感,利用...
其次,Pi4J是一个用于Raspberry Pi的Java库,它允许开发者通过GPIO(通用输入/输出)接口直接控制Raspberry Pi的硬件。GPIO接口允许我们与外部电子设备交互,例如传感器、电机、LED灯等。在智能家居系统中,Pi4J可能...
该项目已在RaspberryPi 3上进行了测试。API请求包含多个位置。 Openweathermap.org API openweathermap组织免费提供API,每天限制1000个请求,每小时限制60个调用。 其他计划可用。 生成单独的API密钥没有任何限制...
AIOT物联网与感测装置介绍D01 AIOT人工智慧物联网介绍D02感测器介绍D03感测器...docker使用D08 MonogoDB大数据资料库介绍与安装实作基本的MonogoDB使用D09 Python访问MongoDB常用指令与程序教学pymongo增删改改查D10 ...
您当然可以在具有docker和docker-compose的任何计算机上运行此程序,但是它已针对Raspberry Pi(Mongo数据库)进行了优化。 它包括Node-Red,Mosquitto Broker和Mongo Database的预配置容器。 节点红色还包括许多...
在设置完Raspberry pi并在DHT11温湿度传感器中进行接线后,我们将以一个简单的python脚本开始,该脚本通过REST API webhook通过2-docker-setup-broker.sh直接将数据发送到MongoDB。 然后,我们将增强此简单代码,...
将服务部署在Raspberry Pi群集中以访问并创建用户。 随意使用其他语言( Ruby?, C#? )创建新的微服务,请遵循以下最低要求: 在根目录上创建一个新文件夹,并将代码放入 添加最少的文档 添加Rest API 添加JWT...
9. **物联网(IoT)**:可能包括硬件接口(如Arduino、Raspberry Pi)、传感器数据采集、MQTT协议、云平台集成(如AWS IoT、Azure IoT Hub)。 10. **区块链技术**:可能研究比特币、以太坊等公链,或者是智能合约的...
例如,可能有基于AI的小游戏、利用Arduino或Raspberry Pi制作的DIY硬件项目、数据可视化的艺术作品等。这些内容通常旨在激发学习兴趣,让技术学习更加生动有趣。 5. **Learning-Sharing-master**: 文件名...
同时,考虑到物联网(IoT)和云计算的运用,可能涉及到MQTT协议、RESTful API、Docker容器化技术、数据库(如MySQL、MongoDB)以及云计算平台(如AWS、Azure或Google Cloud)等。 4. **硬件集成**: 智能农业离不开...
3. **开源硬件**:可能讨论了Arduino、Raspberry Pi等开源硬件平台,以及它们在物联网(IoT)中的应用。 4. **开源移动平台**:如Android的发展状况,以及如何参与开源移动平台的开发。 开源时代200904(第八期)可能...
4. **硬件交互**:如果"家感"项目涉及硬件,如Arduino或Raspberry Pi,我们需要了解如何使用Node.js库(如Johnny-Five或Pi GPIO)来控制GPIO端口,与传感器和执行器进行通信。 5. **数据库集成**:存储和检索设备...
2. **Python库**:如`paho-mqtt`用于实现MQTT协议,`Adafruit_Python_DHT`用于读取DHT系列湿度和温度传感器数据,`RPi.GPIO`在Raspberry Pi上进行GPIO操作等。 3. **设备管理**:如何注册新设备,跟踪其状态,执行...
4. **硬件交互**:Python有多个库如`RPi.GPIO`(针对Raspberry Pi)、`Adafruit_Python_DHT`(DHT系列湿度和温度传感器)等,可以方便地控制硬件设备,读取传感器数据。 5. **事件驱动编程**:对于实时性要求较高的...
5. **物联网(IoT)**:传感器数据的收集可能涉及 IoT 设备,如 Raspberry Pi 配合各种环境传感器。这些设备通过 MQTT 或 CoAP 协议与服务器通信。 6. **地图与定位**:用户界面中绘制房屋布局可能使用地图API,如 ...