CentOS7.3学习笔记总结(六十七)

linux启动流程:

CentOS56

开机主板自检-MBR引导-装在GRUB-加载内核-Init进程初始化

CentOS78

开机主板自检-MBR引导-装在GRUB-加载内核-Systemd进程初始化

从流程行看,CentOS56CentOS78差不多,其实差别还是很大的,不单单是InitSystemd上的差别,我们今天主要是说取代Initsystemd

InitSystemd的区别:

Init:

启动时间长,是串行启动,启动玩一个进程,才会启动下一个进程;并且启动脚本复杂,需要脚本自己处理各种复杂情况,Init不管这些事情,它只负责执行你编写的启动脚本。

systemd:

如果程序支持systemd,在安装程序的时候,系统会自动在/usr/lib/system/system目录添加相应的配置文件,我们就可以通过systemctl来控制程序。

blob.png                                               

常用指令:

Centos6旧指令                centos78新指令

启动某服务           service httpd start               systemctl start httpd

停止某服务           service httpd stop               systemctl stop httpd

重启某服务           service httpd restart           systemctl restart httpd

检查服务状态           service httpd status            systemctl status httpd

删除某服务         chkconfig –del httpd            停掉应用,删除其配置文件

使服务开机自启动  chkconfig --level 5 httpd on systemctl enable httpd

使服务开机不自启动chkconfig --level 5 httpd off         systemctl   disable  httpd

显示所有已启动的服务chkconfig --list                 systemctl list-unit-files | grep enabled

加入自定义服务       chkconfig --add test             systemctl load test

查询服务是否开机自启chkconfig --list | grep httpd    systemctl is-enabled httpd

查看启动失败的服务                               systemctl  --failed


Systemd 命令:

systemctl --version#查看 Systemd 版本

blob.png

(systemctl) reboot #重新启动系统

(systemctl) poweroff#关闭系统,切断电源

systemd-analyze#查看启动好费时间

systemd-analyze blame#查看每个服务启动耗费时间

blob.png

systemctl cat firewalld.service#查看配置文件的内容

blob.png

systemctl list-dependencies firewalld.service#列出所有依赖

blob.png


猜你喜欢

转载自blog.51cto.com/6300167/2536740