리눅스 서비스(데몬) 등록 및 관리 방법
1. 리눅스 서비스(데몬)란?
- 백그라운드에서 동작하는 프로세스
- 시스템 부팅 시 자동 실행 가능
- 예: sshd, crond, ntpd, zabbix-agent
2. CentOS 6 – chkconfig로 서비스 관리(SysV init)
chkconfig 기본 명령어
# 서비스 등록
chkconfig --add [서비스명]
# 서비스 제거
chkconfig --del [서비스명]
# 서비스 상태 확인
chkconfig --list [서비스명]
chkconfig --level [레벨] [서비스명] on/off
실행 레벨(runlevel) 개념
- 0 시스템 종료
- 1 단일 사용자 모드
- 3 멀티 유저 (CLI)
- 5 멀티 유저 (GUI)
- 6 재부팅
zabbix-agent 서비스 등록
서비스 등록
chkconfig --add zabbix-agent
서비스 상태 확인
chkconfig --list | egrep zabbix
zabbix-agent 0:off 1:off 2:off 3:off 4:off 5:off 6:off
Runlevel 3, 5에서 자동 실행 설정
chkconfig --level 35 zabbix-agent on
설정 확인
chkconfig --list | egrep zabbix-agent
zabbix-agent 0:off 1:off 2:off 3:on 4:off 5:on 6:off
chkconfig 전체 목록 확인
chkconfig --list
알림: 이 출력 결과에서는 SysV 서비스만을 보여주며 기존의 systemd 서비스는
포함되어 있지 않습니다. SysV 설정 데이터는 기존의 systemd 설정에 의해
덮어쓰여질 수 있습니다.
'systemctl list-unit-files'를 사용하여 systemd 서비스를 나열하실 수 있습니다.
특정 대상에 활성화된 서비스를 확인하려면
'systemctl list-dependencies [target]'을 사용하십시오.
netconsole 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
network 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
3. CentOS 7 – systemctl로 서비스 관리(systemd)
CentOS 7부터는 systemd 기반으로 변경되었으며 서비스 관리 명령어는 systemctl입니다.
systemd Unit File 목록 확인
전체 Unit File 목록
systemctl list-unit-files
서비스 타입(Unit Type)만 확인
systemctl -t service list-unit-files
UNIT FILE STATE
abrtd.service enabled
anaconda.service static
atd.service enabled
auditd.service disabled
ntpd.service enabled
sshd.service enabled
sshd@.service static
서비스 등록 / 해제(부팅 자동 실행)
서비스 등록(Enable)
systemctl enable zabbix-agent
서비스 해제(Disable)
systemctl disable zabbix-agent
- enable = 부팅 시 자동 실행
- disable = 부팅 시 실행 안 함
실행 중인 서비스(Unit) 목록 확인
현재 실행 중인 Unit
systemctl list-units
UNIT LOAD ACTIVE SUB DESCRIPTION
zabbix-agent.service loaded active running Zabbix Agent
crond.service loaded active running Command Scheduler
모든 Unit 포함하여 확인
systemctl list-units --all
- UNIT : Unit 이름
- LOAD : Unit 파일 로딩 여부
- ACTIVE : 상위 상태
- SUB : 하위 세부 상태
- DESCRIPTION : 서비스 설명
서비스 타입별 목록 확인
실행 중인 서비스만
systemctl list-units --type service
UNIT LOAD ACTIVE SUB DESCRIPTION
abrt-ccpp.service loaded active exited Install ABRT coredump hook
abrt-oops.service loaded active running ABRT kernel log watcher
abrtd.service loaded active running ABRT Automated Bug Reporting Tool
atd.service loaded active running Job spooling tools
blk-availability.service loaded active exited Availability of block devices
containerd.service loaded active running containerd container runtime
비활성 포함 전체 서비스
systemctl list-units --type service --all
UNIT LOAD ACTIVE SUB DESCRIPTION
abrt-ccpp.service loaded active exited Install ABRT coredump hook
abrt-oops.service loaded active running ABRT kernel log watcher
abrt-vmcore.service loaded inactive dead Harvest vmcores for ABRT
abrt-xorg.service loaded inactive dead ABRT Xorg log watcher
abrtd.service loaded active running ABRT Automated Bug Reporting Tool
atd.service loaded active running Job spooling tools
...
● yppasswdd.service not-found inactive dead yppasswdd.service
● ypserv.service not-found inactive dead ypserv.service
● ypxfrd.service not-found inactive dead ypxfrd.service
zabbix-agent.service loaded active running Zabbix Agent
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.
163 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
상태별 서비스 확인
active 상태 서비스
systemctl list-units --state active
failed 상태 서비스
systemctl list-units --state failed
CentOS 6에서는 chkconfig, CentOS 7부터는 systemctl이 서비스 관리의 표준이며 환경에 맞는 명령어 사용이 안정적인 서버 운영의 기본입니다.
'리눅스' 카테고리의 다른 글
| [draft] 우분투에서 기본 텍스트 편집기를 변경하는 방법 (0) | 2026.01.17 |
|---|---|
| [draft] 우분투에서 sudo를 비밀번호 없이 사용하는 방법 (0) | 2026.01.17 |
| [draft] Shell 스크립트에서 CRLF와 LF 문제를 해결하는 방법 (0) | 2026.01.16 |
| [draft] NGINX 저장소의 만료된 GPG 키 갱신 방법 (0) | 2026.01.16 |
| [draft] 로컬 IP 및 공인 IP 확인하는 방법 (0) | 2026.01.16 |