Centos 8 安装 Openbravo 之安装 Tomcat9

[root@openbravo ~]# useradd -d /opt/tomcat -s /bin/nologin tomcat

[root@openbravo ~]# wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.27/bin/apache-tomcat-9.0.27.tar.gz

[root@openbravo ~]# tar -zxvf apache-tomcat-9.0.27.tar.gz 

[root@openbravo ~]# mv apache-tomcat-9.0.27/* /opt/tomcat
[root@openbravo ~]# ll /opt/tomcat/
总用量 124
drwxr-x---. 2 root root  4096 11月 15 01:50 bin
-rw-r-----. 1 root root 18982 10月  7 05:59 BUILDING.txt
drwx------. 2 root root   238 10月  7 05:59 conf
-rw-r-----. 1 root root  5408 10月  7 05:59 CONTRIBUTING.md
drwxr-x---. 2 root root  4096 11月 15 01:50 lib
-rw-r-----. 1 root root 57092 10月  7 05:59 LICENSE
drwxr-x---. 2 root root     6 10月  7 05:57 logs
-rw-r-----. 1 root root  2333 10月  7 05:59 NOTICE
-rw-r-----. 1 root root  3255 10月  7 05:59 README.md
-rw-r-----. 1 root root  6849 10月  7 05:59 RELEASE-NOTES
-rw-r-----. 1 root root 16262 10月  7 05:59 RUNNING.txt
drwxr-x---. 2 root root    30 11月 15 01:50 temp
drwxr-x---. 7 root root    81 10月  7 05:57 webapps
drwxr-x---. 2 root root     6 10月  7 05:57 work
[root@openbravo ~]# ll /opt/
总用量 4
drwx------. 9 tomcat tomcat 4096 11月 15 01:52 tomcat
[root@openbravo ~]# chown -R tomcat:tomcat /opt/tomcat/
[root@openbravo ~]# ll /opt/tomcat/
总用量 124
drwxr-x---. 2 tomcat tomcat  4096 11月 15 01:50 bin
-rw-r-----. 1 tomcat tomcat 18982 10月  7 05:59 BUILDING.txt
drwx------. 2 tomcat tomcat   238 10月  7 05:59 conf
-rw-r-----. 1 tomcat tomcat  5408 10月  7 05:59 CONTRIBUTING.md
drwxr-x---. 2 tomcat tomcat  4096 11月 15 01:50 lib
-rw-r-----. 1 tomcat tomcat 57092 10月  7 05:59 LICENSE
drwxr-x---. 2 tomcat tomcat     6 10月  7 05:57 logs
-rw-r-----. 1 tomcat tomcat  2333 10月  7 05:59 NOTICE
-rw-r-----. 1 tomcat tomcat  3255 10月  7 05:59 README.md
-rw-r-----. 1 tomcat tomcat  6849 10月  7 05:59 RELEASE-NOTES
-rw-r-----. 1 tomcat tomcat 16262 10月  7 05:59 RUNNING.txt
drwxr-x---. 2 tomcat tomcat    30 11月 15 01:50 temp
drwxr-x---. 7 tomcat tomcat    81 10月  7 05:57 webapps
drwxr-x---. 2 tomcat tomcat     6 10月  7 05:57 work

[root@openbravo ~]# echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk-11.0.5.10-0.el8_0.x86_64

[root@openbravo ~]# vim /etc/systemd/system/tomcat.service

[Unit]
Description=Apache Tomcat Web Application Container
Wants=network.target
After=network.target

[Service]
Type=forking


Environment=JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.5.10-0.el8_0.x86_64
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment='CATALINA_OPTS=-server -Xms512M -Xmx1G -Djava.net.preferIPv4Stack=true -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true'

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
SuccessExitStatus=143

User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target

 

配置selinux

[root@openbravo ~]# systemctl start tomcat
Warning: The unit file, source configuration file or drop-ins of tomcat.service changed on disk. Run 'systemctl daemon-reload' to reload units.
Job for tomcat.service failed because the control process exited with error code.
See "systemctl status tomcat.service" and "journalctl -xe" for details.

[root@openbravo ~]# systemctl daemon-reload
[root@openbravo ~]# systemctl start tomcat 
Job for tomcat.service failed because the control process exited with error code.
See "systemctl status tomcat.service" and "journalctl -xe" for details

