CentOS6.5 below TOMCAT7 Nginx redis configuration steps Tutorial Detailed _linux

Source: Internet
Author: User
Tags session id redis

All configurations are done on one machine, and the deployment topology information is as follows:

Note: Because the Redis configuration is stricter for jar packs and Tomcat versions, be sure to use the TOMCAT7 and the jar packages provided in this article.

Download Address:

Http://pan.baidu.com/s/1bO67Ky

TOMCAT:TOMCAT1 localhost:8080

TOMCAT2 localhost:9080

nginx:localhost:1210

redis:localhost:6379

1. Tomcat Installation and configuration

1. In the Server.xml file, modifications to the TOMCAT2 port require a total of 3 changes, 8080, 8005, and 8009, respectively, to 9080, 9005, and 9008 respectively.

After you configure this step, enter http://localhost:8080 and http://localhost:9080 in the browser to see Tomcat's home page.

2. Nginx configuration to achieve load balancing.

2.1 Install Pcre. Because the Nginx rewrite module requires pcre support, the Pcre library needs to be installed.

2.1.1. Get pcre Compile installation package to get the current latest version on http://www.pcre.org/

2.1.2. Extract the pcre-xx.tar.gz package.

2.1.3. Enter the decompression directory, execute./configure.

2.1.4. Make

2.1.5. Make install

2.2 Install Nginx. Because there is no nginx in the Yum source that we want, we need to create a Yum source. The steps are as follows:

2.2.1. Vim/etc/yum.repos.d/nginx.repo

Enter the following, and then save the exit.

[Nginx]
Name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled= 1

2.2.2. Check to see if the Yum source is configured, execute the following command, and if so, the configuration succeeds.

Yum List |grep Nginx

2.2.3. Install Nginx.

Yum-y Install Nginx

2.2.4. Configure Nginx. Achieve load balancing. The main is to configure the nginx.conf file, using the RPM-QC nginx command to query the location of the configuration file.

2.2.5 Check that the configuration file is correct and restart Nginx.

NGINX-T
Service Nginx Restart the following commands are also available here: Nginx-s Reload

2.3 Verifying Load Balancing configuration

2.3.1 respectively Modify the TOMCAT1 and Tomcat2 first file, get the login session ID value, add the following image of the red box H1 tag

2.3.2 in Browser input: localhost:1210, check to see if the configuration was successful. As you can see, you have jumped to the Tomcat page and the configuration was successful.

3. Redis configuration, tomcat sharing session.

3.1 Download and install Redis3

3.1.1 into Redis website Download Redis3, step slightly.

3.1.2 Extract Files

TAR-XVF redis-3.0.2.tar.gz

3.1.3 Compile the installation.

CD redis-3.0.2 make make
install
./utils/install_server.sh # configuration Redis random Boot

3.1.4 Redis is started and closed.

Service redis_6379 start #6379为redis默认端口号, changes to the requirements, the name will change

Service redis_6379 Stop

Service redis_6379 Restart

3.2 Configure Tomcat sharing based on the Redis session mechanism.

3.2.1 Copies the following 3 jar packages to Tomcat's lib directory:

Commons-pool-1.3.jar Jedis-2.0.0.jar Tomcat-redis-session-manager-1.2-tomcat-7-java-7.jar

3.22 Modify the Context.xml file under Tomcat's Conf directory and add the following in the <Context> node:

<valve classname= "Com.radiadesign.catalina.session.RedisSessionHandlerValve"/> 
<manager classname= " Com.radiadesign.catalina.session.RedisSessionManager " 
host=" localhost " 
port=" 6379 " 
database=" "0" 
maxinactiveinterval= "/>"

3.3 reboot Tomcat, in the browser input localhost:1210, found TOMCAT1 and TOMCAT2 session has been shared.

The above is a small set to introduce the CentOS6.5 under the TOMCAT7 Nginx redis configuration Steps Tutorial detailed, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.