zoukankan      html  css  js  c++  java
  • Linux学习 -- 服务管理

      


    1 服务分类

      

      服务管理内容

        启动

        自启动

      查询已安装的服务

        RPM包安装的服务  自启动的   chkconfig --list   2345中如果是启用,代表下次开机会自启动

                 正在运行的服务   ps aux

        源码包安装的服务  

          查看服务的安装位置,一般是/usr/local/下

        系统运行级别 配置文件位于 /etc/inittab
          0 关机
          1 单用户 类似于Windows的安全模式,用户修复
          2 不完全多用户,不含NFS服务 文件共享服务,简单但不太安全
          3 完全多用户 字符界面
          4 未分配
          5 图形界面 X11 X window
          6 重启
        

        


    2 RPM服务的管理
      


      独立服务管理    
        /etc/init.d -> /etc/rc.d/init.d  软链接
        启动
          /etc/init.d/独立服务名 start|stop|restart|status 标准方式

          service 独立服务名 start|stop|restart|status redhat专有命令
            service --status-all 查询所有已安装的rpm独立服务

        自启动
       
    1 chkconfig 命令
             chkconfig --list | grep httpd       查询
             chkconfig [--level 2345] httpd on/off 开启/关闭 默认就是2345

          2 修改文件 /etc/rc.local -> /etc/rc.d/rc.local
            把要自启动的命令写入该文件中即可
              eg. /etc/rc.d/init.d/httpd start
              说明:文件中的 touch /var/lock/subsys/local 会记录系统启动的时间

          3 使用ntsysv工具 类似于setup 也是redhat专有
      
       
      基于xinetd服务的管理 超级守护进程 了解即可 一般不用
        安装xinetd与telnet
          yum -y install xinetd
          yum -y install telnet-server 仅学习,不安全,用完删

        启动
          vi /etc/xinetd.d/telnet    

          

          service xinetd restart  重启xinetd服务
       自启动
          chkconfig telnet on/off

          ntsysv

       注意:基于xinetd服务的启动和自启动是绑定的
        

    3 源码包服务的管理
      启动
        使用绝对路径,可以查看源码包的安装说明(INSTALL),查看启动脚本的方法
        eg. /usr/local/bin/apachectl start|stop
      
      自启动
        #vi /etc/rc.d/rc.local
        加入
        /usr/local/apache2/bin/apachectl start

      
      让源码包服务被 服务管理命令 识别 --不推荐,容易乱
        service命令是查找的位置: /etc/init.d/ -> /etc/rc.d/init.d/ 添加到这里即可
        ln -s /usr/local/apache2/bin/apachectl /etc/init.d/apache
        service apache start|stop|restart

      让源码包服务被 chkconfig与ntsysv命令 管理自启 --不推荐,容易乱
        vi /etc/init.d/apache 
        加入
        #chkconfig: 35 86 76 运行级别 启动顺序 关闭顺序
        #description: source package apache 说明,内容随意
        
        #chkconfig --add apache


    4 总结

      

    
    
    KEEP LEARNING!
  • 相关阅读:
    Satellite Basics
    Antenna basics
    Installing a Sailor 900 VSAT
    Installing Intellian VSAT
    IPTV、DVB、OTT的区别
    STM32两种下载方式
    Postman 使用指南
    elasticsearch term 查询之一
    Elasticsearch -from + size设置
    TIMESTAMP和DATETIME的区别
  • 原文地址:https://www.cnblogs.com/roronoa-sqd/p/4881383.html
Copyright © 2011-2022 走看看