1. systemd, 무엇이 바뀌었나?
RHEL 7
(주)오뉴이노베이션
Solutions Architect팀
2018년 3월 7일
systemd, 무엇이 바뀌었나? 1/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
2. Table of Contents
1. systemd의 이해.........................................................................................3
1.1. systemd는 무엇인가?..............................................................................3
1.2. init은 무엇인가?.................................................................................3
1.3. 왜 System V init는 대체 되었는가?................................................................3
1.4. /etc/init.d/httpd 스크립트.......................................................................3
1.5. systemd: httpd.service...........................................................................5
1.6. So long and thanks for all the fish..............................................................6
1.7. init 사용 종료 시점..............................................................................7
2. systemd – System & Service Manager.....................................................................8
2.1. systemd Overview.................................................................................8
2.2. systemd Units....................................................................................8
2.3. systemd Unit Files...............................................................................8
2.4. Unit 파일의 일반적인 옵션........................................................................8
2.5. 서비스 활성화....................................................................................9
2.6. 개선 된 자원 관리................................................................................9
2.7. Kill/Restart Cleanly.............................................................................9
2.8. Auto-Restarting..................................................................................9
2.9. systemd : Managing Services......................................................................9
2.10. systemctl vs services..........................................................................10
2.10.1 서비스의 시작, 상태 종료...................................................................10
2.10.2. List services.............................................................................10
2.11. Managing Services: Enable / Disable............................................................12
2.12. systemctl vs chkconfig.........................................................................12
2.13. systemctl 명령의 옵션..........................................................................13
2.14. systemd-* 명령들...............................................................................14
2.15. systemd 의존성.................................................................................14
2.16. Parallel, Not Serial...........................................................................15
2.17. Boot Process...................................................................................15
2.17.1. boot Process – Services / Units...........................................................17
2.17.2. target의 모든 서비스 목록.................................................................17
2.17.3. Analyzing Boot............................................................................20
2.18. Targets are the new Runlevels..................................................................22
2.18.1. Common Targets............................................................................22
2.18.2. Working with Targets......................................................................22
2.18.3. Shutting Down, Suspending, Etc............................................................24
2.19. root 암호 리셋하기.............................................................................24
2.20. systemd-cgtop..................................................................................26
2.21. 컨트롤 그룹의 컨텐츠 보기......................................................................26
3. systemd Logging : journalctl..........................................................................31
3.1. 개선 된 Logging.................................................................................31
3.2. journalctl......................................................................................31
3.3. Journal의 사용..................................................................................31
3.3.1. journalctl.................................................................................32
3.3.2. journalctl 사용하기........................................................................33
systemd, 무엇이 바뀌었나? 2/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
3. 1. systemd의 이해
1.1. systemd는 무엇인가?
systemd는 initd를 대체 한다.
# ls -al /sbin/init
lrwxrwxrwx. 1 root root 22 2월 1 23:04 /sbin/init -> ../lib/systemd/systemd
• 시작하기 위한 첫 번째 프로세스이고, 종료하기 위한 마지막 프로세스
• 모든 다른 프로세스의 parent 프로세스
• 서비스와 기타 리소스를 관리
1.2. init은 무엇인가?
• Init – System V UNIX origin in 1970s
• 시스템을 시작하기 위한 프로세스 :
◦ BIOS/UEFI → Bootloader → Kernel → init
• init은 모든 프로세스의 parent 프로세스
• /etc/inittab에 저장 되어 있는 스크립트로부터 프로세스를 생성
• /etc/init.d에 저장 된 스크립트
1.3. 왜 System V init는 대체 되었는가?
• Init Scripts!
◦ 오래 됨
◦ 표준화의 부족
◦ 사람이나 컴퓨터가 이해하기 어렵고, 분석하기가 불가능하다.
• Single threaded
• 복잡한 관계를 표헌하기 어렵다.
1.4. /etc/init.d/httpd 스크립트
# pwd
/etc/init.d
# cat httpd
#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: The Apache HTTP Server is an efficient and extensible
# server implementing the current HTTP standards.
systemd, 무엇이 바뀌었나? 3/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
4. # processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd/httpd.pid
#
### BEGIN INIT INFO
# Provides: httpd
# Required-Start: $local_fs $remote_fs $network $named
# Required-Stop: $local_fs $remote_fs $network
# Should-Start: distcache
# Short-Description: start and stop Apache HTTP Server
# Description: The Apache HTTP Server is an extensible server
# implementing the current HTTP standards.
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/sbin/apachectl
httpd=${HTTPD-/usr/sbin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
STOP_TIMEOUT=${STOP_TIMEOUT-10}
# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure. So we just do it the way init scripts
# are expected to behave here.
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
# When stopping httpd, a delay (of default 10 second) is required
# before SIGKILLing the httpd parent; this gives enough time for the
# httpd parent to SIGKILL any errant children.
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
systemd, 무엇이 바뀌었나? 4/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
5. }
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=6
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
# Force LSB behaviour from killproc
LSB=1 killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
if [ $RETVAL -eq 7 ]; then
failure $"httpd shutdown"
fi
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart|try-restart)
if status -p ${pidfile} $httpd >&/dev/null; then
stop
start
fi
;;
force-reload|reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|
fullstatus|graceful|help|configtest}"
RETVAL=2
esac
exit $RETVAL
1.5. systemd: httpd.service
# pwd
/usr/lib/systemd/system
# cat httpd.service
# It's not recommended to modify this file in-place, because it will be
# overwritten during package upgrades. If you want to customize, the best
systemd, 무엇이 바뀌었나? 5/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
6. # way is to create a file "/etc/systemd/system/httpd.service",
# containing
# .include /lib/systemd/system/httpd.service
# ...make your changes here...
# For more info about custom unit files, see
# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F
# For example, to pass additional options (for instance, -D definitions) to the
# httpd binary at startup, you need to create a file named
# "/etc/systemd/system/httpd.service" containing:
# .include /lib/systemd/system/httpd.service
# [Service]
# Environment=OPTIONS=-DMY_DEFINE
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=notify
Environment=LANG=C
ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
# Send SIGWINCH for graceful stop
KillSignal=SIGWINCH
KillMode=mixed
PrivateTmp=true
[Install]
WantedBy=multi-user.target
1.6. So long and thanks for all the fish
영화 “The hichiker's guide to the galaxy”에서 지구가 멸망할 것을 할고 돌고래가 지구를 떠날 때 다른 물고기
들에게 남긴 인사말.
systemd, 무엇이 바뀌었나? 6/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
7. 1.7. init 사용 종료 시점
Fedora 15 - 2011년 5월
Arch - 2012년 10월
Red Hat - 2014년 6월
SUSE - 2014년 10월
Ubunto & debian – 2015월 4월
systemd, 무엇이 바뀌었나? 7/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
8. 2. systemd – System & Service Manager
2.1. systemd Overview
• 더 많은 서비스를 제어
• 종속적 제어
• 서비스 활성화
• 빠른 시작 및 종료
• 개선 된 자원 관리
• 더 좋은 로깅, 디버깅 프로파일링
• 역 호환
• 배우기 쉽다
2.2. systemd Units
더 많은 서비스를 제어하고, 시스템이 가지고 있는 모든 자원은 제어한다.
• 제어 할 수 있는 Unit의 종류
◦ Services
◦ Sockets
◦ Mounts
◦ Targets
◦ Swap
◦ and more…
Unit는 Unit 파일이 사용되고 정의 된다.
Unit의 이름 규칙은 name.unit_type로 정해 진다.
2.3. systemd Unit Files
• Maintainer files : /usr/lib/systemd/system
• Administrator files : /etc/systemd/system
• Non-persistent, runtime data : /run/systemd
• Drop-ins : /etc/systemd/system/[name.type].d/*.conf
Note :
/etc 아래에 있는 Unit 파일은 /usr 아래에 있는 Unit 파일보다 우선 적용됨.
만약 unit가 수정 되면 '# systemctl daemon-reload' 를 잊지 마세요!
2.4. Unit 파일의 일반적인 옵션
• Description=Unit의 설명
• Documentation=문서 링크
• Requires=추가적으로 요구 되는 Unit
• Before/After=Unit이 시작하기 전/후의 Unit
• Wants=Weaker Requires
• Conflicts=Units cannot co-e4xist
• WantedBy/RquiredBy=Set other units requirement
systemd, 무엇이 바뀌었나? 8/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
9. 2.5. 서비스 활성화
• Start up services when needed
◦ 자원의 저장
◦ 신뢰성 향상
◦ 클라이언트에 투명
• Socket, Device, Path bus 그리고 Timer에 의해 활성화
• xinetd 서비스를 unit로 변환하는 것을 추천
2.6. 개선 된 자원 관리
Services labeled and isolated with Cgroups
More control than nice alone
Can properly kill/restart entire service chain
Can configure multiple instances for a single services
하나의 서비스에 여러개의 인스턴스를 구성 할 수 있음.
Can balance by shares or by hard limits
2.7. Kill/Restart Cleanly
Tracked in the kernel
Knows all children
Don't need to rely on a potentially misbehaving process to hopefully kill its children
2.8. Auto-Restarting
It's paying attention!
Auto-Restarting는 주의 해야함.
Reality : software does crash occasionally
실제로 소프트웨어는 때때로 크래시가 발생.
Reduces need for manual intervention
Auto-Restarting는 수동적인 개입 필요성을 감소
Socket stays open, only lose that single transaction
오픈되어 있는 소켓은 그 단일 트랜잭션을 잃을 수 있음.
2.9. systemd : Managing Services
Init:
# service unit {start, stop, restart, reload}
systemd:
# systemctl {start, stop, restart, reload} unit1 [unit2 …]
• 여러개의 서비스를 동시에 실행 할 수 있음.
• .service Unit 타입
• systemctl은 Tab 키로 완성 될 수 있음.
◦ bash-completion 패키지 설치 필요
systemd, 무엇이 바뀌었나? 9/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
10. 2.10. systemctl vs services
2.10.1 서비스의 시작, 상태 종료
2.10.2. List services
systemd, 무엇이 바뀌었나? 10/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
11. systemd, 무엇이 바뀌었나? 11/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
12. 2.11. Managing Services: Enable / Disable
Init:
# chkconfig unit {on, off}
systemctl:
# systemctl {enable, disable, mask, unmask} unit [unit ...]
mask:
mask는 서비스를 disable하는 것 보다 더 강력하다. 서비스를 /dev/null로 링크 걸고, 그 링크를 인식함으로 서비
스를 시작하지 않는다.
2.12. systemctl vs chkconfig
systemd, 무엇이 바뀌었나? 12/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
13. 2.13. systemctl 명령의 옵션
systemd, 무엇이 바뀌었나? 13/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
14. 2.14. systemd-* 명령들
2.15. systemd 의존성
• 각 unit에 명령과 조건이 정의 되어 있음.
• Nfs-lock.service로 예를 들면
# cat nfs-lock.service
[Unit]
Description=NFS status monitor for NFSv2/3 locking.
DefaultDependencies=no
Conflicts=umount.target
Requires=nss-lookup.target rpcbind.target
After=network.target nss-lookup.target rpcbind.service
PartOf=nfs-utils.service
Wants=nfs-config.service
After=nfs-config.service
systemd, 무엇이 바뀌었나? 14/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
22. 15ms kmod-static-nodes.service
15ms plymouth-read-write.service
14ms dev-mqueue.mount
14ms systemd-user-sessions.service
13ms wpa_supplicant.service
12ms nfs-config.service
12ms systemd-rfkill@rfkill1.service
9ms systemd-random-seed.service
9ms systemd-rfkill@rfkill0.service
9ms sys-fs-fuse-connections.mount
8ms dev-mapper-fedorax2dswap.swap
7ms sys-kernel-debug.mount
7ms systemd-update-utmp-runlevel.service
6ms systemd-update-utmp.service
6ms systemd-rfkill@rfkill2.service
6ms dracut-shutdown.service
5ms var-lib-nfs-rpc_pipefs.mount
5ms auditd.service
2ms sys-kernel-config.mount
2.18. Targets are the new Runlevels
Targets != Runlevels - 몇 몇은 같은 부분이 있다.
Traditional Runlevel Equivalent Target Symlink Target
Runlevel 0 poweroff.target Runlevel0.target
Runlevel 1 rescue.target Runlevel1.target
Runlevel 2 multi-user.target Runlevel2.target
Runlevel 3 multi-user.target Runlevel3.target
Runlevel 4 multi-user.target Runlevel4.target
Runlevel 5 graphical.target Runlevel5.target
Runlevel 6 Reboot.target Runlevel6.target
Target은 다른 target를 포함 할 수 있음.
2.18.1. Common Targets
Target Purpose
graphical.target 멀티 유저, 그래픽과 텍스트 로그인 지원
multi-user.target 멀티 유저, 텍스트 로그인만 지원
resuce.target 싱글 유저, 로컬 파일 시스템과 기본 시스템 초기화, 네트워크는 비활성
emergency.target
싱글 유저, root 파일 시스템이 ro로 마운트, 몇개의 기본적이 서비스만 실행, 네트워
크는 비활성
Rescue, Emergency target는 root 암호가 필요함!!
2.18.2. Working with Targets
기본 target 보기
[root@procyon ~]# systemctl get-default
graphical.target
systemd, 무엇이 바뀌었나? 22/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
23. target 세팅 하기
[root@procyon ~]# systemctl set-default graphical.target
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.
기본 target는 symlink
[root@procyon ~]# ls -al /etc/systemd/system/default.target
lrwxrwxrwx. 1 root root 40 2월 17 13:52 /etc/systemd/system/default.target ->
/usr/lib/systemd/system/graphical.target
target 변경하기
[root@procyon ~]# systemctl isolate graphical.target
PolicyKit daemon disconnected from the bus.
We are no longer a registered authentication agent.
Rescue 모드로 변경하기
[root@procyon ~]# systemctl rescue
메시지를 보내지 않고 긴급 모드 변경하기
[root@procyon ~]# systemctl –no-wall emergency
현재 로드 된 target 보기
[root@procyon ~]# systemctl list-units --type target --no-pager
UNIT LOAD ACTIVE SUB DESCRIPTION
basic.target loaded active active Basic System
cryptsetup.target loaded active active Encrypted Volumes
getty.target loaded active active Login Prompts
graphical.target loaded active active Graphical Interface
local-fs-pre.target loaded active active Local File Systems (Pre)
local-fs.target loaded active active Local File Systems
systemd, 무엇이 바뀌었나? 23/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
24. multi-user.target loaded active active Multi-User System
network.target loaded active active Network
nfs-client.target loaded active active NFS client services
nss-user-lookup.target loaded active active User and Group Name Lookups
paths.target loaded active active Paths
remote-fs-pre.target loaded active active Remote File Systems (Pre)
remote-fs.target loaded active active Remote File Systems
slices.target loaded active active Slices
sockets.target loaded active active Sockets
swap.target loaded active active Swap
sysinit.target loaded active active System Initialization
timers.target loaded active active Timers
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
18 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
2.18.3. Shutting Down, Suspending, Etc
Old Command New Command Description
halt systemctl halt Halts the system
poweroff systemctl poweroff Powers off the system
reboot systemctl reboot Restarts the system
pm-suspend systemctl suspend Suspends the system
pm-hibernate systemctl hibernate Hibernates the system
pm-suspend-hybrid systemctl hybrid-sleep Hibernates and suspends the system
2.19. root 암호 리셋하기
Step 1 : Reboot your system
Step 2 : GRUB 부트로더가 보이면, any key로 인터럽트 그리고 'e' 선택
systemd, 무엇이 바뀌었나? 24/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
25. Step 3 : 커서키로 linux16으로 시작하는 라인의 긑으로 이동
Step 4 : 라인의 끝에서 'rd.break' 입력하고, Ctrl + X로 변경된 설정으로 부팅
linux16 /vmlinuz-4.3.5-300.fc23.x86_64 root=/dev/mapper/fedora-root ro rd.lvm.lv=fedora/root
rd.lvm.lv=fedora/swap rhgb quiet LANG=en_US.UTF-8 rd.break
initrd16 /initramfs-4.3.5-300.fc23.x86_64.img
Step 5 : root 프롬프트로 스위치 되면, /sysroot 파일 시스템을 rw로 remount, 그리고 나서 chroot를 사용해서
jail로 들어감.
Step 6 : passwd로 root password 변경
systemd, 무엇이 바뀌었나? 25/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
26. Step 7 : 리부팅시 모든 파일의 레이블을 다시 지정하기 위해 SELinux를 지시
• 만약 생략했다면 시스템은 아마도 부팅 되지 않을 수 있음.
Step 8 : relabel과 reboot하기 위해 두 번의 exit 명령
# touch /.autorelabel
# exit
exit
switch_root:/# exit
logout
2.20. systemd-cgtop
Top 컨트롤 그룹은 자원의 사용량을 보여준다.
[root@procyon ~]# systemd-cgtop
2.21. 컨트롤 그룹의 컨텐츠 보기
# systemd-cgls –no-pager
systemd, 무엇이 바뀌었나? 26/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
31. 3. systemd Logging : journalctl
3.1. 개선 된 Logging
• syslog가 시작되기를 기다릴 필요가 없음.
• STDERR와 STDOUT를 더 이상 유실 되지 않음.
• syslog보다 더 디데일 함
• logging도 metadata가 있음.
• 디버깅과 프로파일링이 개선됨.
3.2. journalctl
• RHEL7에서 rsyslog가 대체 된것이 아님.
◦ rsyslog는 디폴트로 enable됨
• journal은 기본적으로 저장(persistent) 되지 않음.
◦ persistence하기 위해서는 'mkdir /var/log/journal'
• key-value 쌍으로 저장 됨.
◦ Journalctl [tab] [tab]
◦ man 7 systemd.journal-fields
• 메시지와 함께 이벤트 메타데이터를 수집
• 간단한 필터
◦ units, binaries 등을 배치
3.3. Journal의 사용
• Tail the journal : 'journalctl -f'
• Show X number of lines : 'jounralctl -n 50'
• View from boot : 'journalctl -b'
• Filter by priority : 'journalctl -p [level]'
0 emerg
1 alert
2 crit
3 err
4 warning
5 notice
6 debug
systemd, 무엇이 바뀌었나? 31/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
32. 3.3.1. journalctl
[root@procyon ~]# journalctl –no-pager
• time stamps는 시스템 로컬 타임 존으로 변환 됨.
• 모든 로그 데이터는 rotated logs가 포함된 것이 보여짐.
• 기본적으로 영구 보존 되지 않음, 그러나 보존 할 수 있음.
최근의 로그를 보려면 -f 옵션을 사용
[root@procyon ~]# journalctl -f
원한다면 stdout/stderr는 systemd-cat으로 journal로 write 할 수 있다.
priority로 필터하기
systemd, 무엇이 바뀌었나? 32/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
33. 시간과 priority로 필터하기
[root@procyon ~]# journalctl -p err --since "2016-2-1 00:00:00" --until "2016-2-10 23:59:59"
field, UID, unit 등으로 확장 필터 할 수 있음.
3.3.2. journalctl 사용하기
• 유용한 filter
◦ -r reverse order
◦ -u [unit]
◦ bynary e.g. /usr/sbin/dnsmasq [additional binaries]
◦ --since=yesterday or YYYY-MM-DD (HH:MM:SS)
◦ --until=YYYY-MM-DD
• 전체 journal 보기
◦ journalctl -o verbose (useful for grep)
유용한 사이트
systemd, 무엇이 바뀌었나? 33/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189
34. • How to enable persistent logging for the systemd journalctl
◦ https://access.redhat.com/solutions/696893
• System Administrator's Guide
◦ https://access.redhat.com/documentation/en-
US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/s1-Using_the_Journal.html
• Lennart Poettering – The systemd Journalctl
◦ https://www.youtube.com/watch?v=i4CACB7paLc
systemd, 무엇이 바뀌었나? 34/34 (주)오뉴이노베이션
08381. 서울특별시 구로구 디지털로 273 702 호 ( 구로동 , 에이스트윈타워 2 차 )
702, ACE Twin Tower 2Cha, 273, Digital-ro Guro-gu, Seoul, Korea 08381
Tel. 02-866-2179 Fax. 02-866-2189