zoukankan      html  css  js  c++  java
  • 服务管理

    查看rpm包安装的服务:chkconfig --list

    [root@localhost ~]# chkconfig --list
    
    注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。 
          如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
          欲查看对特定 target 启用的服务请执行
          'systemctl list-dependencies [target]'。
    
    netconsole      0:关    1:关    2:关    3:关    4:关    5:关    6:关
    network         0:关    1:关    2:开    3:开    4:开    5:开    6:关  注释:数据代表6个不同的运行级别,0关机,1单用户,2不完全多用户,3多用户,4保留,5图形界面,6重启

     ps aux查看当前进程


    rpm服务:独立服务

    /etc/init.d/或/etc/rc.d/init.d  放置启动脚本的目录,这两个目录一模一样。

    /etc/xinetd.d  放置基于xinetd服务的启动脚本

    [root@localhost ~]# ls /etc/init.d
    functions  netconsole  network  README
    [root@localhost ~]# ll /etc/init.d/
    总用量 32
    -rw-r--r--. 1 root root 15131 9月  12 2016 functions
    -rwxr-xr-x. 1 root root  2989 9月  12 2016 netconsole
    -rwxr-xr-x. 1 root root  6643 9月  12 2016 network
    -rw-r--r--. 1 root root  1160 11月  7 2016 README
    [root@localhost ~]# ls /etc/rc.d/init.d
    functions  netconsole  network  README
    [root@localhost ~]# ll /etc/rc.d/init.d/
    总用量 32
    -rw-r--r--. 1 root root 15131 9月  12 2016 functions
    -rwxr-xr-x. 1 root root  2989 9月  12 2016 netconsole
    -rwxr-xr-x. 1 root root  6643 9月  12 2016 network
    -rw-r--r--. 1 root root  1160 11月  7 2016 README

    /etc/sysconfig  放置初始化环境配置文件位置

    /etc  放置rpm包安装的配置文件

    /etc/xinetd.conf  放置xinetd服务配置文件

    /var/lib  放置服务产生的数据

    /var/log  放置服务产生的日志

    独立服务启动方式:

    /etc/init.d/服务名 start、restart、stop、status

    service 服务名 start、restart、stop、status  注:service是红帽专有命令,ubuntu系列没有此命令,本质上还是去/etc/init.d目录搜索服务

    [root@localhost ~]# /etc/init.d/network status
    已配置设备:
    lo ens33
    当前活跃设备:
    lo ens33
    [root@localhost ~]# service network status
    已配置设备:
    lo ens33
    当前活跃设备:
    lo ens33

    service --status-all

    [root@localhost ~]# service --status-all
    未加载 netconsole 模块
    已配置设备:
    lo ens33
    当前活跃设备:
    lo ens33

    设置服务开机自启动:chkconfig --level 2345 服务名 on  注:4为保留,习惯写上,也可以不写。--level 2345可省,默认就是2345。

    设置取消服务开机自启动:chkconfig --level 2345 服务名 off  注:--level 2345可省,默认就是2345

    修改/etc/rc.d/rc.local,在此文件中加入需要设置为自启动服务的命令语句 ——建议使用修改配置文件的方法设置服务开机自启动。

    使用ntsysv管理设置服务是否开机自启动,此方法不仅能管理独立服务,也可管理基于xinetd服务,但仍不可管理源码包安装的服务,红帽专有命令。

    注:所有红帽专有命令都不建议使用,建议使用标准通用方法,因为可以在所有Linux发行版上通用,降低学习成本,提高使用效率。

    [root@localhost ~]# ll /etc/rc.d/rc.local
    -rw-r--r--. 1 root root 473 11月  7 2016 /etc/rc.d/rc.local
    [root@localhost ~]# ll /etc/rc.local
    lrwxrwxrwx. 1 root root 13 7月  19 23:23 /etc/rc.local -> rc.d/rc.local
    [root@localhost ~]# cat /etc/rc.d/rc.local  注释:此文件的作用是在系统启动后,输入用户名密码之前会先执行此文件中预置的所有命令。
    #!/bin/bash
    # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
    #
    # It is highly advisable to create own systemd services or udev rules
    # to run scripts during boot instead of using this file.
    #
    # In contrast to previous versions due to parallel execution during boot
    # this script will NOT be run after all other services.
    #
    # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
    # that this script will be executed during boot.
    
    touch /var/lock/subsys/local

    rpm服务:基于xinetd服务


    源码包安装的服务

    启动方式:绝对路径 start|stop

    [root@localhost ~]# ls /etc/rc.d
    init.d  rc0.d  rc1.d  rc2.d  rc3.d  rc4.d  rc5.d  rc6.d  rc.local  注释:数据代表运行级别
    [root@localhost ~]# ls /etc/rc.d/rc3.d
    K50netconsole  S10network  注释:S代表启动,K代表关闭,数据代表启动关闭顺序
  • 相关阅读:
    Bean作用域
    处理自动装配的歧义
    IOC/DI 依赖注入
    Session管理
    JSP
    Jenkins(持续集成)Windows版本安装
    Jenkins安装插件提速(Windows)终极解决办法
    Jenkins(持续集成)Windows版本解决插件安装缓慢
    Please wait while Jenkins is getting ready to work...(Jenkins访问资源慢的问题)
    Spring Boot 小技巧
  • 原文地址:https://www.cnblogs.com/xiongjiawei/p/7399529.html
Copyright © 2011-2022 走看看