首页 > 系统服务 > 详细

linux基础之CentOS7新特性

时间:2019-04-25 16:15:15      阅读:156      评论:0      收藏:0      [点我收藏+]

CentOS7开机启动顺序:

POST --> Boot Sequence --> Bootloader --> kernel + initramfs(initrd) --> rootfs --> /sbin/systemd

Systemd新特性

  系统引导时实现服务并启动
  按需激活进程
  系统状态快照
  基于依赖关系定义服务控制逻辑

关键特性:
  基于socket的激活机制: socket与服务程序分离
  基于bus的激活机制
  基于device的激活机制
  基于path的激活机制
  系统快照: 保存各unit的当前状态信息与持久存储设备中
  向后兼容sysv init脚本

核心概念: unit 

配置文件进行标识和配置: 文件中主要包含了系统服务、监听socket、保存的系统快照以及其他与init相关的信息
  保存至:
    /user/lib/systemd/system
    /run/systemd/system
    /etc/systemd/system

Unit的类型:

service unit: 文件扩展名为.service,用于定义系统服务
target unit: 文件扩展名为.target,用于模拟实现"运行级别"
device unit: 文件扩展名为.device,用于定义内核识别的设备
mount unit:  .mount,定义文件系统挂载点
socket unit: .socket,用于标识进程间通信用的socket文件
snapshot unit: .snapshot,管理系统快照
swap unit: .swap,用于标识swap设备
automount unit: .automount,文件系统的自动挂载点
path unit: .path,用于定义文件系统中的一个文件或目录

管理系统服务

命令: systemctl COMMAND name.service
启动: service name start ==> systemctl start name.service
停止: service name stop ==> systemctl stop name.service
重启: service name restart ==> systemctl restart name.service
状态: service name status ==> systemctl status name.service
条件式重启: service name condrestart ==> systemctl try-restart name.service
重载或重启服务:systemctl reload-or-restart name.service
重载或条件式重启服务:systemctl reload-or-try-restart name.service

 查看某服务当前激活与否的状态: systemctl is-active name.service
 查看所有已经激活的服务
    systemctl list-units --type service
  查看所有服务
     systemctl list-units --type service --all

chkconfig 命令的对应关系
设定某服务开机自启:chkconfig name on ==> systemctl enable name.service
禁止: chkconfig name off ==> systemctl disable name.service
查看所有服务的开机自启状态
chkconfig --list ==> systemctl list-unit-files --type service
查看服务是否开机自启:systemctl is-enabled name.servcie
运行级别:
                0 ==> runlevel0.target, poweroff.target
                1 ==> runlevel1.target, rescue.target
                2 ==> runlevel2.target, multi-user.target
                3 ==> runlevel3.target, multi-user.target
                4 ==> runlevel4.target, multi-user.target
                5 ==> runlevel5.target, reboot.target
     级别切换:
            init N ==> systemctl isolate name.trget
        查看级别: 
            runlevel ==> systemctl list-units --type target
        获取默认运行级别:
            /etc/inittab ==> systemctl get-default
        修改默认级别:
            /etc/inittab ==> systemctl set-default name.target
        切换至紧急救援模式:
            systemctl rescue
        切换至emergency模式:
            systemctl emergency

其他常用命令

     关机: systemctl halt、 systemctl poweroff
        重启: systemctl reboot
        挂起: systemctl suspend
        快照: systemctl hibernate
        快照并挂起: systemctl hybrid-sleep

 

linux基础之CentOS7新特性

原文:https://www.cnblogs.com/ckh2014/p/10769015.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!