CentOS7 systemctl 설정 (부팅시 자동실행 포함)
systemctl에 관해 정리한다는게 이제서야 하게 되었다. 하지만 간단하게..
chkconfig로 데몬들을 runlevel에 따라 기동하도록 설정해왔는데 fedora16부터인가 systemctl로 전향되었다.
하지만 이런저런 이유로 chkconfig도 겸용하고 있는듯하다.
현재 fedora에서는 /etc/systemd/system에 설정화일이 존재하는데 /usr/lib/systemd/system/의 하부로 링크가 걸려있는것도 있다.
centos도 같은 레드햇 계열이므로 구조는 동일하지 않을까 한다.
1. 목록 보기
systemctl 또는 systemctl list-units
systemctl list-unit-files
예1) # systemctl
UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.automount loaded active running Arbitrary Executable File Formats File System Automount Point
sys-devices-pci0000:00-0000:...1-1x2d1-1x2d1.4-1x2d1.4:1.2-net-enp0s26u1u4i2.device loaded active plugged 802.11n_WLAN_Adapter
sys-devices-pci0000:00-0000:00:1b.0-sound-card0.device loaded active plugged 7 Series/C210 Series Chipset Family High Definition Audio Controller
sys-devices-pci0000:00-0000:....2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda1.device loaded active plugged SAMSUNG_MZMPC128HBFU-000L1
sys-devices-pci0000:00-0000:...2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda10.device loaded active plugged SAMSUNG_MZMPC128HBFU-000L1
sys-devices-pci0000:00-0000:...2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda11.device loaded active plugged SAMSUNG_MZMPC128HBFU-000L1
sys-devices-pci0000:00-0000:....2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda2.device loaded active plugged SAMSUNG_MZMPC128HBFU-000L1
sys-devices-pci0000:00-0000:....2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda3.device loaded active plugged SAMSUNG_MZMPC128HBFU-000L1
sys-devices-pci0000:00-0000:....2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda4.device loaded active plugged SAMSUNG_MZMPC128HBFU-000L1
sys-devices-pci0000:00-0000:....2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda5.device loaded active plugged SAMSUNG_MZMPC128HBFU-000L1
sys-devices-pci0000:00-0000:....2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda6.device loaded active plugged SAMSUNG_MZMPC128HBFU-000L1
sys-devices-pci0000:00-0000:....2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda7.device loaded active plugged SAMSUNG_MZMPC128HBFU-000L1
sys-devices-pci0000:00-0000:....2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda8.device loaded active plugged SAMSUNG_MZMPC128HBFU-000L1
중략....
예2) # systemctl list-units --type=service <== 목록중에 서비스인것
UNIT LOAD ACTIVE SUB DESCRIPTION
alsa-state.service loaded active running Manage Sound Card State (restore and store)
atd.service loaded active running Job spooling tools
auditd.service loaded active running Security Auditing Service
avahi-daemon.service loaded active running Avahi mDNS/DNS-SD Stack
chronyd.service loaded active running NTP client/server
crond.service loaded active running Command Scheduler
cups.service loaded active running CUPS Printing Service
dbus.service loaded active running D-Bus System Message Bus
elasticsearch.service loaded failed failed Starts and stops a single elasticsearch instance on this system
fedora-loadmodules.service loaded active exited Load legacy module configuration
fedora-readonly.service loaded active exited Configure read-only root support
irqbalance.service loaded active running irqbalance daemon
kdm.service loaded active running The KDE login manager
lvm2-lvmetad.service loaded active running LVM2 metadata daemon
lvm2-monitor.service loaded active exited Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling
mcelog.service loaded active running Machine Check Exception Logging Daemon
NetworkManager.service loaded active running Network Manager
polkit.service loaded active running Authorization Manager
rngd.service loaded active running Hardware RNG Entropy Gatherer Daemon
중략...
예3) # systemctl list-unit-files <== 파일목록
UNIT FILE STATE
proc-sys-fs-binfmt_misc.automount static
dev-hugepages.mount static
dev-mqueue.mount static
proc-fs-nfsd.mount static
proc-sys-fs-binfmt_misc.mount static
sys-fs-fuse-connections.mount static
sys-kernel-config.mount static
sys-kernel-debug.mount static
tmp.mount static
var-lib-nfs-rpc_pipefs.mount static
cups.path enabled
systemd-ask-password-console.path static
systemd-ask-password-plymouth.path static
systemd-ask-password-wall.path static
abrt-ccpp.service enabled
abrt-oops.service enabled
abrt-uefioops.service enabled
abrt-vmcore.service enabled
abrt-xorg.service enabled
abrtd.service disabled
alsa-restore.service static
alsa-state.service static
alsa-store.service static
중략...
2. 서비스 상태 확인
systemctl status service명.service
예) # systemctl status elasticsearch.service
elasticsearch.service - Starts and stops a single elasticsearch instance on this system
Loaded: loaded (/etc/systemd/system/elasticsearch.service; disabled)
Active: failed (Result: exit-code) since Mon 2013-07-15 13:41:37 JST; 15min ago
Docs: http://www.elasticsearch.org
Main PID: 19359 (code=exited, status=143)
CGroup: name=systemd:/system/elasticsearch.service
Jul 15 13:35:46 viper systemd[1]: Started Starts and stops a single elasticsearch instance on this system.
Jul 15 13:41:37 viper systemd[1]: Stopping Starts and stops a single elasticsearch instance on this system...
Jul 15 13:41:37 viper systemd[1]: elasticsearch.service: main process exited, code=exited, status=143/n/a
Jul 15 13:41:37 viper systemd[1]: Stopped Starts and stops a single elasticsearch instance on this system.
Jul 15 13:41:37 viper systemd[1]: Unit elasticsearch.service entered failed state.
Jul 15 13:41:38 viper systemd[1]: Stopped Starts and stops a single elasticsearch instance on this system.
3. 서비스를 시작
systemctl start service명.service
예) # systemctl start elasticsearch.service
4. 서비스를 중지
systemctl stop service명.service
예) # systemctl stopt elasticsearch.service
5. 부팅시 자동 실행
systemctl enable service명.service
예) # systemctl enable elasticsearch.service
6. 부팅시 자동 미실행
systemctl disable service명.service
예) # systemctl disable elasticsearch.service