目录
企业级WEB应用服务器TOMCAT
安装java环境
[root@tomcat ~]# yum install java-1.8.0-openjdk.x86_64 -y
安装并启动tomcat
[root@tomcat ~]# tar zxf apache-tomcat-9.0.91.tar.gz -C /usr/local/
[root@tomcat ~]# ln -s /usr/local/apache-tomcat-9.0.91/ /usr/local/tomcat
[root@tomcat ~]# /usr/local/tomcat/bin/startup.sh
生成tomcat的主配置文件
生成启动文件
[root@tomcat ~]# useradd -s /sbin/nologin -M tomcat
[root@tomcat ~]# chown -R tomcat.tomcat /usr/local/tomcat
[root@tomcat ~]# vim /lib/systemd/system/tomcat.service
[Unit]
Description=Tomcat
#After=syslog.target network.target remote-fs.target nss-lookup.target
After=syslog.target network.target
[Service]
Type=forking
EnvironmentFile=/usr/local/tomcat/conf/tomcat.conf
ExecStart=/usr/local/tomcat/bin/startup.sh
ExecStop=/usr/local/tomcat/bin/shutdown.sh
PrivateTmp=true
User=tomcat
Group=tomcat
[Install]
WantedBy=multi-user.target
[root@tomcat ~]# systemctl daemon-reload
[root@tomcat ~]# systemctl enable --now tomcat
查看tomcat相关目录和文件
[root@tomcat ~]# ls /usr/local/tomcat/
bin conf lib logs README.md RUNNING.txt
webapps
BUILDING.txt CONTRIBUTING.md LICENSE NOTICE RELEASE-NOTES temp work
同步没做好的话,tomcat2的操作如上tomcat1。
结合反向代理实现tomcat部署
实现tomcat中的负载均衡
每次刷新ID号都变,需要做会话保持
在原地址进行hash,流量都打在10上
tomcat负载均衡实
[root@Nginx ~]# vim /usr/local/nginx/conf.d/vhosts.conf
upstream tomcat {
ip_bash;
#hash $cookie_JSESSIONID;
server 172.25.254.10:8080;
server 172.25.254.20:8080;
}
server {
listen 80;
server_name lee.timinglee.org;
root /webdataw/nginx/timinglee.org/lee;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
try_files $uri $uri.html $uri/index.html /error/default.html;
location ~ \.jsp$ {
proxy_pass http://tomcat;
}
}