Linux_pieces

  • Linux:免费的类Unix操作系统
  • bash:Linux平台内定shell
  • 进程(daemon):正在运行的程序
  • 守护进程(daemon):一直在后台运行的程序 
  • init:linux操作系统必不可少的 程序 之一, 历史上linux的启动,都是用 init 
    • init 0
    • init 3
    • init 5
  • unit (服务): 如 firewalld ( 防火墙 )
  • systemd ( systemdaemon ) 根据 Linux 惯例,字母d是守护进程(daemon)的缩写。 Systemd 这个名字的含义,就是它要守护整个系统。
    • 使用了 Systemd,就不需要再用init了。Systemd 取代了initd,成为系统的第一个进程(PID 等于 1),其他进程都是它的子进程。
    • 很多服务之间是有依赖关系的,systemd 的一大亮点就是可以管理 unit 之间的依赖关系。
    • Systemd 并不是一个命令,而是一组命令,涉及到系统管理的方方面面。
    • ubuntu下的 init 守护进程 的 service 服务 —— CentOS下的 systemd 守护进程 的 systemctl 服务
  •  systemctl ( ctl - control )  是 Systemd 的主命令,用于管理系统
    • introduction
      • 在Linux生态系统中,Systemd被部署到了大多数的标准Linux发行版中,只有为数不多的几个发行版尚未部署(如Ubuntu)。
      •  Systemctl是一个systemd工具,主要负责控制systemd系统和服务管理器。

Systemd 并不是一个命令,而是一组命令,涉及到系统管理的方方面面。

1.systemctl

  • systemctl [command] [unit]
    • command 有
      • start
      • stop
      • restart
      • status
      • reload : 重新加载配置文件
      • kill  
      • mask : 注销 unit 服务, 注销了后 就无法 启动这个服务了
      • unmask 取消注销
    • unit 服务举例 : firewalld
    • 命令使用 防火墙举例
      • systemctl start firewalld
      • systemctl stop firewalld
      • systemctl restart firewalld
      • systemctl reload firewalld
      • systemctl status firewalld
      • systemctl mask firewalld
      • systemctl unmask firewalld
    • 开关机
      • systemctl reboot
      • systemctl poweroff
      • systemctl halt

2.hostnamectl

  • hostnamectl set-hostname master

3.unit 不同的单元提供不同的服务

  • Unit 之间存在依赖关系:A 依赖于 B,就意味着 Systemd 在启动 A 的时候,同时会去启动 B。
  • 启动计算机的时候,需要启动大量的 Unit。
  • 如果每一次启动,都要一一写明本次启动需要哪些 Unit,显然非常不方便。Systemd 的解决方案就是 Target。

    简单说,Target 就是一个 Unit 组,包含许多相关的 Unit 。启动某个 Target 的时候,Systemd 就会启动里面所有的 Unit。从这个意义上说,Target 这个概念类似于"状态点",启动某个 Target 就好比启动到某种状态。

    传统的init启动模式里面,有 RunLevel 的概念,跟 Target 的作用很类似。不同的是,RunLevel 是互斥的,不可能多个 RunLevel 同时启动,但是多个 Target 可以同时启动。

.target  .service

猜你喜欢

转载自blog.csdn.net/qq_924485343/article/details/114898534