CentOS7 中 jboss 服务未启动

CentOS7 中 jboss 服务未启动

无法在 Centos 7 上分叉 initd 脚本。我已经安装了 JBOSS EAP7,它带有内置 initd 脚本来启动服务。我启动/停止/重新启动如下服务,效果很好。但是,当我通过 systemd 分叉相同的 initd 脚本时,它不起作用。任何帮助,将不胜感激。

# /opt/jboss/bin/init.d/jboss-eap-rhel.sh start
Starting jboss-eap: /root
                                                           [  OK  ]
# /opt/jboss/bin/init.d/jboss-eap-rhel.sh status
jboss-eap is running (pid 3024)

# /opt/jboss/bin/init.d/jboss-eap-rhel.sh stop
Stopping jboss-eap:                                        [  OK  ]

# /opt/jboss/bin/init.d/jboss-eap-rhel.sh status
jboss-eap is not running

# /opt/jboss/bin/init.d/jboss-eap-rhel.sh start
Starting jboss-eap: /root
                                                           [  OK  ]
# /opt/jboss/bin/init.d/jboss-eap-rhel.sh status
jboss-eap is running (pid 3314)

通过 systemd 分叉相同的 initd 脚本会出现错误。

# cat /etc/systemd/system/jbosseap7.service
[Unit]
Description=JBoss EAP7
After=syslog.target
After=network.target

[Service]
Type=forking
ExecStart=/opt/jboss/bin/init.d/jboss-eap-rhel.sh start
ExecStop=/opt/jboss/bin/init.d/jboss-eap-rhel.sh stop
ExecReload=/opt/jboss/bin/init.d/jboss-eap-rhel.sh restart
PIDFile=/var/run/jboss-eap/jboss-eap-standalone.pid

[Install]
WantedBy=multi-user.target


# time systemctl start jbosseap7
Job for jbosseap7.service failed because a timeout was exceeded. See "systemctl status jbosseap7.service" and "journalctl -xe" for details.

real    **1m27.330s**
user    0m0.008s
sys     0m0.003s

# time systemctl status jbosseap7
● jbosseap7.service - JBoss EAP7
   Loaded: loaded (/etc/systemd/system/jbosseap7.service; enabled; vendor preset: disabled)
   Active: failed (Result: timeout) since Mon 2018-06-11 07:04:29 EDT; 15s ago

Jun 11 06:58:22 node01.local.com systemd[1]: Starting JBoss EAP7...
Jun 11 06:58:22 node01.local.com runuser[4071]: pam_unix(runuser:session): session opened for user jboss by (uid=0)
Jun 11 06:58:22 node01.local.com jboss-eap-rhel.sh[4060]: Starting jboss-eap: /
Jun 11 06:58:39 node01.local.com jboss-eap-rhel.sh[4060]: [  OK  ]
Jun 11 06:58:39 node01.local.com systemd[1]: PID file /var/run/jboss-eap/jboss-eap-standalone.pid not readable (yet?) after start.
Jun 11 07:04:28 node01.local.com systemd[1]: jbosseap7.service start operation timed out. Terminating.
Jun 11 07:04:29 node01.local.com systemd[1]: Failed to start JBoss EAP7.
Jun 11 07:04:29 node01.local.com systemd[1]: Unit jbosseap7.service entered failed state.
Jun 11 07:04:29 node01.local.com systemd[1]: jbosseap7.service failed.

real    0m0.045s
user    0m0.004s
sys     0m0.000s

笔记:我什至尝试在 [SERVICE] 单元下指定超时限制,但这仍然不起作用。如果不指定时间限制,仍然需要很长时间(1分27秒)。这里可能出了什么问题?

补充评论:

有时启动,有时不启动。我们怎样才能确定失败的那一个呢?

