Systemd

From 탱이의 잡동사니
Jump to navigation Jump to search

Overview

Linux systemd 내용 정리

Configure files

systemd configure file

systemd 는 /etc/systemd 아래에 설정파일을 두고 있다. <source lang=bash> $ ls /etc/systemd/ bootchart.conf journald.conf logind.conf network ntp-units.d resolved.conf system system.conf timesyncd.conf user user.conf </source>

service/target configure file

systemd에서 관리하는 서비스들은 service/target 파일들을 통해서 관리하는데, 다음의 위치에 저장되게 된다.

바이너리 실행파일은 아래 경로에서 확인 가능하며
$ ls /lib/systemd/

기본적인 시스템의 Service, Target은 아래에 위치하고 있다
$ ls /lib/systemd/system

Service management

서비스를 설정하고 관리하는 방법은 기본적으로 다음과 같다.

- 서비스 활성화
$ systemctl enable [서비스명]

- 서비스 비활성화
$ systemctl disable [서비스명]

- 서비스 시작
$ systemctl start [서비스명]

- 서비스 종료
$ systemctl stop [서비스명]

- 서비스 재시작
$ systemctl restart [서비스명]

- 서비스 갱신
$ systemctl reload [서비스명]

service restart

systemd 에 등록되어 있는 서비스는 서비스 내용에 따라 서비스 종료시 바로 자동으로 실행되는 경우가 있다. 이런 경우, kill -9 명령어로 서비스를 분명히 종료 했지만 바로 재시작이 되게 되는데, 어떤 이유로 해당 서비스가 재시작되는지 알기가 까다롭게 된다. 이런 경우, /var/log/syslog 메시지를 확인하면 아래의 내용과 같이 systemd 에 의해 해당 서비스가 재시작 되었음을 확인할 수 있다.

Apr  4 08:27:04 earth systemd[1]: freeswitch.service: main process exited, code=killed, status=9/KILL
Apr  4 08:27:04 earth systemd[1]: Unit freeswitch.service entered failed state.
Apr  4 08:27:04 earth freeswitch[18707]: 18708 Backgrounding.
Apr  4 08:27:06 earth freeswitch[18707]: FreeSWITCH[18707] Waiting for background process pid:18708 to be ready.....
Apr  4 08:27:06 earth freeswitch[18707]: FreeSWITCH[18707] System Ready pid:18708

See also