MongoDB

Материал из First-Leon
Перейти к: навигация, поиск

Установка

3.2

apt-get update
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
apt-get install mongodb-org

3.4

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
sudo apt-get update 
sudo apt-get install mongodb-org
sudo service mongod start
sudo systemctl status mongod

4.0

apt-get install gnupg2
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
apt-get update 
apt-get install mongodb-org
service mongod start
systemctl status mongod


Настройка

В файле: /etc/mongod.conf

bindIp: 0.0.0.0

mcedit /lib/systemd/system/mongod.service
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
Documentation=https://docs.mongodb.org/manual

[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target

Установка mongo-express

npm install -g mongo-express

В файле: /usr/lib/node_modules/mongo-express/config.js

host:             process.env.VCAP_APP_HOST                 || '0.0.0.0',
admin: process.env.ME_CONFIG_MONGODB_ENABLE_ADMIN ? process.env.ME_CONFIG_MONGODB_ENABLE_ADMIN.toLowerCase() === 'true' : true,

Запускаем:

mongo-express -P 27017

Конфиг supervisor:

mcedit /etc/supervisor/conf.d/mongo-express.conf
[program:mongo-express]
command = node --trace-warnings /usr/bin/mongo-express
directory = /usr/lib/node_modules/mongo-express
environment=NODE_PATH=".:./lib"
autostart=true
autorestart = true
user = root
stderr_logfile=/var/log/supervisor/mongo-express-err.log
stdout_logfile=/var/log/supervisor/mongo-express-out.log

Ссылки