zoukankan      html  css  js  c++  java
  • Mongodb~Linux环境下的部署~服务的部署与自动化

    <mongodb在linux上的部署>

    事实上redis安装程序挺好,直接帮我们生成了服务,直接可以使用systemctl去启动它,而mongodb在这方面没有那么智能,需要我们去编写自己的服务脚本了,然后把它加到开机自启动里面就可以了,主要的过程分为以下几个步骤:

    mongodb我安装在了/root/tools目录下

    一 配置文件,ANSI,记事本编写,UTF8可能有问题

    dbpath=/root/tools/mongodb-linux-x86_64-amazon-3.4.2/db
    logpath=/root/tools/mongodb-linux-x86_64-amazon-3.4.2/log/mongo.log
    logappend=true  
    port=27017  
    fork=true  
    nohttpinterface=true  
    auth=false

    二 服务文件,文件位于:/usr/lib/systemd/system

    [Unit]  
    Description=mongodb   
    After=network.target remote-fs.target nss-lookup.target  
    [Service]  
    Type=forking  
    ExecStart=/root/tools/mongodb-linux-x86_64-amazon-3.4.2/bin/mongod --config /root/tools/mongodb-linux-x86_64-amazon-3.4.2/bin/mongodb.conf  
    ExecReload=/bin/kill -s HUP $MAINPID  
    ExecStop=/root/tools/mongodb-linux-x86_64-amazon-3.4.2/bin/mongod --shutdown --config /root/tools/mongodb-linux-x86_64-amazon-3.4.2/bin/mongodb.conf  
    PrivateTmp=true        
    [Install]  
    WantedBy=multi-user.target  

    三 服务命令

        #文件权限  
         chmod 754 mongodb.service  
        #启动服务  
        systemctl start mongodb.service    
        #关闭服务    
        systemctl stop mongodb.service    
        #开机启动    
        systemctl enable mongodb.service   

    这你几步之后,我们的mongodb服务就做好了!

    感谢各位阅读!

  • 相关阅读:
    JavaScript中函数和构造函数的区别
    如何使用less(变量,混合,匹配,运算,嵌套...)
    sublime text3 最常用的快捷键及插件
    ReentrantLock实现原理
    揭密FutureTask
    消息队列设计精要(转)
    漫谈MySql中的事务
    浅析Spring AOP
    理解java动态代理
    理解tomcat之搭建简易http服务器
  • 原文地址:https://www.cnblogs.com/lori/p/7145114.html
Copyright © 2011-2022 走看看