设置mongodb.service启动服务

cd /lib/systemd/system
vi mongodb.service

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
    [Unit]  
    Description=mongodb  
    After=network.target remote-fs.target nss-lookup.target  
  
    [Service]  
    Type=forking  
    RuntimeDirectory=mongodb
    RuntimeDirectoryMode=0751
    PIDFile=/var/run/mongodb/mongod.pid
    ExecStart=/usr/mongodb/bin/mongod --config /usr/mongodb/mongodb.conf  
    ExecStop=/usr/mongodb/bin/mongod --shutdown --config /usr/mongodb/mongodb.conf  
    PrivateTmp=false  
  
    [Install]  
    WantedBy=multi-user.target

 


mongodb.service服务
 设置mongodb.service权限

chmod 754 mongodb.service

系统mongodb.service操作命令

#启动服务
systemctl start mongodb.service
#关闭服务
systemctl stop mongodb.service
#开机启动
systemctl enable mongodb.service
 mongodb.service启动测试


mongodb服务启动测试

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