- 默认服务:(rpm包安装的)
chkconfig
查看所有rpm
包安装的服务
源码包所有文件安装在/usr/local
.
rpm包安装到厂商指定的位置
service httpd start
(redhat)独立服务启动,是因为rpm
包安装的服务启动日志都在/etc/rc.d/init.d
下,service
命令每次都在这里搜索服务/etc/init.d/httpd start|status|restart|stop
,独立服务的启动
service --status-all
服务状态查询
systemv
一些服务的目录:
/etc/init.d 独立服务启动脚本位置
/etc/sysconfig/ 初始化环境配置文件
/etc/ 配置文件位置
/etc/xinetd.d xinetd.d服务启动脚本
/var/lib/ 服务产生数据
/var/log/ 日志
- 独立服务的自启动
修改配置文件夹
/etc/rc.d/rc.local
centos 7 取消了 system V 的 init操作 管理,改用system d
whatis systemd
:
systemd system and service manager
init
服务按顺序启动,而systemd
并行启动所有服务- 自动解决依赖性问题
- 将许多
daemon
集合为一个target
,位操作系统环境一次启动 - 运行级别启动脚本通过
/etc/rc.d/rc[0-6]/Sxxdaemon
链接到/etc/init.d/daemon
,S
是启动该服务.xx
是启动顺序
systemd
将daemon执行脚本统称为
一个服务单位(unit),在systemd
中进行分类(type
)
systemd
一些服务目录
/usr/lib/systemd/ 类似(/etc/init.d)
/run/systemd/system 系统执行过程中产生的服务脚本,优先级比上面高
/etc/systemd/system 管理员根据需求建立的执行脚本,优先级比上一个也高
type
.service (unit) 系统服务(本地\网络)
.socket (unit) 内部程序数据交换socket服务
.target (unit集合),系统执行环境服务集合
.mount // unit
.automount //文件系统挂载服务
.path //unit 检测特定文件或目录类型
.timer // 循环执行的服务
systemctl
whatis systemctl
Control the systemd system and service manager
:控制systemd
系统和服务管理器
systemctl [command] [unit]
[command]:
start
stop
restart
reload:重新加载配置文件
enable:配置文件中:开机启动
disable:配置文件中:开机不启动
status
is-active:是否运行
状态active:
running
exited:目前没执行,执行一次就退出的状态
waiting:正在运行且等待
inactive:未运行
- 查看系统服务
systemctl [command] [--type=TYPE] [--all]
command:
list-units: 显示目前启动的, --all显示所有
list-unit-files:将/usr/lib/systemd/system/所有服务说明
TYPE 有
servie、socket、target、mount
systemctl list-units --type=service