还剩2页未读,继续阅读
文本内容:
部署Nginx+Tomcat负载均衡集群部署思路:
1、Tomcat服务器设置关闭防火墙〃两台保持一致安装JDK〃两台保持一致安装Tomcat〃两台保持一致创建站点/明限/16$1;目录,修改50「丫©
1.*1111文件〃两台保持一致创建index,jsp文件〃两台有所区别(例如tomcat1和tomcat2)nginx服务器配置部署步骤
一、部署Tomcat
1、安装jdk[root@localhost、]#rpm-qa|grep jdk*[root@localhost tar-zxvf jdk-7u65-linux-x
64.gz[root@localhost〜]#mv jdkl.
7.065//usr/local/java[root@localhost whichjava[root@localhost]#rm-rf/usr/bin/java[root@localhost In-s/usr/local/java/bin/*/usr/bin/]#java-version下面方法有误[root@localhost[root@localhost tar-zxvf Jdk-7u65-linux-x
64.gz[root@localhost mvjdkl.
7.065//usr/local/java[root@localhost、]#vim/etc/profile.d/java.sh添加export JAVA_HOME=/usr/local/java exportPATH=$PATH:$JAVA_HOME/bin[root@localhost source/etc/profile.d/java.sh[root@localhost echo$PATH[root@localhost java-version
2、安装tomcat[root@localhost]#tar-zxvf apache-tomcat-
7.
0.
54.tar.gz〜[root@localhost~]#mv apache-tomcat-
7.
0.54/usr/local/tomcat7[root@localhost#/usr/local/tomcat7/bin/startup,sh〃启动tomcat]#netstat-anpt|grep8080[root@localhost~]#firefox.
168.
1.10:8080/[root@localhost]#/usr/local/tomcat7/bin/shutdown,sh〃关闭tomcat[root@localhost验证[root@localhost mkdir-pv/web/test[root@localhost vim/web/test/index.jsp添加〜验证tomcat站点,以及能够运行jsp1@page languagejava〃import java・util・*〃pageEncoding UTF—8〃%二〃二〃二〃head titleJSP/title/headbodyH out.printin/zwelcome toJSP server%/body/html[root@localhost/usr/local/tomcat7/conf/server,xml添加Context docBase=zz/web/test/,z path=〃〃reloadable=false”/Context注在host端增加Context[root@localhost#/usr/local/tomcat7/bin/shutdown,sh[root@localhost#/usr/local/tomcat7/bin/startup,sh[root@localhost^]#firefox.
168.
1.1:8080/
二、部署Nginx服务器
1、安装Nginx[root@localhost yum-y installpcre-devel zlib-devel[root@localhost useradd-M-s/sbin/nologin nginx[root@localhost tar-zxvf nginx-
1.
6.
0.tar.gz-C/usr/src/[root@localhost cd/usr/src/nginx-
1.
6.0/[root@localhost nginx-
1.
6.0]#./configure prefix=/usr/local/nginx user=nginx group=nginx一一一一一一--with-file-aio--with-http_stub_status_module--with-http_gzip_static_module一with_http_flv_module--with-http_ssl_module[root@localhost nginx-
1.
6.0]#makemake install[root@localhost In-s/usr/local/nginx/sbin/*/usr/local/sbin/[root@localhost nginx-t[root@localhost nginx[root@localhost netstat-anpt grep80[root@localhost killall-s HUPnginx//重新加载[root@localhost〜killall-s QUITnginx//关闭服务[root@localhost nginx〜验证[root@localhost firefoxhttp://localhost/〜
2、设置权重[root@localhost vim/usr/local/nginx/conf/nginx.conf在http{}中添加:upstream tomcat_server{server
192.
168.
1.10:8080weight=l;server
192.
168.
1.20:8080weight=l;}location/{}中添力□:proxypass;
3、重启Nginx服务[root@localhost killall-s QUITnginx〜[root@localhost nginx〜[root@localhost netstat-anpt|grep nginx
4、验证[root@localhost#firefox.
1.1/验证结果分别显示Tomcatl和Tomcat2上的网站页面。
个人认证
优秀文档
获得点赞 0