service详解1

一、简介

systemd是linux系统中的一个系统和服务管理工具,它被设计为向后兼容 SysV init scripts。该机制全部只有一个systemd服务和一个systemctl管理工具,定义每一个服务为一个服务单位(unit),并将该unit归属到不同的服务类型(type)。

二、 Systemd Unit 类型简介

Unit TypeFile ExtensionDescription
Service unit.serviceA system service .
Target unit.targetA group of systemd units .
Automount unit.automountA file system automount point .
Device unit.deviceA device file recognized by the kernel .
Mount unit.mountA file system mount point .
Path unit.pathA file or directory in a file system .
Scope unit.scopeAn externally created process .
Slice unit.sliceA group of hierarchically organized units that manage system processes .
Snapshot unit.snapshotA saved state of the systemd manager .
Socket unit.socketAn inter-process communication socket .
Swap unit.swapA swap device or a swap file .
Timer unit.timerA systemd timer .

也可以使用命令 systemctl -t help 查看

[root@master01 ~]# systemctl -t help
Available unit types:
service
socket
busname
target
snapshot
device
mount
automount
swap
timer
path
slice
scope
[root@master01 ~]# 

三、Systemd Unit 文件位置

DirectoryDescription
/usr/lib/systemd/system/Systemd unit files distributed with installed RPM packages.
/run/systemd/system/Systemd unit files created at run time. This directory takes precedence over the directory with installed service unit files.
/etc/systemd/system/Systemd unit files created by systemctl enable as well as unit files added for extending a service. This directory takes precedence over the directory with runtime unit files.
  • 1、/usr/lib/systemd/system/,在使用CentOS官方提供的软件安装后,默认的启动脚本配置文件都会存放在这里,这里的文件一般不要修改,如果需要修改,请到 /etc/systemd/system/ 目录下复制一份新的并修改。比如我要修改httpd service,步骤如下:

1、复制 httpd unit 文件到/etc/systemd/system/ 目录下

cp /usr/lib/systemd/system/httpd.service /etc/systemd/system/httpd.service

2、打开/etc/systemd/system/httpd.service文件,并修改对应的配置项

3、重载配置文件,使其生效,并查看

systemctl daemon-reload
systemctl show httpd -p TimeoutStartUSec
  • 2、/run/systemd/system/ 系统运行的过程中产生的脚本名,这些脚本的优先级要比/usr/lib/systemd/system/高
  • 3、/etc/systemd/system/ 对于原有的unit 文件的扩展以及修改会存放在这个路径下,执行优先级又比/run/systemd/system/高

四、systemd服务本身的配置文件

systemd服务本身的默认配置文件在/etc/systemd/system.conf,在这个文件中可以设置一些默认的属性值。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值