Skip to content

Instantly share code, notes, and snippets.

@hkhoshraftar
Created April 19, 2020 06:36
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 hkhoshraftar/32ffdecd0147c2b81fbfa9f862d29bd7 to your computer and use it in GitHub Desktop.
Save hkhoshraftar/32ffdecd0147c2b81fbfa9f862d29bd7 to your computer and use it in GitHub Desktop.
cd /opt
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.5.tgz
tar -zxvf mongodb-linux-x86_64-4.0.5.gz
ln -s mongodb-linux-x86_64-4.0.5 mongodb
useradd mongod
mkdir -p /var/lib/mongo
chown -R mongod:mongod /opt/mongodb*
chown -R mongod: /var/lib/mongo
nano /etc/mongod.conf
-----------------------------
storage:2
dbPath: "/var/lib/mongo"
journal:
enabled: true
net:
port: 27017
bindIp: "127.0.0.1"
------------------------------
nano /etc/systemd/system/mongod.service
-----------------------------
[Unit]
Description=MongoDB
After=syslog.target network.target
[Service]
Type=simple
User=mongod
Group=mongod
ExecStart=/opt/mongodb/bin/mongod --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
-----------------------------
systemctl daemon-reload
systemctl status mongod
setenforce 0
systemctl daemon-reload
systemctl status mongod
systemctl start mongod
systemctl status mongod
nano /root/.bash_profile
------------------------
## mongodb
PATH=$PATH:/opt/mongodb/bin
------------------------
. ~/.bash_profile
setenforce 1
mongo
mongo shell
systemctl enable mongod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment