반응형
[Centos7] Tomcat 서비스 등록, 삭제, 목록 확인
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
[root@test ~]# systemctl list-units --type service
UNIT LOAD ACTIVE SUB DESCRIPTION
auditd.service loaded active running Security Auditing Service
chronyd.service loaded active running NTP client/server
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
firewalld.service loaded active running firewalld - dynamic firewall daemon
getty@tty1.service loaded active running Getty on tty1
httpd.service loaded active running The Apache HTTP Server
irqbalance.service loaded active running irqbalance daemon
kdump.service loaded active exited Crash recovery kernel arming
kmod-static-nodes.service loaded active exited Create list of required static device nodes for the current kernel
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
lvm2-pvscan@8:2.service loaded active exited LVM2 PV scan on device 8:2
network.service loaded active exited LSB: Bring up/down networking
NetworkManager-wait-online.service loaded active exited Network Manager Wait Online
NetworkManager.service loaded active running Network Manager
oddjobd.service loaded active running privileged operations for unprivileged applications
polkit.service loaded active running Authorization Manager
postfix.service loaded active running Postfix Mail Transport Agent
rhel-dmesg.service loaded active exited Dump dmesg to /var/log/dmesg
rhel-domainname.service loaded active exited Read and set NIS domainname from /etc/sysconfig/network
rhel-import-state.service loaded active exited Import network configuration from initramfs
rhel-readonly.service loaded active exited Configure read-only root support
rsyslog.service loaded active running System Logging Service
sshd.service loaded active running OpenSSH server daemon
sssd.service loaded active running System Security Services Daemon
systemd-journal-flush.service loaded active exited Flush Journal to Persistent Storage
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running Login Service
systemd-random-seed.service loaded active exited Load/Save Random Seed
systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
systemd-sysctl.service loaded active exited Apply Kernel Variables
systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directories
systemd-udev-trigger.service loaded active exited udev Coldplug all Devices
systemd-udevd.service loaded active running udev Kernel Device Manager
systemd-update-utmp.service loaded active exited Update UTMP about System Boot/Shutdown
systemd-user-sessions.service loaded active exited Permit User Sessions
systemd-vconsole-setup.service loaded active exited Setup Virtual Console
tuned.service loaded active running Dynamic System Tuning Daemon
|
cs |
systemctl list-units --type service
현재 등록된 서비스 확인
1
|
[root@test ~]# cd /usr/lib/systemd/system
|
cs |
cd /usr/lib/systemd/system
/usr/lib/systemd/system 디렉토리(기본 서비스 등록 장소)로 이동
ls -al로 확인하시면 다양한 서비스들이 존재합니다.
1
|
[root@test system]# vi tomcat.service
|
cs |
vi tomcat.service
서비스 스크립트 작성
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=forking
ExecStart=/usr/share/tomcat9/bin/startup.sh
ExecStop=/bin/kill -15 $MAINPID
User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always
[Install]
WantedBy=multi-user.target
|
cs |
위와 같이 작성 후 서비스 스크립트 저장
ExecStart는 설치한 톰캣경로의 startup.sh로 지정
1
2
|
[root@test system]# systemctl enable tomcat.service
Created symlink from /etc/systemd/system/multi-user.target.wants/tomcat.service to /usr/lib/systemd/system/tomcat.service.
|
cs |
systemctl enable tomcat.service
서비스 등록
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
[root@test system]# systemctl list-units --type service
UNIT LOAD ACTIVE SUB DESCRIPTION
auditd.service loaded active running Security Auditing Service
chronyd.service loaded active running NTP client/server
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
firewalld.service loaded active running firewalld - dynamic firewall daemon
getty@tty1.service loaded active running Getty on tty1
httpd.service loaded active running The Apache HTTP Server
irqbalance.service loaded active running irqbalance daemon
kdump.service loaded active exited Crash recovery kernel arming
kmod-static-nodes.service loaded active exited Create list of required static device nodes for the current kernel
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
lvm2-pvscan@8:2.service loaded active exited LVM2 PV scan on device 8:2
network.service loaded active exited LSB: Bring up/down networking
NetworkManager-wait-online.service loaded active exited Network Manager Wait Online
NetworkManager.service loaded active running Network Manager
oddjobd.service loaded active running privileged operations for unprivileged applications
polkit.service loaded active running Authorization Manager
postfix.service loaded active running Postfix Mail Transport Agent
rhel-dmesg.service loaded active exited Dump dmesg to /var/log/dmesg
rhel-domainname.service loaded active exited Read and set NIS domainname from /etc/sysconfig/network
rhel-import-state.service loaded active exited Import network configuration from initramfs
rhel-readonly.service loaded active exited Configure read-only root support
rsyslog.service loaded active running System Logging Service
sshd.service loaded active running OpenSSH server daemon
sssd.service loaded active running System Security Services Daemon
systemd-journal-flush.service loaded active exited Flush Journal to Persistent Storage
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running Login Service
systemd-random-seed.service loaded active exited Load/Save Random Seed
systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
systemd-sysctl.service loaded active exited Apply Kernel Variables
systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directories
systemd-udev-trigger.service loaded active exited udev Coldplug all Devices
systemd-udevd.service loaded active running udev Kernel Device Manager
systemd-update-utmp.service loaded active exited Update UTMP about System Boot/Shutdown
systemd-user-sessions.service loaded active exited Permit User Sessions
systemd-vconsole-setup.service loaded active exited Setup Virtual Console
tomcat.service loaded active running Apache Tomcat Web Application Container
tuned.service loaded active running Dynamic System Tuning Daemon
|
cs |
systemctl list-units --type service
서비스 재확인
(밑에서 2번째 tomcat 서비스가 등록됨)
1
2
3
4
5
6
|
[root@test system]# service tomcat start
Redirecting to /bin/systemctl start tomcat.service
[root@test system]#
[root@test system]#
[root@test system]# service tomcat stop
Redirecting to /bin/systemctl stop tomcat.service
|
cs |
service tomcat start
service tomcat stop
톰캣 서비스 작동 확인
Centos7 리부트 후 톰캣 서비스가 자동실행까지 확인하시면 됩니다.
1
2
|
[root@test system]# ps -ef | grep tomcat
tomcat 15881 1 99 13:51 ? 00:00:22 /usr/bin/java
-Djava.util.logging.config.file=/usr/share/tomcat9/conf/logging.properties
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Dspring.profiles.active=core -Djdk.tls.ephemeralDHKeySize=2048
-Djava.protocol.handler.pkgs=org.apache.catalina.webresources
-Dorg.apache.catalina.security.SecurityListener.UMASK=0027
-Dignore.endorsed.dirs=
-classpath /usr/share/tomcat9/bin/bootstrap.jar:/usr/share/tomcat9/bin/tomcat-juli.jar
-Dcatalina.base=/usr/share/tomcat9 -Dcatalina.home=/usr/share/tomcat9
-Djava.io.tmpdir=/usr/share/tomcat9/temp org.apache.catalina.startup.Bootstrap start
|
cs |
ps -ef | grep tomcat
tomcat 권한으로 작동중인 톰캣 프로세스 확인
1
|
[root@test system]# systemctl disable tomcat.service
|
cs |
systemctl disable tomcat.service
(위 명령어로 서비스 삭제도 가능)
출처 :
반응형
'[AWS] > ROG' 카테고리의 다른 글
[AWS] [활용] RDS SQL Server 생성 – 읽기 전용 복제본 생성편 (0) | 2022.03.10 |
---|---|
[AWS] CentOS 7 부팅시 자동시작 스크립트 적용 (0) | 2022.03.08 |
[AWS] 키페어 가져오기 - Failed to import AWS Keypair into other region!!! (0) | 2022.03.07 |
AWS Systems Manager | Run Command or Script in multiple EC2 Linux instances | Live Coding with SSM (0) | 2022.03.07 |
[AWS] SSM - System Manager - EC2에서 원격으로 command 실행 (0) | 2022.03.07 |
댓글