Skip to content

Instantly share code, notes, and snippets.

@maniac787
Last active November 7, 2020 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maniac787/aa6dec4a834d0c409160ce70fa0b9b21 to your computer and use it in GitHub Desktop.
Save maniac787/aa6dec4a834d0c409160ce70fa0b9b21 to your computer and use it in GitHub Desktop.
Mongo as service
Unzip file
tar -xvzf mongodb-linux-x86_64-ubuntu2004-4.4.1
create log folder
create mongod.conf into mongo_home
#Data storage locations
storage:
dbPath: /home/roberto/data/
journal:
enabled: true
wiredTiger:
engineConfig:
cacheSizeGB: 1
#Logs storage localtions
systemLog:
destination: file
logAppend: true
path: /home/roberto/logs/mongod.log
#Network interfaces
net:
port: 27017
bindIp: 0.0.0.0
security:
authorization: enabled
update ~/.bashrc
export PATH=/home/roberto/mongodb/bin:$PATH
source ~/.bashrc
mongod --dbpath=/home/roberto/data --config /home/roberto/mongodb/mongod.conf
netstat -plntu
sudo apt install net-tools
netstat -anp | grep -i 27017
# Creando el servicio
cd /etc/systemd/system/
ll
sudo touch /etc/mongod.conf; sudo nano /etc/mongod.conf
sudo touch /lib/systemd/system/mongod.service; sudo vi /lib/systemd/system/mongod.service
[Unit]
Description=MongoDB
After=syslog.target network.target
[Service]
Type=simple
User=root
Group=root
ExecStart=/home/roberto/mongodb/bin/mongod --config /home/roberto/mongodb/mongod.conf
[Install]
WantedBy=multi-user.target
sudo systemctl enable mongod.service
sudo systemctl start mongod.service
sudo apt install mongo-tools
mongodump -h 45.00.00.00 -u user -p pass --forceTableScan --authenticationDatabase admin -d denuncia_db --archive=/home/roberto/backup/backup.archive
mongorestore --archive=/home/roberto/backup/backup.archive --db denuncia_db -h 45.00.00.00 -u user -p pass --authenticationDatabase admin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment