100513. Nginx+tomcat cluster +session sharing (Linux)

Source: Internet
Author: User

First step: Multiple Tomcat installations and JDK installations in Linux (slightly)

The second step: Nginx installation, Linux installed Nginx and windows are a little different also error-prone, need to compile, here to do the introduction

First, installation dependent

Gcc

Openssl-fips-2.0.2.tar.gz

Zlib-1.2.7.tar.gz

Pcre-8.21.tar.gz

To download the Linux version of the installation package, if you do not download the installation package, you can install the command online:

Yum Install gcc-c++

Yum install-y pcre Pcre-devel

Yum install-y zlib Zlib-devel

Yum Install-y OpenSSL Openssl-devel

Install through the installation package as follows (one example below)

[Email protected] ~]# TAR-ZXVF openssl-fips-2.0.2.tar.gz [[email protected] ~]# CD openssl-fips-2.0.2
[Email protected] openssl-fips-2.0.2]#/config [[email protected] openssl-fips-2.0.2]# make
[[email protected] openssl-fips-2.0.2]# make install

Second, download and install Nginx

Download nginx-1.2.6.tar.gz

[Email protected] nginx-1.2.6]#./configure
--with-pcre=. /pcre-8.21

--with-openssl=. /openssl-fips-2.0.2
[[email protected] nginx-1.2.6]# make
[[email protected] nginx-1.2.6]# make install

The installation of Nginx is complete!

Go to Niginx's Sbin catalog check for Success

[Email protected] nginx-1.2.6]# Cd/usr/local/nginx/sbin[[email protected] sbin]#./nginx-t

Start Nginx (go to the Sbin directory to execute the following command)

[Email protected] sbin]#./nginx

Step three: Configure a few tomcat, each of which will be server.xml in the 8080,8005,8009 of these places to fix it.

Fourth step: Modify the nginx.conf (pay attention to add red section on it)

Worker_processes 1;

Events {

Worker_connections 1024;

}

HTTP {

Include Mime.types;

Default_type Application/octet-stream;

Sendfile on;

Keepalive_timeout 65;

Upstream server_lb{#server_lb跟下面的一样

Server localhost:8090; #这里是tomcat的地址

Server localhost:8091;

}

server {

Listen 80;

server_name localhost;

Location/{

root HTML;

Proxy_pass http://server_lb;

Index index.html index.htm INDEX.JSPF index.jsp;

Proxy_redirect default;

}

Error_page 502 503 504/50x.html;

Location =/50x.html {

root HTML;

}

}

}

At this point, the Nginx+tomcat cluster is complete and can be accessed by http://localhost to view

Fifth step: Session sharing, because the broadcast mechanism of Tomcat is not supported in Linux, so it cannot be implemented as using modify Web. XML and Servcer.xml in Windows (described in the previous article). I need to use technology like Mencache or Redis to achieve this. This technique will be introduced later. Here to share to everyone a Redis learning video, you can first understand.

Note: I am also attaching the Redis teaching video I collected to the people who need it ...

100513. Nginx+tomcat cluster +session sharing (Linux)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.