Redhat7的一些配置和之前的版本中关于服务的配置配置有一些不同,以下稍稍介绍一下。

  • systemctl管理服务
    Centos6/Redhat6中使用service、chkconfig命令来实现服务的启动配置;
    Centos7/RHEL7中使用systemctl命令实现服务的启动配置,服务程序管理主要是依赖于 /usr/lib/systemd/system/目录下的以.service结尾的unit file文件来管理,我们使用systemctl来调用。

systemctl命令:
Usage: systemctl { start | restart | stop | status | enable | disable } servername
systemctl list-unit-files //查看所有单元文件的状态
systemctl list-unit-file --type=target //列出系统target单元
systemctl is-enabled NAME.service //查看服务是否开机自启动
systemctl is-active name.service //查看服务是否**

说明
systemd使用unit file文件进行控制程序的启动和关闭,需要注意以下几点:

  • 所有的unit file文件都保存在/usr/lib/systemd/system/目录下面,而/etc/systemd/system下的是unitfile文件的软连接

  • 使用yum安装的程序会自带一个unit file文件,保存在/usr/lib/systemd/system/目录下,比如:
    /usr/lib/systemd/system/httpd.service

  • 常见的unit file文件类型
    Service unit :NAME.service //用于定义系统服务
    Target unit:NAME.target //用于模拟实现“运行级别”
    Device unit: NAME.device //用于定义内核识别的设备
    Mount unit:NAME.mount //用于定义文件系统的挂载点
    Socket unit:NAME.socket //用于表示进程间通信用到的socket文件
    Snapshot:NAME.snapshot //用于管理系统快照
    Swap unit:NAME.swap //用于管理Swap设备
    Automount unit:NAME.automount //用于文件系统自动挂载点设备
    Path unit:NAME.path //用于定义文件系统中的某一文件或目录

  • 运行级别
    systemctl使用目标target取代了运行级别的概念
    ReadHat7的服务管理程序systemctl介绍

  • 补充:
    关机:systemctl halt | systemctl poweroff
    重启:systemctl reboot
    挂起:systemctl suspend
    快照:systemctl hibernate
    快照并挂起:systemctl hybrid-sleep

相关文章:

  • 2021-08-12
  • 2022-12-23
  • 2021-05-20
  • 2021-06-27
  • 2021-12-14
  • 2021-09-18
  • 2021-07-11
猜你喜欢
  • 2021-08-27
  • 2022-12-23
  • 2021-10-05
  • 2022-01-14
  • 2022-12-23
  • 2021-06-29
  • 2021-05-27
相关资源
相似解决方案