Distributed Web site Deployment

Source: Internet
Author: User

Environment Introduction: Two win2008_x64-bit host +jdk7_x64 bits are a host ip:192.168.7.100, B host ip:192.168.7.101

First, install the memcached (a host, b host need to install)

: http://download.csdn.net/detail/ttyyadd/9414586

Unzip to the local disk when the download is complete.

Open the CMD Command window to the directory where the Memcached.exe is located, and then execute the following command to install

After installation does not start need to go to service management inside find the memached service to start it.

Second, the following start configuration Tomcat6

1. First download the required jar

Place the downloaded jar under the Lib folder in the Tomcat directory

http://download.csdn.net/detail/ttyyadd/9414529

2. Start configuration (a host: 192.168.7.100) context.xml

<manager classname="De.javakaffee.web.msm.MemcachedBackupSessionManager"Memcachednodes="n1:192.168.7.100:11211,n2:192.168.7.101:11211"Failovernodes="N2"Requesturiignorepattern=".*\. (ICO|PNG|GIF|JPG|CSS|JS) $"Transcoderfactoryclass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"/>

Start Configuration (Host B: 192.168.7.101) context.xml

<manager classname="De.javakaffee.web.msm.MemcachedBackupSessionManager"Memcachednodes="n1:192.168.7.100:11211,n2:192.168.7.101:11211"Failovernodes="N1"Requesturiignorepattern=".*\. (ICO|PNG|GIF|JPG|CSS|JS) $"Transcoderfactoryclass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"/>

The note here is the Failovernodes property, which points to another host (not native).

3. Create a new test.jsp page, and place the root directory under Tomcat of host A and Host B, respectively

<%@ page language="java" %><%@ page import="java.util.*" %>System.  out . println (Session.getid ()); out. println ("<br> HostA hostb, SESSION ID:" + session.getid () +"  <br>"); %></body>

Third, configure Nginx

1, first download Nginx installation package

http://nginx.org/

2. Start configuring Nginx

Open the nginx.conf of the installation directory. My installation directory is (D:\nginx-1.9.9\conf\nginx.conf)

#user nobody;worker_processes1; #error_log logs/Error.log, #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid;events {worker_connections1024x768;}    HTTP {include mime.types; Default_type Application/octet-stream; #log_format Main'$remote _addr-$remote _user [$time _local] "$request"'    #                  '$status $body _bytes_sent "$http _referer"'    #                  '"$http _user_agent" "$http _x_forwarded_for "'; #access_log logs/Access.log Main;    Sendfile on;    #tcp_nopush on; #keepalive_timeout0; Keepalive_timeout $;  #gzip on; upstream Mysvr {#weigth参数表示权值, the higher the weight, the greater the probability of being assigned to it. 1.down indicates that the server is temporarily not participating in the load #2. Weight by default, the larger the 1.weight, the greater the load weight. #3. Backup: When all other non-backup machines are down or busy, request the backup machine.        So the pressure on this machine is the lightest.      #server 192.168.1.116 down;      #server 192.168.1.116 Backup;      Server 192.168.7.100:8080 weight=1; Server 192.168.7.101:8080 weight=1; } Server {Listen the; server_name 192.168.7.100; #charset Koi8-R; #access_log logs/Host.access.log Main;   Location/{Proxy_pass http://mysvr;        Proxy_connect_timeout 5s;        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_buffering off; } #error_page404/404. html; # REDIRECT Server error pages to theStaticPage/50x.html # Error_page - 502 503 504/50x.html; Location= /50x.html {root html; } # Proxy The PHP scripts to Apache listening on127.0.0.1: the# #location~\.php$ {# Proxy_pass http://127.0.0.1;#} # Pass the PHP scripts to FastCGI server listening on127.0.0.1:9000# #location~\.php$ {# root HTML; # Fastcgi_pass127.0.0.1:9000;        # Fastcgi_index index.php; # Fastcgi_param Script_filename/Scripts$fastcgi_script_name;        # include Fastcgi_params; #} # Deny access to. htaccess files,ifApache's Document Root# concurs with Nginx'S One# #location~ /\.ht {# deny all; #}} # anotherVirtualHostusingMix of ip-, name-, and port-based configuration # #server {# listen8000; # Listen Somename:8080;    # server_name somename alias Another.alias; # Location/{# root HTML;    # index index.html index.htm; #} #} # HTTPS Server # #server {# listen443SSL;    # server_name localhost;    # ssl_certificate Cert.pem;    # Ssl_certificate_key Cert.key;    # Ssl_session_cache shared:ssl:1m;    # ssl_session_timeout 5m; # Ssl_ciphers High:!anull:!MD5;    # ssl_prefer_server_ciphers on; # Location/{# root HTML;    # index index.html index.htm; #    }    #}}

Save and close. nginx.conf file content is more, in fact, only need to modify the red font part

Then the cmd window into the installation directory to start the Nginx command is:

Start Nginx

Nginx Other Related commands:

1) Start Nginx:start nginx

2) Stop the Nginx:nginx-s stop

3) Reboot after configuration modification: Nginx-s Reload

Has now been configured to complete

Start visit: http://192.168.7.100/test.jsp

You can see that the session ID does not change.

Distributed Web site Deployment

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.