zoukankan      html  css  js  c++  java
  • CentOS 7 System特性 管理服务方式以及与CentOS 6chkconfig的对比

    Systemd新特性:

      系统引导时实现服务并行启动   

      按需激活进程   

      系统状态快照基于依赖关系定义服务控制逻辑

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

    Unit的类型:
      Service unit:文件的扩展名为.serivce,用于定义系统服务
      Target unit:文件扩展名为.target,用于模拟实现运行级别
      Mount unit: .mount,定义文件系统挂载点
      Socket unit: .socket,用于表示进程间通信用的socket文件
      Snapshot unit: .sanpshot,管理系统快照
      Swap unit: .swap,用于标识swap设备
      Automount unit: .automount,文件系统的自动挂载点
      Path unit: .path,用于定义文件系统中的一个文件或目录

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

    不兼容:
      systemctl命令固定不变
      非有systemctl启动的服务,systemctl无法与之通信

    管理系统服务:
      CentOS 7:service unit
        能兼容早期的服务类脚本

        命令:systemctl COMMAND name.service


        CentOS 6       CentOS 7
    启动: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
    条件式重启:如果莫服务此前已经启动,则把该服务重启,如果没启动,则不做任何操作
    开机自启:chkconfig name on    systemctl enable name.service
    禁止自启:chkconfig name off    systemctl disenable name.service
    查看所有服务的开机自启状态:
      chkconfig --list        systemctl list-units-files --type service

    查看某服务当前激活与否的状态:systemctl is-active name.service

    查看所有已经激活的服务: systemctl list-units --type service

    查看所有服务:systemctl list-units --type service --all

    查看服务是否开机自启:systemctl is-enabled name.service
    重启或重载服务:systemctl reload-or-restart name.service
    重载或条件式重启服务: systemctl reload-or-try-restart name.service
    禁止设定为开机自启: systemctl mask name.service
    取消禁止设定为开机自启: systemctl unmask name.service

    target units:
      unit配置文件:.target

    运行级别:
      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,graphical.target
      6 --> runlevel6.target,reboot.target

    级别切换:
      CentOS 6   CentOS 7
      init #      systemctl isolate name.target
    查看级别:
      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

  • 相关阅读:
    02-print的用法
    01-Hello World
    01-查看系统整体性能情况:sar
    03-购物车
    Python之路,Day2
    02-三级菜单
    Python之路,Day1
    loadrunner中配置java脚本环境
    算法
    实现testNg的retry机制
  • 原文地址:https://www.cnblogs.com/lushengle/p/7769172.html
Copyright © 2011-2022 走看看