Saya mencoba untuk menginstal kucing jantan pada mesin virtual CentOS 7 baru. Saya berhasil menginstal apache httpd, dan saya bisa mendapatkan halaman uji apache ketika saya mengetik ip dari mesin virtual ke browser web di komputer lain di jaringan. Tapi saya mendapatkan pesan kesalahan berikut ketika saya mengetik systemctl start tomcat
:
Job for tomcat.service failed. See 'systemctl status tomcat.service' and 'journalctl -xn' for details.
Berikut ini adalah sejarah lengkap dari perintah dalam menginstal java dan kucing jantan:
Saya pertama kali mulai dengan menginstal java menggunakan instruksi dari tutorial ini karena instruksi tomcat (blok kedua di bawah) ingin saya menggunakan openjdk, dan saya perlu menggunakan java nyata:
//Install Java
# cd /opt/
# yum install wget
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.tar.gz"
# tar xzf jdk-8u60-linux-x64.tar.gz
# cd /opt/jdk1.8.0_60/
# alternatives --install /usr/bin/java java /opt/jdk1.8.0_60/bin/java 2
# alternatives --config java
(Select the version you want)
# alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_60/bin/jar 2
# alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_60/bin/javac 2
# alternatives --set jar /opt/jdk1.8.0_60/bin/jar
# alternatives --set javac /opt/jdk1.8.0_60/bin/javac
# java -version (checks to see you install correct version)
# export JAVA_HOME=/opt/jdk1.8.0_60
# export JRE_HOME=/opt/jdk1.8.0_60/jre
# export PATH=$PATH:/opt/jdk1.8.0_60/bin:/opt/jdk1.8.0_60/jre/bin
Perhatikan bahwa tutorial sebelumnya tidak menjelaskan cara memasukkan variabel lingkungan /etc/environment
, jadi saya berhenti sebelum perintah itu.
Perintah berikut berasal dari tutorial lain ini . Saya mulai pada titik setelah menginstal java:
//Install Tomcat
Login as sudo user, not root.
# sudo groupadd tomcat
# sudo useradd -M -s /bin/nologin -g tomcat -d /opt/tomcat tomcat
# cd ~
# wget http://mirrors.gigenet.com/apache/tomcat/tomcat-8/v8.0.27/bin/apache-tomcat-8.0.27.tar.gz
# sudo mkdir /opt/tomcat
# sudo tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1
# cd /opt/tomcat
# sudo chgrp -R tomcat conf
# sudo chmod g+rwx conf
# sudo chmod g+r conf/*
# sudo chown -R tomcat work/ temp/ logs/
# sudo vi /etc/systemd/system/tomcat.service
Cut and paste the following file contents:
##################################################
# Systemd unit file for tomcat
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/jre
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/bin/kill -15 $MAINPID
User=tomcat
Group=tomcat
[Install]
WantedBy=multi-user.target
##################################################
# sudo systemctl daemon-reload
# sudo systemctl start tomcat
Job for tomcat.service failed. See 'systemctl status tomcat.service' and 'journalctl -xn' for details.
# sudo systemctl start tomcat.service
Pekerjaan untuk tomcat.service gagal. Lihat 'systemctl status tomcat.service' dan 'journalctl -xn' untuk detailnya. # sudo systemctl aktifkan tomcat.service ln -s '/etc/systemd/system/tomcat.service' '/etc/systemd/system/multi-user.target.wants/tomcat.service' # sudo systemctl aktifkan tomcat
# sudo systemctl status tomcat.service
tomcat.service - Apache Tomcat Web Application Container
Loaded: loaded (/etc/systemd/system/tomcat.service; enabled)
Active: failed (Result: exit-code) since Tue 2015-10-13 11:05:31 PDT; 47s ago
Oct 13 11:05:31 localhost.localdomain kill[20887]: -q, --queue <sig> use sigqueue(2) rather than kill(2)
Oct 13 11:05:31 localhost.localdomain kill[20887]: -p, --pid print pids without signaling them
Oct 13 11:05:31 localhost.localdomain kill[20887]: -l, --list [=<signal>] list signal names, or convert one to a name
Oct 13 11:05:31 localhost.localdomain kill[20887]: -L, --table list signal names and numbers
Oct 13 11:05:31 localhost.localdomain kill[20887]: -h, --help display this help and exit
Oct 13 11:05:31 localhost.localdomain kill[20887]: -V, --version output version information and exit
Oct 13 11:05:31 localhost.localdomain kill[20887]: For more details see kill(1).
Oct 13 11:05:31 localhost.localdomain systemd[1]: tomcat.service: control process exited, code=exited status=1
Oct 13 11:05:31 localhost.localdomain systemd[1]: Failed to start Apache Tomcat Web Application Container.
Oct 13 11:05:31 localhost.localdomain systemd[1]: Unit tomcat.service entered failed state.
Melakukan yum localinstall
rpm jdk yang diperbarui, seperti yang disarankan dalam posting lain ini , tidak berhasil.
EDIT:
Sesuai saran @ Bram, saya mengubah file konfigurasi ke yang berikut, tetapi saya masih mendapatkan kesalahan yang sama:
# Systemd unit file for tomcat
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=forking
Environment=JAVA_HOME=/opt/jdk1.8.0_60
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/bin/kill -15 $MAINPID
User=tomcat
Group=tomcat
[Install]
WantedBy=multi-user.target
Juga, sesuai komentar @ JeffSchaller dalam obrolan, saya dapat meminta kucing jantan untuk memulai secara asli sebagai berikut:
[user@localhost tomcat]$ sudo /opt/tomcat/bin/startup.sh
Using CATALINA_BASE: /opt/tomcat
Using CATALINA_HOME: /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME: /
Using CLASSPATH: /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
Tomcat started.
[user@localhost tomcat]$
Jadi masalah dalam OP ini tampaknya dengan konfigurasi systemd. Bagaimana saya bisa memperbaikinya?
sudo systemctl start tomcat.service
adalah sekelompok izin ditolak kesalahan yang mengambil ratusan baris.