# systemctl start jbosseap7
# systemctl status jbosseap7
● jbosseap7.service - JBoss EAP7
   Loaded: loaded (/etc/systemd/system/jbosseap7.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Mon 2018-06-11 07:32:47 EDT; 7s ago
  Process: 2913 ExecStop=/etc/init.d/jboss-eap-rhel.sh stop (code=exited, status=0/SUCCESS)
  Process: 2771 ExecStart=/etc/init.d/jboss-eap-rhel.sh start (code=exited, status=0/SUCCESS)
 Main PID: 2537 (code=exited, status=0/SUCCESS)

Jun 11 07:32:15 node01.local.com systemd[1]: Starting JBoss EAP7...
Jun 11 07:32:15 node01.local.com runuser[2782]: pam_unix(runuser:session): session opened for user jboss by (uid=0)
Jun 11 07:32:15 node01.local.com jboss-eap-rhel.sh[2771]: Starting jboss-eap: /
Jun 11 07:32:46 node01.local.com jboss-eap-rhel.sh[2771]: jboss-eap started with errors, please see server log for details
Jun 11 07:32:46 node01.local.com jboss-eap-rhel.sh[2771]: [  OK  ]
Jun 11 07:32:47 node01.local.com jboss-eap-rhel.sh[2913]: Stopping jboss-eap: [  OK  ]
Jun 11 07:32:47 node01.local.com systemd[1]: Started JBoss EAP7.

# ps -ef | grep jboss
root      2924  2222  0 07:33 pts/0    00:00:00 grep --color=auto jboss

# systemctl start jbosseap7

# systemctl status jbosseap7
● jbosseap7.service - JBoss EAP7
   Loaded: loaded (/etc/systemd/system/jbosseap7.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2018-06-11 07:33:35 EDT; 3s ago
  Process: 2913 ExecStop=/etc/init.d/jboss-eap-rhel.sh stop (code=exited, status=0/SUCCESS)
  Process: 2930 ExecStart=/etc/init.d/jboss-eap-rhel.sh start (code=exited, status=0/SUCCESS)
 Main PID: 2943 (standalone.sh)
   CGroup: /system.slice/jbosseap7.service
           ├─2943 /bin/sh /opt/jboss/bin/standalone.sh -c standalone.xml
           └─3012 java -D[Standalone] -server -verbose:gc -Xloggc:/opt/jboss/standalone/log/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:Nu...

Jun 11 07:33:19 node01.local.com systemd[1]: Starting JBoss EAP7...
Jun 11 07:33:19 node01.local.com runuser[2941]: pam_unix(runuser:session): session opened for user jboss by (uid=0)
Jun 11 07:33:19 node01.local.com jboss-eap-rhel.sh[2930]: Starting jboss-eap: /
Jun 11 07:33:35 node01.local.com jboss-eap-rhel.sh[2930]: [  OK  ]
Jun 11 07:33:35 node01.local.com systemd[1]: Started JBoss EAP7.

PS 结果:

# ps -aux|grep jboss
jboss     4559  0.0  0.0 113120  1540 ?        S    07:58   0:00 /bin/sh /opt/jboss/bin/standalone.sh -c standalone.xml
jboss     4628 49.4 33.9 3077608 640432 ?      Sl   07:58   0:15 java -D[Standalone] -server -verbose:gc -Xloggc:/opt/jboss/standalone/log/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading -Xms1303m -Xmx1303m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Dorg.jboss.boot.log.file=/opt/jboss/standalone/log/server.log -Dlogging.configuration=file:/opt/jboss/standalone/configuration/logging.properties -jar /opt/jboss/jboss-modules.jar -mp /opt/jboss/modules org.jboss.as.standalone -Djboss.home.dir=/opt/jboss -Djboss.server.base.dir=/opt/jboss/standalone -c standalone.xml
root      4754  0.0  0.0 112644   952 pts/0    R+   07:58   0:00 grep --color=auto jboss

答案1

从systemctl守护进程的日志中,很明显它正在尝试读取jboss的pid文件。

因此,首先删除它的 pid 文件:

rm /var/run/jboss-eap/jboss-eap-standalone.pid

现在,注释以下行并重新加载守护进程:

#PIDFile=/var/run/jboss-eap/jboss-eap-standalone.pid
systemctl daemon-reload

然后启动jboss服务。

systemctl start jbosseap7

相关内容