位置: 编程技术 - 正文
推荐整理分享centos7下systemd实现tomcat多实例配置方法(centos7 syslog),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:centos7 systemctl,centos7 syslog,centos7 system halted,centos7 systemctl,centos7 sysctl,centos7 system halted,centos7 system halted,centos7 systemd,内容如对您有帮助,希望把文章链接给更多的朋友!
本文我们分享在Centos安装tomcat,然后用systemd实现tomcat多实例的方法,有需求的朋友可以认真参考一下。系统环境: CentOS 7 x_
1、安装jdk
rpm -ivh jdk-8u-linux-x.rpm
2、创建普通用户
getent group tomcat || groupadd -r tomcatgetent passwd tomcat || useradd -r -d /opt -s /bin/nologin tomcat
3、下载tomcat 7cd /optwget zxvf apache-tomcat-7.0..tar.gzmv apache-tomcat-7.0. tomcatchown -R tomcat:tomcat tomcat tar zxvf apache-tomcat-7.0..tar.gzmv apache-tomcat-7.0. tomcatchown -R tomcat:tomcat tomcat
两个实例同时监听端口必然会产生冲突,所以必须修改.
sed -i 's///g' /opt/tomcat/conf/server.xmlsed -i 's///g' /opt/tomcat/conf/server.xmlsed -i 's///g' /opt/tomcat/conf/server.xmlsed -i 's///g' /opt/tomcat/conf/server.xml
AJP通常用不上,这里统一关闭
sed -i '//d' /opt/tomcat/conf/server.xmlsed -i '//d' /opt/tomcat/conf/server.xml
tomcat在Linux 下默认工作模式是bio,性能非常低,建议使用apr或者nio,这里改为nio,即非阻塞IO,性能比较好。
sed -i.bak 's#HTTP/1.1#org.apache.coyote.http.HttpNioProtocol#' /opt/tomcat/conf/server.xmlsed -i.bak 's#HTTP/1.1#org.apache.coyote.http.HttpNioProtocol#' /opt/tomcat/conf/server.xml
4、创建启动文件
cd /usr/lib/systemd/systemcat >tomcat.service <<EOF[Unit]Description=Apache Tomcat 7After=network.target[Service]Type=oneshotExecStart=/opt/tomcat/bin/startup.shExecStop=/opt/tomcat/bin/shutdown.shRemainAfterExit=yesUser=tomcatGroup=tomcat[Install]WantedBy=multi-user.targetEOFtomcat同理sed 's/tomcat/tomcat/g' tomcat.service > tomcat.service
5、启动服务
systemctl enable tomcatsystemctl enable tomcatsystemctl start tomcatsystemctl start tomcat
6、查看进程
ps aux |grep tomcat附上一份nginx反向代理tomcat的配置文件proxy_cache_path /var/cache/nginx/proxy_cache levels=1:2 keys_zone=static:m inactive=1h max_size=1g; upstream tomcat { ip_hash ; #hash $remote_addr consistent; server .0.0.1: max_fails=1 fail_timeout=2s ; server .0.0.1: max_fails=1 fail_timeout=2s ; ; keepalive ;} server { listen ; server_name tomcat.example.com; charset utf-8; access_log /var/log/nginx/tomcat.access.log main; root /usr/share/nginx/html; index index.html index.htm index.jsp; location / { proxy_pass proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_cache_use_stale error timeout invalid_header updating http_ http_ http_ http_; proxy_connect_timeout ; proxy_send_timeout ; proxy_read_timeout ; proxy_http_version 1.1; proxy_set_header Connection ""; add_header X-Backend "$upstream_addr"; } location ~* ^.+.(js|css|ico|gif|jpg|jpeg|png)$ { proxy_pass ; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_cache_use_stale error timeout invalid_header updating http_ http_ http_ http_; proxy_connect_timeout ; proxy_send_timeout ; proxy_read_timeout ; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_cache static; proxy_cache_key $host$uri$is_args$args; proxy_cache_valid 5m; proxy_cache_valid 1m; proxy_cache_valid any 1h; add_header X-Cache $upstream_cache_status; #log_not_found off; #access_log off; expires max; } location ~ /.ht { deny all; } }
CentOS7 增加tomcat 启动、停止(使用systemctl进行配置) 1,centos7使用systemctl替换了service命令参考:redhat文档:
CentOS系统恢复误删除文件的方法 CentOS系统中,当误删除了文件后,进行以下几步操来恢复文件。1、关掉所有的服务当发现误删除文件时,为了尽可能的恢复数据,先要关掉所有的正在
centos所有版本镜像下载地址集合 版本号下载地址更新时间centos2.1iso镜像下载2.1//8/:centos3.1iso镜像下载3.1//7/:centos3.3iso镜像下载3.3//3/:centos3.4iso镜像下载3.4//3/:ce
标签: centos7 syslog
本文链接地址:https://www.jiuchutong.com/biancheng/350486.html 转载请保留说明!上一篇:CentOS内核的编译与安装简单示例分享(centos编译器)
下一篇:CentOS7 增加tomcat 启动、停止(使用systemctl进行配置)(centos7配置tomcat)
友情链接: 武汉网站建设