Linux 시스템의 총괄 시스템
17400 단어 Linux
목록 1.init의 진화, 모든 기능의 Systemd 2
1.1 Linux 시스템에서 init는 주로 3개 버전2
1.2 전통적인 init 프로그램을 비교하면 Systemd의 특징은 다음과 같다. 2
1.3 Systemd Journal의 이점은 다음과 같습니다. 3
2. Systemd의 기본 개념 3
2.1 단원의 개념(12개 유형)3
2.1.1 유닛 보기 4
2.1.2 유닛의 상태5
2.1.3 Unit 관리 작업5
2.1.4 Unit 종속성 6
2.2 Unit 구성 파일6
2.2.1 프로필의 상태 6
2.2.2 네이티브 구성 파일 수 통계 6
2.2.3 프로필 보기 7
2.3 Target 7
2.3.1 Target 명령 보기 7
2.3.2 Target와 기존 Run Level의 대응 관계는 다음과 같습니다.8
2.4 Systemd 트랜잭션 8
2.5 Systemd의 동시 부팅 원리 8
2.6 Systemd 사용9
2.7 시스템 관리9
2.7.1 전원 끄기, 재부팅, 휴면...9
2.7.2 systemd-analyze 명령은 부팅 시간을 확인하는 데 사용됩니다.9
2.7.3 hostnamectl 명령은 현재 호스트의 정보를 보는 데 사용됩니다.10
2.7.4 localectl 명령은 현지화 설정을 보는 데 사용됩니다.10
2.7.5 timedatectl 명령은 현재 시간대 설정을 보는 데 사용됩니다.10
2.7.6 loginctl 명령은 현재 로그인한 사용자를 보는 데 사용됩니다.11
2.7.7 자세히 보기 명령11
2.7.7.1 상태 보기, 트리 목록 11
2.7.2 UNIT 목록 표시 11
2.7.3 의존 관계 목록 11
2.7.4 트리 디스플레이 프로세스 12
2.7.5 트리 표시12
1. init의 진화, 모든 기능의 Systemd
본고는 Systemd 과정을 공부하는 정리 노트입니다. 독자가 배우려면 다음과 같은 순서로 몇 편의 아주 좋은 글을 볼 수 있습니다.
https://www.ibm.com/developerworks/cn/linux/1407_liuming_init3/index.html
Linux init , 3 [Systemd] (2014-7-16)
http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html
Systemd : (2016-3-7)
http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-part-two.html
Systemd : (2016-3-8)
3 , Systemd 。 , :
https://www.freedesktop.org/wiki/Software/systemd/
https://www.freedesktop.org/software/systemd/man/
https://en.wikipedia.org/wiki/Systemd
https://zh.wikipedia.org/wiki/Systemd
http://www.jinbuguo.com/systemd/systemd-analyze.html
https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
http://0pointer.de/public/systemd-ebook-psankar.pdf
Systemd :
https://wiki.archlinux.org/index.php/Systemd
https://wiki.gentoo.org/wiki/Systemd
https://wiki.debian.org/systemd
https://wiki.debian.org/zh_CN/Systemd
https://fedoraproject.org/wiki/How_to_debug_Systemd_problems
https://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet
https://docs.fedoraproject.org/en-US/quick-docs/understanding-and-administering-systemd/index.html
1.1 Linux 시스템의 init 버전은 크게 3개
커널에서 시작된 첫 번째 사용자 공간 프로세스는 init에서 시작되었고 init는 주로 다음과 같은 3가지 버전이 있습니다.
> System V init, (Sys V init, ) : /etc/inittab
> Upstart, (Ubuntu ) : /etc/init, .conf
> systemd, ( , ) : /usr/lib/systemd/; /etc/systemd/
Linux , d (daemon) 。 Systemd , 。
systemd linux 。 systemd SysV、LSB init scripts . sysvinit .
Systemd , , , , 。 , 。 。
1.2 전통적인 init 프로그램을 비교하면 Systemd의 특징은 다음과 같다.
* : socket / D-Bus activation
*
* Linux Cgroup 。 , 。
* :Systemd autofs , autofs 。Maintains mount and automount points
* :
* ( systemd 2014)
* :systemd journald, syslog
* Systemd Journal ( ), journalctl 。 /etc/systemd/journald.conf。
1.3 Systemd Journal의 이점은 다음과 같습니다.
* : , , 。
* : , 。 , , 。
* : Linux , CPU 。
* : 。
* : 。
* : , 。 。 , 。 。Syslog , 。
* : , 。
* : , 。
2. Systemd의 기본 개념
2.1 단원의 개념(12개 유형)
systemd , unit。
; ; ; 。
systemd Unit 12 。
> Service unit: 。 , mysqld。 。
> Socket Unit: socket。 。 ,systemd 、 AF_INET、AF_INET6、AF_UNIX socket 。 。 " " ( :nscd.socket nscd.service)。
> Device Unit: 。 Linux 。 udev systemd 。
> Mount Unit: 。 。Systemd 。 ; 。Systemd /etc/fstab , 。
> Automount Unit: 。 。 , ,systemd 。
> Swap Unit:swap 。 , 。 , 。
> Timer Unit: 。 , atd、crond 。
> Target unit: Unit 。 , 。 。 。 , , , (target), 。 ( :multi-user.target SysV 5)
> Snapshot Unit:Systemd ,
> Path Unit:
> Scope Unit: Systemd , systemd 。 。
> Slice Unit: , Linux (cgroup) 。
2.1.1 Unit 장치 보기
# Unit
$ systemctl list-units
# Unit,
$ systemctl list-units --all
:UNIT LOAD ACTIVE SUB DESCRIPTION
> LOAD = 。(loaded,not-found)
> ACTIVE = , SUB 。(active,failed,inactive)
> SUB = , 。(active,dead,exited,failed,listening,mounted,plugged,running,waiting)
현재 시스템의 모든 설정 단원을 조회 통계 (> 파일 후 excel 분류 통계 사용)
LOAD (314)
loaded 308
not-found 6
ACTIVE (314)
active 265
failed 2
inactive 47
SUB (314)
active 32
dead 47
exited 25
failed 2
listening 5
mounted 11
plugged 166
running 20
waiting 6
# Unit
$ systemctl list-units --all --state=inactive
# Unit
$ systemctl list-units --failed
# 、 service Unit
$ systemctl list-units --type=service
2.1.2 유닛의 상태
#
$ systemctl status
# Unit
$ sysystemctl status bluetooth.service
status ,systemctl , 。
# Unit
$ systemctl is-active application.service
# Unit
$ systemctl is-failed application.service
# Unit
$ systemctl is-enabled application.service
2.1.3 Unit 관리 작업
, , Unit( service)。
#
$ sudo systemctl start apache.service
#
$ sudo systemctl stop apache.service
#
$ sudo systemctl restart apache.service
#
$ sudo systemctl kill apache.service
#
$ sudo systemctl reload apache.service
#
$ sudo systemctl daemon-reload
# Unit
$ systemctl show httpd.service
# Unit
$ systemctl show -p CPUShares httpd.service
# Unit
$ sudo systemctl set-property httpd.service CPUShares=500
2.1.4 Unit 종속성
systemd 。
:unit A unit B, unit B "require A" 。 systemd A B。
systemctl list-dependencies Unit 。
$ systemctl list-dependencies nginx.service
, Target ( ), 。 Target, --all 。
$ systemctl list-dependencies --all nginx.service
2.2 Unit 구성 파일
, Systemd Unit 。
Systemd /etc/systemd/system/ 。 , ,( )
/usr/lib/systemd/system/, 。
systemctl enable , 。disable , , 。
, Unit , sshd.socket。 ,Systemd .service, sshd sshd.service。
2.2.1 프로필의 상태
#
$ systemctl list-unit-files
UNIT FILE STATE
2.2.2 统计本机配置文件数量
STATE (299)(8 ) disabled 98 , enabled 8 , ; enabled-runtime 1 generated 3 indirect 4 static 184 , [Install] ( ), transient 1 ? masked type. (299)(12 ) automount 1 mount 10 path 2 scope 1 ,transient service 183 slice 2 ? socket 27 , swap 1 target 63 timer 9 device 0 snapshot 0
2.2.3 프로필 보기# $ systemctl list-unit-files --type=service , SystemD , , 。 $ sudo systemctl daemon-reload $ sudo systemctl restart httpd.service , , , 。 Unit , 。 :http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-part-two.html https://docs.fedoraproject.org/en-US/quick-docs/understanding-and-administering-systemd/index.html :https://www.freedesktop.org/software/systemd/man/systemd.unit.html
2.3 Target, Unit。 , Unit, 。Systemd Target。 ,Target Unit , Unit 。 init , RunLevel , Target 。 ,RunLevel , RunLevel , Target 。
2.3.1 Target 명령 보기# Target $ systemctl list-unit-files --type=target # Target Unit $ systemctl list-dependencies multi-user.target # Target $ systemctl get-default # Target $ sudo systemctl set-default multi-user.target # Target , Target , # systemctl isolate , # Target Target $ sudo systemctl isolate multi-user.target
2.3.2 Target와 기존 Run Level의 대응 관계는 다음과 같습니다.Traditional runleve l New target name Symbolically linked to... > Runlevel 0 | runlevel0.target -> poweroff.target 。 > Runlevel 1 | runlevel1.target -> rescue.target 。 > Runlevel 2 | runlevel2.target -> multi-user.target / 。 3。 > Runlevel 4 | runlevel4.target -> multi-user.target > Runlevel 3 | runlevel3.target -> multi-user.target , 。 。 > Runlevel 5 | runlevel5.target -> graphical.target , 。 3 。 > Runlevel 6 | runlevel6.target -> reboot.target > emergency emergency.target Shell
2.4 Systemd 트랜잭션Systemd 。Systemd , 。 , systemd 。 systemd , :required ;want ,systemd wants 。 ,systemd 。 Systemd , 。
2.5 Systemd의 동시 부팅 원리, 。 : socket : D-Bus D-Bus desktop-bus , 、 、 。 , 。 D-Bus , 。 : :https://www.ibm.com/developerworks/cn/linux/1407_liuming_init3/index.html
2.6 Systemd 사용systemd 。 , systemd 。 : , 。 setsid(), systemd pid 。 Systemd , stderr , syslog。 SIGTERM, , 。 SIGHUP 。 , , systemd 。 sd_notify() systemd 。 , , , 。
2.7 시스템 관리Systemd , , 。systemctl 。
2.7.1 전원 끄기, 재부팅, 휴면...# $ sudo systemctl reboot # , $ sudo systemctl poweroff # CPU $ sudo systemctl halt # ( ), , 。 $ sudo systemctl suspend # , , 。 $ sudo systemctl hibernate # ( ), 。 $ sudo systemctl hybrid-sleep # ( ) $ sudo systemctl rescue Systemd
2.7.2 systemd-analyze 명령은 부팅 시간을 확인하는 데 사용됩니다.# $ systemd-analyze # $ systemd-analyze blame # $ systemd-analyze critical-chain # $ systemd-analyze critical-chain atd.service
2.7.3 hostnamectl 명령은 현재 호스트의 정보를 보는 데 사용됩니다.# $ hostnamectl # 。 $ sudo hostnamectl set-hostname tompc
2.7.4 localectl 명령은 현지화 설정을 보는 데 사용됩니다.# $ localectl # 。 $ sudo localectl set-locale LANG=en_GB.utf8 $ sudo localectl set-keymap en_GB
2.7.5 timedatectl 명령은 현재 시간대 설정을 보는 데 사용됩니다.# $ timedatectl # $ timedatectl list-timezones # $ sudo timedatectl set-timezone America/New_York $ sudo timedatectl set-time YYYY-MM-DD $ sudo timedatectl set-time HH:MM:SS
2.7.6 loginctl 명령은 현재 로그인한 사용자를 보는 데 사용됩니다.# session $ loginctl list-sessions # $ loginctl list-users # $ loginctl show-user tom
2.7.7 추가 보기 명령
2.7.7.1 상태 보기, 트리 목록$ systemctl status CGroup: / ├─user.slice │ └─user-1001.slice │ ├─session-2.scope │ │ ├─ 507 lightdm --session-child 14 21 │ │ ├─ 518 /bin/sh /etc/xdg/xfce4/xinitrc -- /etc/X11/xinit/xserv> │ │ ├─ 529 xfce4-session List running units: :$ systemctl list-units $ systemctl
2.7.2 UNIT 목록 표시$ systemctl UNIT LOAD ACTIVE SUB DESCRIPTION proc-sys-fs-binfmt_misc.automount loaded active running Arbitrary Executabl> sys-devices-pci0000:00-0000:00:02.0-backlight-acpi_video0.device loaded activ> sys-devices-pci0000:00-0000:00:02.0-drm-card0-card0\x2dLVDS\x2d1-intel_backli> sys-subsystem-net-devices-wlp16s0.device loaded active plugged PRO/Wireless> -.mount loaded active mounted / dev-hugepages.mount loaded active mounted Huge Pages File System
2.7.3 의존 관계 목록$ systemctl list-dependencies default.target ● ├─lightdm.service ● └─multi-user.target ● ├─dbus.service ● ├─lm_sensors.servic
2.7.4 트리 디스플레이 프로세스alias psc='ps xawf -eo pid,user,cgroup,args' $ ps xawf -eo pid,user,cgroup,args PID USER CGROUP COMMAND 2 root - [kthreadd] 3 root - \_ [rcu_gp] 4 root - \_ [rcu_par_gp] 6 root - \_ [kworker/0:0H-kblockd]
2.7.5 트리 디스플레이$ systemd-cgls Control group /: -.slice ├─user.slice │ └─user-1001.slice │ ├─session-2.scope │ │ ├─ 507 lightdm --session-child 14 21 │ │ ├─ 518 /bin/sh /etc/xdg/xfce4/xinitrc -- /etc/X11/xinit/xserverrc │ │ ├─ 529 xfce4-session =============== , 。 Type= [Service] : Type=simple( ):systemd 。 。 , , 。 Type=forking:systemd , 。 , , 。 PIDFile=, systemd 。 Type=oneshot: 。 RemainAfterExit=yes, systemd 。 Type=notify:Type=simple , systemd 。 libsystemd-daemon.so 。 Type=dbus: BusName DBus , 。 Type=idle:systemd , 。 Type=simple。 ---------------------- Service types There are several different start-up types to consider when writing a custom service file. This is set with the Type= parameter in the [Service] section: Type=simple (default): systemd considers the service to be started up immediately. The process must not fork. Do not use this type if other services need to be ordered on this service, unless it is socket activated. Type=forking: systemd considers the service started up once the process forks and the parent has exited. For classic daemons use this type unless you know that it is not necessary. You should specify PIDFile= as well so systemd can keep track of the main process. Type=oneshot: this is useful for scripts that do a single job and then exit. You may want to set RemainAfterExit=yes as well so that systemd still considers the service as active after the process has exited. Type=notify: identical to Type=simple, but with the stipulation that the daemon will send a signal to systemd when it is ready. The reference implementation for this notification is provided by libsystemd-daemon.so. Type=dbus: the service is considered ready when the specified BusName appears on DBus's system bus. Type=idle: systemd will delay execution of the service binary until all jobs are dispatched. Other than that behavior is very similar to Type=simple. ================= https://bbs.archlinux.org/viewtopic.php?id=163286 $ sudo pacman -S graphviz , : $ systemd-analyze dot --order | dot -Tsvg > systemd-user.svg , : $ systemd-analyze dot --user --order | dot -Tsvg > systemd-user.svg =================== https://wiki.archlinux.org/index.php/Systemd systemd ============= ===============
에 발표되다
2019-04-06 14:45 osoft 읽기(
...) 설명(
...) 모음 편집
댓글 새로 고침 페이지 새로 고침 맨 위로
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
바이너리 파일cat 또는tail, 터미널 디코딩 시 처리 방법cat으로 바이너리 파일을 보려고 할 때 코드가 엉망이 되어 식은땀이 났다. 웹에서 스크롤된 정보의 처리 방법과alias의 설정을 요약합니다. reset 명령을 사용하여 터미널을 재설정합니다.이렇게 하면 고치지 못하...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.