2. 1. Systemd 소개
2. Systemd 유닛
3. Systemd 사용
4. Q & A
목차
리눅스 Systemd
3. Systemd 소개
리눅스 Systemd
1
init 프로세스를 대체하여 도입된 PID 1번 프로세스
2010년도에 발표하여 2015년도 부터 본격적으로 도입됐다.
시스템 관리, 로그 관리, 서비스 관리, 초기화 스크립트 관리 등의 역할을 하고 있다.
Systemd의 d는 Daemon을 의미한다.
init프로세스 : 유닉스 기반 컴퓨터 운영 체제에서 부팅 과정 중 최초로 실행되는 프로
세스
Daemon : 리눅스가 처음 가동될때 실행되는 백그라운드 프로세스로 요청이 생기면
반응하는 리스너 같은 역할을 한다.
PID : 프로세스를 구분하기 위한 식별자.
4. Systemd 소개
리눅스 Systemd
1
Init프로세스에 대한 호환성 제공 init 스크립트 런레벨과 타겟
의존성 기반의 서비스 제어 로직 제공
Systemd 유닛을 통한 시스템 관리
부팅시 서비스를 병렬로 시작
시스템 상태 스냅샷 지원
Cgroup관리
통합로그 관리
주요 기능과 특징
5. Systemd 유닛
리눅스 Systemd
2
유닛 파일 종류
유닛 명 확장자 특징
서비스 유닛 .service 다른 시스템에게 제공되는 서비스를 나타낸다.
장치 유닛 .device 하드웨어가 추가되거나 마운트 됐을 때 생성된다.
마운트 유닛 .mount 생성된 장치를 마운트 포인트에 연결하면 생성된다.
자동마운트 유닛
.automoun
t
자동마운트 포인트를 관리한다.
스왑 유닛 .swap 스왑영역에 생성되며 스왑 영역을 관리한다.
타겟 유닛 .target 부팅정보를 담고있는 유닛이다
경로 유닛 .path 특정 파일시스템이나 디렉토리를 모니터링하는 정보
타이머 유닛 .timer 일정 간격으로 유닛을 실행 할 때 사용한다.
스냅샷 유닛 .snapshot 특정 시점의 모든 유닛의 상태를 저장한다.
소켓 유닛 .socket 서로다른 서비스, 시스템간의 데이터를 주고 받는다.
범위 유닛 .scope 시스템 프로세스 집합을 관리한다.
슬라이스 유닛 .slice 프로세스 그룹의 자원을 계층적으로 관리한다.
6. Systemd 유닛
리눅스 Systemd
2
유닛 파일의 위치
패키지 설치
/usr/lib/system/system
수동생성, 관리
/etc/systemd/system
임시유닛
/run/system/system
systemctl start systemctl enable
부팅시
7. Systemd 유닛
리눅스 Systemd
2
유닛 파일 구성
1 [Unit]
2 Description=The Apache HTTP Server
3 After=network.target remote-fs.target nss-lookup.t
arget
4 Documentation=man:httpd(8)
5 Documentation=man:apachectl(8)
6
7 [Service]
8 Type=notify
9 EnvironmentFile=/etc/sysconfig/httpd
10 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGRO
UND
11 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
12 ExecStop=/bin/kill -WINCH ${MAINPID}
~
18 KillSignal=SIGCONT
19 PrivateTmp=true
20
일반적정보
유닛 설명
의존성 순서
참고문서
서비스에 대한 옵션
유닛의 유형
시작될 때 실행
재구성 됐을 때 실행
중지됐을 때
Enable 됐을 경우
링크파일이 생성되는
8. Systemd 사용
리눅스 Systemd
3
동작 명령 동작 명령
시작
/ 확인
systemctl start 서비스 재시작
systemctl restart 서비
스
systemctl is-active 서비
스 활성화
/ 확인
systemctl enable 서비
스
상태확인 systemctl status 서비스
systemctl is-enabled 서
비스
중지 systemctl stop 서비스 비활성화
Systemctl disable 서비
스
동작 명령
유닛 정보 systemctl list-units
유닛 목록 systemctl list-unit-files
의존관계 systemctl list-dependencies (유닛명)
유닛 제어 명령
일괄 제어가 가능한 명령
9. Systemd 사용
리눅스 Systemd
3
start 및 확인
[centos@test ~]$ sudo systemctl start httpd
[centos@test ~]$ sudo systemctl is-active httpd
active
enable 및 확인
[centos@test ~]$ sudo systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd
.service to /usr/lib/systemd/system/httpd.service.
[centos@test ~]$ sudo systemctl is-enabled httpd
enabled
10. Systemd 사용
리눅스 Systemd
3
status 확인
[centos@test ~]$ sudo systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset
: disabled)
Active: active (running) since 목 2021-01-14 16:54:39 KST; 41min ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 4383 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─4383 /usr/sbin/httpd -DFOREGROUND
├─4384 /usr/sbin/httpd -DFOREGROUND
├─4385 /usr/sbin/httpd -DFOREGROUND
├─4386 /usr/sbin/httpd -DFOREGROUND
├─4387 /usr/sbin/httpd -DFOREGROUND
└─4388 /usr/sbin/httpd -DFOREGROUND
1월 14 16:54:39 test.novalocal systemd[1]: Starting The Apache HTTP Server...
1월 14 16:54:39 test.novalocal systemd[1]: Started The Apache HTTP Server.
11. Systemd 사용
리눅스 Systemd
3
disable 및 stop
[centos@test ~]$ sudo systemctl disable httpd
Removed symlink /etc/systemd/system/multi-user.target.wants/httpd.ser
vice.
[centos@test ~]$ sudo systemctl stop httpd
[centos@test ~]$ sudo systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vend
or preset: disabled)
Active: inactive (dead)
Docs: man:httpd(8)
man:apachectl(8)
12. Systemd 사용
리눅스 Systemd
3
로그 확인
[centos@test ~]$ sudo systemctl start httpd
Job for httpd.service failed because the control process exited with error c
ode. See "systemctl status httpd.service" and "journalctl -xe" for details.
[centos@test ~]$ sudo journalctl –xe