[root@openbravo ~]# journalctl -xe
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- 
-- tomcat.service 单元已结束停止操作。
11月 15 10:44:43 openbravo systemd[1]: Starting Apache Tomcat Web Application Container...
-- Subject: tomcat.service 单元已开始启动
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- 
-- tomcat.service 单元已开始启动。
11月 15 10:44:43 openbravo systemd[14925]: tomcat.service: Failed to execute command: Permission denied
11月 15 10:44:43 openbravo systemd[14925]: tomcat.service: Failed at step EXEC spawning /opt/tomcat/bin/startup.sh>
-- Subject: 进程 /opt/tomcat/bin/startup.sh 无法执行
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- 
-- 进程 /opt/tomcat/bin/startup.sh 无法被执行并已失败。
-- 
-- 该进程返回的错误代码为 13。
11月 15 10:44:43 openbravo systemd[1]: tomcat.service: Control process exited, code=exited status=203
11月 15 10:44:43 openbravo systemd[1]: tomcat.service: Failed with result 'exit-code'.
11月 15 10:44:43 openbravo systemd[1]: Failed to start Apache Tomcat Web Application Container.
-- Subject: tomcat.service 单元已失败
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- 
-- tomcat.service 单元已失败。
-- 
-- 结果为“RESULT”。
11月 15 10:44:43 openbravo setroubleshoot[14916]: SELinux is preventing /usr/lib/systemd/systemd from execute acce>
11月 15 10:44:43 openbravo platform-python[14916]: SELinux is preventing /usr/lib/systemd/systemd from execute acc>
                                                    
                                                    *****  Plugin catchall (100. confidence) suggests   **********>
                                                    
                                                    If you believe that systemd should be allowed execute access o>
                                                    Then you should report this as a bug.
                                                    You can generate a local policy module to allow this access.
                                                    Do
                                                    allow this access for now by executing:
                                                    # ausearch -c '(artup.sh)' --raw | audit2allow -M my-artupsh
                                                    # semodule -X 300 -i my-artupsh.pp
                                                    

[root@openbravo ~]# ausearch -c '(artup.sh)' --raw | audit2allow -M my-artupsh
******************** 重要 ***********************
要激活这个策略包,执行

semodule -i my-artupsh.pp

[root@openbravo ~]# semodule -X 300 -i my-artupsh.pp

[root@openbravo ~]# systemctl start tomcat
Job for tomcat.service failed because the control process exited with error code.
See "systemctl status tomcat.service" and "journalctl -xe" for details.
[root@openbravo ~]# journalctl -xe
-- Support: https://access.redhat.com/support
-- 
-- tomcat.service 单元已失败。
-- 
-- 结果为“RESULT”。
11月 15 10:49:37 openbravo dbus-daemon[768]: [system] Successfully activated service 'org.fedoraproject.Setroubles>
11月 15 10:49:37 openbravo setroubleshoot[15201]: SELinux is preventing /usr/lib/systemd/systemd from 'read, open'>
11月 15 10:49:37 openbravo platform-python[15201]: SELinux is preventing /usr/lib/systemd/systemd from 'read, open>
                                                    
                                                    *****  Plugin restorecon (99.5 confidence) suggests   ********>
                                                    
                                                    If you want to fix the label. 
                                                    /opt/tomcat/bin/startup.sh default label should be bin_t.
                                                    Then you can run restorecon. The access attempt may have been >
                                                    Do
                                                    # /sbin/restorecon -v /opt/tomcat/bin/startup.sh
                                                    
                                                    *****  Plugin catchall (1.49 confidence) suggests   **********>
                                                    
                                                    If you believe that systemd should be allowed read open access>
                                                    Then you should report this as a bug.
                                                    You can generate a local policy module to allow this access.
                                                    Do
                                                    allow this access for now by executing:
                                                    # ausearch -c '(artup.sh)' --raw | audit2allow -M my-artupsh
                                                    # semodule -X 300 -i my-artupsh.pp
                                                    
11月 15 10:49:44 openbravo systemd[1]: Starting dnf makecache...
-- Subject: dnf-makecache.service 单元已开始启动
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- 
-- dnf-makecache.service 单元已开始启动。
11月 15 10:49:44 openbravo dnf[15209]: 元数据缓存近期已刷新。
11月 15 10:49:44 openbravo systemd[1]: Started dnf makecache.
-- Subject: dnf-makecache.service 单元已结束启动
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- 
-- dnf-makecache.service 单元已结束启动。
-- 
-- 启动结果为“RESULT”。

[root@openbravo ~]# /sbin/restorecon -v /opt/tomcat/bin/startup.sh
Relabeled /opt/tomcat/bin/startup.sh from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:bin_t:s0

[root@openbravo ~]# systemctl status tomcat                   
● tomcat.service - Apache Tomcat Web Application Container
   Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2019-11-15 10:54:53 EST; 6s ago
  Process: 15590 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS)
 Main PID: 15600 (java)
    Tasks: 43 (limit: 4595)
   Memory: 237.1M
   CGroup: /system.slice/tomcat.service
           └─15600 /usr/lib/jvm/java-11-openjdk-11.0.5.10-0.el8_0.x86_64/bin/java -Djava.util.logging.config.file=>

11月 15 10:54:53 openbravo systemd[1]: tomcat.service: Service RestartSec=10s expired, scheduling restart.
11月 15 10:54:53 openbravo systemd[1]: tomcat.service: Scheduled restart job, restart counter is at 979.
11月 15 10:54:53 openbravo systemd[1]: Stopped Apache Tomcat Web Application Container.
11月 15 10:54:53 openbravo systemd[1]: Starting Apache Tomcat Web Application Container...
11月 15 10:54:53 openbravo startup.sh[15590]: Existing PID file found during start.
11月 15 10:54:53 openbravo startup.sh[15590]: Removing/clearing stale PID file.
11月 15 10:54:53 openbravo startup.sh[15590]: Tomcat started.
11月 15 10:54:53 openbravo systemd[1]: Started Apache Tomcat Web Application Container.

[root@openbravo ~]# systemctl enable tomcat
Created symlink /etc/systemd/system/multi-user.target.wants/tomcat.service → /etc/systemd/system/tomcat.service.

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值