1、linux版本:
cat /proc/version
Linux version 3.10.0-1062.1.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) )
2、安装mongodb
省略100行文字。
以下操作都是root用户下操作
3、建立服务文件
1)进入“/etc/systemd/system”目录
2)创建“mongodb.service”文件
内容如下
[Unit]
Description=mongodb
After=network.target remote-fs.target nss-lookup.target
[Service]
User=bigdata
Group=bigdata
Type=forking
RuntimeDirectory=mongodb
RuntimeDirectoryMode=0751
# PIDFile=/home/bigdata/mongodb/run/mongod.pid
ExecStart=/home/bigdata/mongodb/bin/mongod --config /home/bigdata/mongodb/mongodb.conf
ExecStop=/home/bigdata/mongodb/bin/mongod --shutdown --config /home/bigdata/mongodb/mongodb.conf
PrivateTmp=false
[Install]
WantedBy=multi-user.target
注意:一定要注释掉“PIDFile”属性。
User、Group属性都是你自己的本机用户信息。
mongodb的目录都是你本机安装的位置。
4、注册为系统自启动服务
systemctl enable mongodb.service
5、启动系统服务
systemctl start mongodb.service