擴充套件Linux網路棧
阿新 • • 發佈:2020-12-07
1.下載mongodb安裝版本至linux伺服器,我這邊是/usr/local/src下面
2.解壓安裝包,將安裝包裡面的內容移動至/usr/local/mongodb下面
# tar zxvf mongodb-linux-x86_64-rhel70-4.2.0.tgz # mkdir /usr/local/mongodb # mv mongodb-linux-x86_64-rhel70-4.2.0/* /usr/local/mongodb/
3.切換至/usr/local/mongodb下,新建data資料夾,log資料夾
# cd mongodb/ # mkdir data # mkdir log
4.vim編輯mongodb.conf檔案
bind_ip=0.0.0.0 port=27017 dbpath=/usr/local/mongodb/data/ logpath=/usr/local/mongodb/log/mongodb.log pidfilepath =/usr/local/mongodb/run/mongodb.pid logappend=true fork=true journal=true maxConns=2000 auth = true
5.執行vim /etc/profile命令後按i鍵編輯,在檔案末尾加上如下配置
export PATH=/usr/local/mongodb/bin:$PATH
儲存退出後執行:source /etc/profile 重啟配置檔案
6.設定mongodb.service啟動服務
cd /lib/systemd/system
vi mongodb.service
[Unit] Description=MongoDB Database Server Documentation=https://docs.mongodb.org/manual After=network.target remote-fs.target nss-lookup.target [Service] Type=forking User=root Group=root ExecStart=/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf ExecStop=/usr/local/mongodb/bin/mongod --shutdown -f /usr/local/mongodb/mongodb.conf [Install] WantedBy=multi-user.target
mongodb.service服務許可權修改
chmod 754 mongodb.service
系統mongodb.service操作命令
#啟動服務 systemctl start mongodb.service #關閉服務 systemctl stop mongodb.service #開機啟動 systemctl enable mongodb.service