码迷,mamicode.com
首页 > 其他好文 > 详细

nginx+Tomcat负载均衡

时间:2020-04-22 16:39:41      阅读:66      评论:0      收藏:0      [点我收藏+]

标签:syntax   height   stream   yum   visible   imp   sof   server   image   

#!/bin/bash
rpm -ivh jdk-8u131-linux-x64_.rpm
if [ `grep JAVA_HOME /etc/profile | wc -l` -ne 4 ];then
echo -e ‘export JAVA_HOME=/usr/java/jdk1.8.0_131\n
export JAVA_BIN=/usr/javak1.8.0_131/bin\n
export PATH=$PATH:$JAVA_HOME/bin\n
export CLASSPATH=.:$JAVA_HOMEb/dt.jar:$JAVA_HOMEb/tools.jar\n
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH‘ >> /etc/profile
fi
source /etc/profile
tar xfz apache-tomcat-7.0.47.tar.gz
mv apache-tomcat-7.0.47 /opt/tomcat1
tar xfz apache-tomcat-7.0.47.tar.gz
mv apache-tomcat-7.0.47 /opt/tomcat2
sed -i ‘s/8009/18009/‘ /opt/tomcat2/conf/server.xml
sed -i ‘s/8005/18005/‘ /opt/tomcat2/conf/server.xml
sed -i ‘s/8080/18080/‘ /opt/tomcat2/conf/server.xml
yum -y install supervisor
systemctl start supervisord
touch /etc/supervisord.d/tomcat1.ini
touch /etc/supervisord.d/tomcat2.ini
echo -e ‘[program:tomcat1]
command=/opt/tomcat1/bin/catalina.sh run‘ >> /etc/supervisord.d/tomcat1.ini
echo -e ‘[program:tomcat2]
command=/opt/tomcat2/bin/catalina.sh run‘ >> /etc/supervisord.d/tomcat2.ini
systemctl restart supervisord
yum -y install gcc gcc-c++ pcre-devel zlib-devel
tar xfz nginx-1.12.0.tar.gz
cd nginx-1.12.0 && ./configure && make && make install
sed -i ‘/#gzip  on;/aupstream tomcat{‘ /usr/local/nginx/conf/nginx.conf
sed -i ‘/upstream tomcat{/aserver 10.0.0.41:8080;‘ /usr/local/nginx/conf/nginx.conf
sed -i ‘/server 10.0.0.41:8080;/aserver 10.0.0.41:18080;‘ /usr/local/nginx/conf/nginx.conf
sed -i ‘/server 10.0.0.41:18080;/a\}‘ /usr/local/nginx/conf/nginx.conf
sed -i ‘s/index.htm;$/index.jsp;/‘ /usr/local/nginx/conf/nginx.conf
sed -i ‘/404.html;/alocation ~ \.jsp$ {‘ /usr/local/nginx/conf/nginx.conf
sed -i ‘/location ~ \.jsp$ {/aproxy_pass   http://tomcat;‘ /usr/local/nginx/conf/nginx.conf
sed -i ‘/proxy_pass   http:\/\/tomcat;/a\}‘ /usr/local/nginx/conf/nginx.conf
/usr/local/nginx/sbin/nginx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
rpm -ivh jdk-8u131-linux-x64_.rpm
if [ `grep JAVA_HOME /etc/profile | wc -l` -ne 4 ];then
echo -e ‘export JAVA_HOME=/usr/java/jdk1.8.0_131\n
export JAVA_BIN=/usr/javak1.8.0_131/bin\n
export PATH=$PATH:$JAVA_HOME/bin\n
export CLASSPATH=.:$JAVA_HOMEb/dt.jar:$JAVA_HOMEb/tools.jar\n
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH‘ >> /etc/profile
fi
source /etc/profile
tar xfz apache-tomcat-7.0.47.tar.gz
mv apache-tomcat-7.0.47 /opt/tomcat1
tar xfz apache-tomcat-7.0.47.tar.gz
mv apache-tomcat-7.0.47 /opt/tomcat2
sed -i ‘s/8009/18009/‘ /opt/tomcat2/conf/server.xml
sed -i ‘s/8005/18005/‘ /opt/tomcat2/conf/server.xml
sed -i ‘s/8080/18080/‘ /opt/tomcat2/conf/server.xml
yum -y install supervisor
systemctl start supervisord
touch /etc/supervisord.d/tomcat1.ini
touch /etc/supervisord.d/tomcat2.ini
echo -e ‘[program:tomcat1]
command=/opt/tomcat1/bin/catalina.sh run‘ >> /etc/supervisord.d/tomcat1.ini
echo -e ‘[program:tomcat2]
command=/opt/tomcat2/bin/catalina.sh run‘ >> /etc/supervisord.d/tomcat2.ini
systemctl restart supervisord
yum -y install gcc gcc-c++ pcre-devel zlib-devel
tar xfz nginx-1.12.0.tar.gz
cd nginx-1.12.0 && ./configure && make && make install
sed -i ‘/#gzip  on;/aupstream tomcat{‘ /usr/local/nginx/conf/nginx.conf
sed -i ‘/upstream tomcat{/aserver 10.0.0.41:8080;‘ /usr/local/nginx/conf/nginx.conf
sed -i ‘/server 10.0.0.41:8080;/aserver 10.0.0.41:18080;‘ /usr/local/nginx/conf/nginx.conf
sed -i ‘/server 10.0.0.41:18080;/a\}‘ /usr/local/nginx/conf/nginx.conf
sed -i ‘s/index.htm;$/index.jsp;/‘ /usr/local/nginx/conf/nginx.conf
sed -i ‘/404.html;/alocation ~ \.jsp$ {‘ /usr/local/nginx/conf/nginx.conf
sed -i ‘/location ~ \.jsp$ {/aproxy_pass   http://tomcat;‘ /usr/local/nginx/conf/nginx.conf
sed -i ‘/proxy_pass   http:\/\/tomcat;/a\}‘ /usr/local/nginx/conf/nginx.conf
/usr/local/nginx/sbin/nginx

  

nginx+Tomcat负载均衡

标签:syntax   height   stream   yum   visible   imp   sof   server   image   

原文地址:https://www.cnblogs.com/wanglinyan/p/12752575.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!