2020. 4. 16.

[Linux] Service 등록 및 관리

서비스와 데몬

서비스와 데몬은 구분하지 않아도 된다. 이둘은 사용자의 요청 시점이 아니라 임의의 시점(보통 시스템 boot)에서 background process 시작되어 사용자나 프로세스에 서비스를 제공하는 프로그램을 의미

방식

 stand alone
 - 스스로 listen하며 항상 메모리에 상주
 - 요청에 즉시 대응 가능
 - 서비스 요청이 매우 드물거나 idle 경우 메모리를 낭비

Super daemon
 - listen 직접하지 않는다.
 - 메모리에 상주하지 않으며 서비스 요청이 있을때 xinetd 의해 호출
 - 점차 사라지는 추세다.

초창기에는 super daemon 방식을 썻지만 현재는 안쓴다.
Stand alone


서비스 조회

systemctl list-unit-files - 모든 서비스의 상태 확인
#Systemctl [is-enabled | is-active] [서비스명]
 - is-enabled : 자동 실행 등록 여부
 - is-active : 현재 실행 여부

login as: 
root@192.168.Ia.152's password: 
Last login: Tue Apr 14 2ø2ø 
Croot@cent152 systemctl list-unit-files 
UNIT FILE 
proc-sys-fs-binfmt_misc 
dev-hugepages . mount 
dev-mqueue 
. mount 
proc-fs-nfsd . mount 
proc-sys-fs-binfmt_misc 
sys -f s -fuse-connections 
sys -kernel-config. mount 
sys-kernel-debug. mount 
tmp. nt 
. a utcmount 
. mount 
. mount 
var-lib-nfs-rpc_pipefs . mount 
brandbot. path 
cups . path 
systemd-ask- password- console. path 
systemd- ask- password - plymouth . path 
systemd-ask- password-wall. path 
session-I. scope 
session-cl. scope 
abrt-ccpp. 
abrt-oops . 
STATE 
static 
static 
static 
static 
static 
static 
static 
static 
disabled 
static 
disabled 
enabled 
static 
static 
static 
static 
static 
enabled 
enabled
Croot@cent152 
enabled 
Croot@cent152 
a c tive 
Croot@cent152 
enabled 
Croot@cent152 
unknown 
Croot@cent152 
systemctl 
systemctl 
systemctl 
systemctl 
is-enabled crond . setwice 
is-active crond. setwice 
is-enabled mdmonitor. setwice 
is-active mdmoniter. setwice


서비스 등록

# systemctl [enable | disable] [서비스명]
- [enable | disable] : 등록 및 등록 해제

Croot@cent152 systemctl disable crond . setwice 
Removed symlink /etc/systemd/system/multi-user.target.wants/crond. setwice. 
Croot@cent152 
disabled 
Croot@cent152 
a c tive 
Croot@cent152 
systemctl is-enabled crond . setwice 
systemctl is-active crond . setwice


서비스 실행

# systemctl [start | restart | stop] [서비스명]
- [start | restart | stop] : 실행, 재실행, 종료

네트워크 관련작업은 stop하면 다시 방법이 없음 그래서 restart 이용함
하지만 stop start 이용하여 하는것이 좋음


systemctl 추가 옵션

# systemctl [옵션] [서비스명]
- try-restart : 실행, 재실행, 종료
- Reload : 설정 재구동
- status : 상태 확인

Croot@cent152 systemctl status network 
network. - LS8: Bring up/down networking 
Loaded : 
Active: 
loaded (/etc/rc .d/init.d/network; bad; vendor preset: disabled) 
active (exited) 
2ø2ø-ø4-16 
since 
• man: systemd-sysv-generator(8) 
Docs . 
Tasks . 
:41:32 cent152 systemdCI): Starting LS3: Brin 
16 eg 
:41:34 cent152 networkC611): loopback 
16 eg 
:41:38 cent152 networkC611): ens32 
16 eg 
:41:38 cent152 systemdCI): Started LS8: Bring 
16 eg 
(ST; 26min ago 
up/down networking... 
up/down networking. 
Hint: Some 
lines were ellipsized, use -I to show in full. 
Croot@cent152

ntsysv

가능한 서비스 설정 
원래 있던 명령어가 아닌 GUI 유틸리티다. 이후 없어진다면

systemctl enable vsftpd 이런식으로 수동으로 설정할 있다.

acpid 
ACPl(Advanced Confi uration and 
ower Interface) 
anacron 
Anacronæ cron 
apmd 
atd 
crondø 
avahi-daemon 
Avafii 
avahi-dnsconfd 
DNS 
bluetooth 
conman 
cups 
idd 
ibmasm 
i map 
irda 
IvmZ—monitor 
dmQventd(Tfie Linux Kernel Device 
LVS(Linux Lo iCal 
Volume 
mcstrans 
(SELiV1"x 
mdmonitor 
RAID 
mdmpd 
microcode_ctl 
cpug4

multipatfid 
netconsole 
syslooc-• 
netfs 
Samba, NFS, NCP 
n fs 
(NFS) 
nfslock 
lock* 
nscd 
EZA) 
pand 
pcscd 
PC/SC 
portmap 
rawdevices 
"disc 
readahead_earlg 
restorecond 
SELinuxø 
rpcgssd 
GS5(GenQral Securit 
Service NFS version 4 
rpcidmapd 
"dmap(pmappine) 
rpcsvcqssd 
655 (General Securitg 
Service) 
NFS version 4 
Q) 
sgslog 
wpa_supplicant 
protected access) 
"bind 
NIS


서비스 설정

반드시 필요한 서비스를 죽이면 안됨
network : 네트워크 활성화
crond.service : 스케쥴 관리
display-manager.service : Xwindow 필수
gdm.service : Xwindow 필수
sshd.service : sshd

댓글 없음:

댓글 쓰기