Nginx + Tomcat + redis Server Load balancer plan

Source: Internet
Author: User
Tags redis server

Software and jar packages required by Server Load balancer

Redis-2.4.14.tar.gz
Tcl8.5.11-src.tar.gz
Nginx-1.2.0.tar.gz
Tomcat-redis-session-manager-1.0.jar
Commons-pool-1.6-bin.tar.gz
Jedis-2.1.0.jar

Step 1: install Tomcat to support redis cache policies
1. Copy the JAR file to ¥atat_home/lib /.
2. Correct ¥ atat_home/CONF/context. xml
Add
<Valve classname = "com. radiadesign. Catalina. session. redissessionhandlervalve"/>
<Manager classname = "com. radiadesign. Catalina. session. redissessionmanager"
Host = "localhost"
Port = "6379"
Database = "0"
Maxinactiveinterval = "60"
/>

Step 2 install the redis Application

Install the redis attachment Library
Tcl8.5.11-src.tar.gz
Tar zxvf tcl8.5.11-src.tar.gz
CD tcl8.5.11/Unix
./Configure -- prefix =/usr
-- Enable-threads
-- Mandir =/usr/share/Man &&
Make &&

Sed-I
-E "s @ ^ (tcl_src_dir =" "). * @ 1/usr/include ""@"
-E "/tcl_ B/s @ =" "(-l )\?. * UNIX @ = "" 1/usr/lib @"
Tclconfig. Sh
Make install &&
Make install-private-headers &&
Ln-v-SF tclsh8.5/usr/bin/tclsh &&
Chmod-V 755/usr/lib/libtcl8.5.so
Ln-v-SF tclsh8.5/usr/bin/tclsh
Ldconfig-p | grep "" TCL ""
Libtcl8.5.so (libc6, x86-64) =>/usr/lib/libtcl8.5.so
Libtcl8.4.so (libc6, x86-64) =>/usr/lib64/libtcl8.4.so
Libopenipmitcl. so.0 (libc6, x86-64) =>/usr/lib64/libopenipmitcl. so.0
The libtcl8.5.so statement is displayed, indicating that the installation is successful.
Start to install redis
Tar zxvf redis-2.4.14.tar.gz
CD redis-2.4.14
Make
Make Test
Make install
Echo 1>/proc/sys/Vm/overcommit_memory
Sudo-S
Mkdir-P/usr/local/redis/bin
Mkdir-P/usr/local/redis/etc
Mkdir-P/usr/local/redis/var
CP redis-server redis-cli redis-benchmark redis-STAT/usr/local/redis/bin/
CP redis. CONF/usr/local/redis/etc/


Vim redis. conf
The current directory redis. conf is the redis device file.

Daemonize no changed no to redis for background running
Run/usr/local/redis/bin/redis-server/usr/local/redis/etc/redis. conf

./Redis-CLI is a test client script (you can execute this script to interact with redis)
Set a B
Get
Installation Complete

Start toncat test session Storage
Step 3 install nginx
First install the attached class library
Yum-y install PCRE-devel // HTTP rewrite Module
Yum-y install OpenSSL-devel // HTTP cache module requireslibrary
Yum install-y zlib-devel // gzib
Install nginx
./Configure -- prefix =/usr/local/nginx -- without-http_rewrite_module
Make make install
Device VI/usr/local/nginx/CONF/nginx. conf

// The default weight of the Server Load balancer host list is 1.
Upstream backend
{
Server 192.168.1.246: 8080;
Server 192.168.1.246: 9080;
}
Server Device
{
Proxy_redirect off;

Proxy_set_header host ¥ host;
Proxy_set_header X-real-IP $ remote_addr;
Proxy_set_header X-forwarded-for ¥ proxy_add_x_forwarded_for;
Proxy_pass http: // backend;

}
// Test the nginx Device

Sbin/nginx-T
Restart nginx
Kill-HUP 'cat/usr/local/nginx/logs/nginx. pid'

Over!

Related Article

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.