首页
Linux教程
Linux实战教程
Shell教程
Mysql教程
Keepalived教程
Linux基础教程
Linux进阶教程
运维题库
运维干货
视频教程
运维资讯
资源下载
关于我们
首页 Linux进阶教程2.15 Linux服务管理

2.14 计算机网络基础

2.16 Linux启动过程

1.1 什么是systemd

Systemd(System Daemon)是CentOS7系统中的系统管理守护进程、工具和库的集合,用于取代早期的init进程。Systemd的功能是用于集中管理和配置Linux系统。

systemd是CentOS7系统中启动的第一个进程(PID等于1),其他所有进程都是他的子进程。

C6:服务启动方式

# /etc/init.d/network restart
Restarting network (via systemctl):                        [  OK  ]

# service network restart
Restarting network (via systemctl):                        [  确定  ]

1.2 systemd相关路径文件

路径 描述
/usr/lib/systemd/system 启动服务程序所在的路径
/etc/systemd/system 不同运行级别启动文件路径
/etc/systemd/system/multi-user.target.wants 开机自启文件所在路径

1.3 systemd管理服务相关命令

1)常用命令

systemctl命令 作用
start 启动服务
stop 停止服务
restart 重启服务
reload 重新加载配置
status 查看服务运行状态

2)使用实例:

# 启动crond服务
systemctl start crond

# 停止crond服务
systemctl stop crond

# 重启crond服务
systemctl restart  crond

# 重新加载配置crond 
systemctl reload  crond

# 查看crond服务运行状态
systemctl status crond

3)运行状态描述

状态 描述
loaded 服务单元的配置文件已经被处理
active(running) 服务持续运行
inactive (dead) 服务停止状态
enabled 服务设定为开机运行
disabled 服务设定为开机不运行

1.4 systemd服务开机自启

1)常用命令

systemctl命令 作用
enable 开机自动启动
disable 开机不自动启动

2)手工设置开机自启动

/etc/systemd/system/multi-user.target.wants/目录下设置快捷方式

# ln -s /usr/lib/systemd/system/crond.service /etc/systemd/system/multi-user.target.wants/crond.service
# ls -l /etc/systemd/system/multi-user.target.wants/|grep crond
# systemctl status crond

3)手工设置开机停止启动

删除在multi-user.target.wants里的快捷方式

# rm -f /etc/systemd/system/multi-user.target.wants/crond.service
# ls -l /etc/systemd/system/multi-user.target.wants/|grep crond
# systemctl status crond

1.5 linux服务器 开机自启动服务优化

1)需要保留的服务

除下方服务外,其他的根据需要开启

服务名称 服务作用
rsyslog.service 日志系统
sshd.service 远程连接SSHD
sysstat.service 性能监控
network 网络服务(使用chkconfig开启)

2)处理方法

# systemctl list-unit-files|egrep -v "network.ta|rsyslog|sshd\.|sysstat|static"|awk '{print "systemctl disable "$1}'|bash

# systemctl list-unit-files|grep enabled

网络服务的开机自启动
# chkconfig network on
# chkconfig --list|grep network

本文链接:https://www.yunweibase.com/archives/700

2.14 计算机网络基础

2.16 Linux启动过程

网友评论comments

发表评论

邮箱地址不会被公开。 必填项已用*标注

暂无评论

Copyright © 运维基地 保留所有权
扫二维码
扫二维码
返回顶部