Label: nginx Tomcat load balancing cluster

experimental topology:

技术分享

 

experimental requirements:

  Customer access 192.168.10.10, first or first request will pleaseRequest to 10.101, second or second request to 10.102. SanezumiNow two servers load, more than the same way to build.

test environment:

host

operating system

software required

Nginx server

RHEL 6.5 x 86 _ 64

nginx-1.6.0.tar.gz

Tomcat server 1

CentOS 6.5 x 86 _ 64

apache-tomcat-7.0.54.tar. Gzjdk-7u65-linux-x64.gz

Tomcat server 2

CentOS 6.5 x 86 _ 64

2.       for the convenience of the experiment,3linux host and1VMnet1

技术分享

3. IP address as topology

clientIP

2.       Tomcat11)     IP

Ping Tomcat2 server

技术分享

Ping Nginx server

技术分享

buildjava environment

[[email protected]~]# service iptables stop  // close the firewall

[[email protected]~]# setenforce 0  // turn off securitylinux

技术分享

[[email protected]~]# cd /opt

[[email protected]]# tar xzvf jdk-7u65-linux-x64.gz

[[email protected]]# ls

技术分享

 

[[email protected]]# mv jdk1.7.0_65/ /usr/local/java

[[email protected]]# vi /etc/profile.d/java.sh  // buildjava.shjava root directory, inPATHjavabin

 

[[email protected] opt]# yum remove java  // remove the system’s ownjava program       

[[email protected]]# source /etc/profile.d/java.sh  //[[email protected]]# java –version  // Viewjava

buildTomcat

[[email protected]]# tar xzvf apache-tomcat-7.0.54.tar.gz

[[email protected]]# ls

技术分享

 

[[email protected]]# mv apache-tomcat-7.0.54 /usr/local/tomcat7

[[email protected]]# /usr/local/tomcat7/bin/startup.sh  // starttomcat

[[email protected]]# netstat -anpt | grep 8080

技术分享

 

 

技术分享

 

buildjavaweb Site

[[email protected]]# mkdir -p /web/webapp1

[[email protected]]# vi /web/webapp1/index.jsp  //

[[email protected]]# vi /usr/local/tomcat7/conf/server.xml //web

[[email protected]]# /usr/local/tomcat7/bin/shutdown.sh  //

[[email protected]]# /usr/local/tomcat7/bin/startup.sh   // RestartTomcat

 

 

 技术分享

3.       build from thisTomcat2 server

 IP

Ping Nginx server  

技术分享

[[email protected]~]# service iptables stop

[[email protected]~]# setenforce 0

 

技术分享

 

 

 

 

 

4.       Nginx1)     IP

 

buildNginx server

[[email protected]]# service iptables stop

[[email protected]]# setenforce 0

技术分享

 

[[email protected]]# yum install -y \   // install related packages

> pcre-devel \

> zlib-devel \

> openssl-devel

 

[[email protected]]# yum -y install \   // install compiler tools

> gcc \

> gcc-c++ \

> make

 

[[email protected]]# useradd www -s /bin/false   // createnginx Userwww, no landing.shell

[[email protected]]# tar xzvf nginx-1.6.0.tar.gz

[[email protected]]# ls

技术分享

 

[[email protected]]# cd nginx-1.6.0

 

[[email protected]]# ./configure \ 

>–prefix=/usr/local/nginx \

> –user=www \

> –group=www \

> –with-file-aio\

>–with-http_stub_status_module \

>–with-http_gzip_static_module \

>–with-http_flv_module \

>–with-http_ssl_module

 

[[email protected]]# make

[[email protected]]# make install

[[email protected]]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/  // in order to facilitate management, the main processSequencenginx[[email protected]]# vi /usr/local/nginx/conf/nginx.conf

技术分享

 If you have more than one server, write down the format.

tomcat

nginx by defaultproxy_pass way proxy totomcat_server Group

 

[[email protected]]# nginx –t  // check configuration file

技术分享

[[email protected]]# nginx  // startnginx

[[email protected]]# netstat -anpt | grep 80

 

技术分享

 

result validation:

技术分享

 

 

refresh

 

技术分享

 

refresh again

技术分享

This article is from the “sunshine academy” blog, please be sure to keep this source http: /Yuan2.blog.51cto.com / 446689 / 1670924

Build Nginx + Tomcat load balancing cluster

Label: nginx Tomcat load balancing cluster

Original address: http: / Yuan2. Blog. 51CTO. COm / 446689 / 1670924

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *