nginx + keepalived + tomcat + memcache dual VIP session remains high availability and Session

Nginx + Keepalived + Tomcat + Memcached achieve double VIP load balancing and session remains Session


IP List:

Name IP software
--------------------------- ----------------------
VIPl 192.168.200.254     
VIP2 192.168.200.253
Nginx Nginx 192.168.200.101. 1-keepalived
Nginx Nginx keepalived 192.168.200.102 2-
Tomcat-192.168. 1 Tomcat the memcached .200.103
Tomcat-2 192.168.200.104 Tomcat the memcached



all machines and turn off the firewall Selinux:
[the root @ localhost ~] # iptables STOP-Service
[the root @ localhost ~] # 0 the setenforce


installation configuration Tomcat server and JDK:
===== ================================================== ================================================== ========
Installation Configuration JDK:
Extract the-7u65-Linux-JDK x64.tar.gz
[the root-Tomcat @ ~. 1] # RM -rf / usr / bin / Java
[the root-Tomcat @ ~. 1] # 7u65- the tar-XF JDK linux-x64.tar.gz

after extracting generates jdk1.7.0_65 folder, the folder to both the / usr / local named Java
[the root-Tomcat @ ~. 1] # Music Videos jdk1.7.0_65 / / usr / local / java

build script at java.sh /etc/profile.d/
[the root-Tomcat @ ~. 1] # Vim / etc / Profile # end of an additional
export JAVA_HOME = / usr / local / java # set java root
export PATH = $ PATH: $ JAVA_HOME / bin # add the bin subdirectory with java directory in the PATH environment variable in

the script to import java.sh environment variable to take effect
[root @ tomcat-1 ~] # source / etc / profile

run java -version java or javac -version command to view the version
[root @ Tomcat-1 ~] # java -version
java version "1.7.0_65"
the OpenJDK Runtime Environment (x86_64 RHEL-2.5.1.2.el6_5-U65-B17)
The VM 64-Bit Server the OpenJDK (24.65 Build-B04, Mixed MODE)
[the root-Tomcat @ ~. 1] # the javac -version
the javac 1.7.0_65


installation configuration Tomcat:
extract the package
[root @ tomcat-1 ~] # tar xf apache -tomcat-7.0.54.tar.gz

after decompression generating apache-tomcat-7.0.54 folder, the folder to the / usr / local, and renamed tomcat7
[the root-Tomcat @ ~. 1] # Music Videos Apache -tomcat-7.0.54 / usr / local / tomcat7

start the Tomcat
[the root-Tomcat @ ~. 1] # /usr/local/tomcat7/bin/startup.sh
the Using CATALINA_BASE: / usr / local / tomcat7
the Using CATALINA_HOME: / usr / local / tomcat7
the Using CATALINA_TMPDIR: / usr / local / tomcat7 / TEMP
the Using the JRE_HOME: / usr / local / Java
the Using the CLASSPATH: /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat- juli.jar
Tomcat Started.

Run Tomcat default port 8080
[the root-Tomcat @ ~. 1] # -anpt the netstat | grep: 8080
TCP 0 0 ::: ::: * LISTE 8080
N 55 349 / Java  

off Tomcat
[the root-Tomcat @ ~. 1] # / usr / local / tomcat7 / bin / shutdown.sh

browser to access the test http://192.168.200.103:8080


establishment of java web site:
first create a webapp directory with the directory for storing website files
[root @ tomcat- 1 ~] # mkdir / webapp

built on a test page index.jsp webapp1 directory of
[root @ Tomcat-1 ~] # vim /webapp/index.jsp
Server Info:   
SessionID: <% = session.getId ()%>
<br>
SessionIP: <% = to request.getServerName ()%>  
<br>
SessionPort: <% = to request.getServerPort ()%>
<br>
<%
  Out.println ( "Server One");
%>
              

Tomcat server.xml file to modify the

definition of a virtual host and file path to the website established / webapp, adding context segment host segment
[root @ tomcat-1 ~] # cp / usr / local / tomcat7 / conf / server {.xml,. BAK}
[the root-Tomcat @ ~. 1] Vim /usr/local/tomcat7/conf/server.xml #

124 <= the Host name "localhost" the appBase = "the webapps"
125 = unpackWARs "to true" = the autoDeploy "to true">
126 <= the docBase the Context "/ the webapp" path = "" Reloadable = "flase">
127 </ the Context>

the docBase = "/ the webapp" reference document #web application directory
path = "" # set default "class "
Reloadable =" flase "monitoring set #" class "is a change

closed tomcat, restart
[root @ tomcat-1 ~] # / usr / local / tomcat7 / bin / shutdown.sh
Using CATALINA_BASE:   /usr/local/tomcat7
Using CATALINA_HOME:   /usr/local/tomcat7
CATALINA_TMPDIR the Using: / usr / local / tomcat7 / the TEMP
the Using JRE_HOME: / usr / local / the Java
the Using the CLASSPATH: /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar

[the root-Tomcat @ ~. 1] # /usr/local/tomcat7/bin/startup.sh
the Using CATALINA_BASE: / usr / local / tomcat7
the Using CATALINA_HOME: / usr / local / tomcat7
the Using CATALINA_TMPDIR: / usr / local / tomcat7 / TEMP
JRE_HOME the Using: / usr / local / the Java
the Using the CLASSPATH: /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
. Tomcat Started

browser to access the test http: // 192.168.200.103:8080

============================================= ================================================== ==================

substantially the same configuration Tomcat 1 Tomcat 2
Mounting the JDK, Java environment configuration, version maintains consistent Tomcat 1
installed Tomcat, Tomcat 1 is consistent with the version

[2-Tomcat the root @ ~] # Vim /webapp/index.jsp
Server Info:   
the SessionID: <% = session.getId ( )%>
<br>
SessionIP: <% = to request.getServerName ()%>  
<br>
SessionPort: <% = to request.getServerPort ()%>
<br>
<%
  Out.println ( "TWO Server");
%>

[2-Tomcat the root @ ~]} /usr/local/tomcat7/conf/server.xml{,.bak CP #
[2-Tomcat the root @ ~] Vim /usr/local/tomcat7/conf/server.xml #

124 <the Host name = "localhost" the appBase = "the webapps"
125 = unpackWARs "to true" the autoDeploy = "to true">
126 <= the docBase the Context "/ the webapp" path = "" reloadable="flase" >
127             </Context>

[root @ Tomcat-2 ~] # /usr/local/tomcat7/bin/shutdown.sh
[root @ Tomcat-2 ~] # /usr/local/tomcat7/bin/startup.sh

browser to access the test http: // 192.168.200.104:8080

============================================= ================================================== ==================

Tomcat configuration instructions
/ usr / local / tomcat7 # home directory
bin # activate or deactivate the store windows or linux platform Tomcat script file
conf # store various global Tomcat configuration file, server.xml and foremost of which is the web.xml
lib # storage library files needed to run Tomcat (JARS)
logs # LOG files stored execution of Tomcat
webapps directory publishing major Web #Tomcat ( comprising the application instances)
class files generated by the compiler jsp stored work #

[root @ tomcat-1 ~] # ls / usr / local / tomcat7 / conf /
catalina.policy # access control profile
catalina.properties #Tomcat profile attributes
context.xml # context configuration files (SELinux)
the logging.properties # log log file configuration
server.xml # master configuration file
tomcat-users.xml # manager- gui manage user profile (generated after Tomcat installation management interface, the file can be opened to access)
the web.xml #Tomcat a servlet, servlet-mapping, filter, MIME , etc. Related

server.xml main configuration file can be modified to enable the interface set root of the site, web hosting, open https and other functions.

structure constituting server.xml
<Server>
    <-Service>
        <Connector />
            <Engine>
                <the Host>
                    <the Context> </ the Context>
                </ the Host>
            </ Engine>
    </-Service>
<

<! - -> content is within the gaze Information



Server
Server element represents the entire Catalina Servlet Container

Service
Service is a collection; it is composed of one or more Connector, and an Engine, responsible for all Connector obtained customer requests.

Connector
a Connector listens for client requests on a designated port and a request to obtain the Engine to handle, get a response from the Department Engine and returned to the client.

There are two typical TomcatEngine Connector, listen for http requests directly from a browser, and listens for a request from the other webserver
Coyote Http / 1.1 Connector 8009 at the listening port from other wenserver (Apache) a servlet / jsp proxy request.

Engine
under Engine can configure multiple virtual hosts the Virtual Host, each virtual server has a domain name
when a request to obtain Engine, which matches the request to one of the Host, and Host to which the request is to be processed,
Engine there is a default virtual host, when the request can not be matched to any time on a host, will be handed over to handle the default host

host
on behalf of a virtual host, virtual hosts, each virtual host and a network domain name domain Name to match
each The next virtual host can deploy (deploy) one or more Web app, each corresponding to a web app Context, there is a Context path.

When a Host obtaining request, the request will be matched to a Context, then the request to the Context processed, the longest matching method match, so a path == "" Context will be of the Host default Context match.

Context
a Context corresponding to a Web application, a Web application Servlet by one or more components.

================================================== ================================================== =============


Nginx-server configuration. 1:

[the root-Nginx @ ~. 1] # yum the install PCRE -Y-devel zlib-devel OpenSSL-devel
[the root-Nginx @ ~. 1] # -M -s the useradd / sbin / nologin Nginx
[the root-Nginx @ ~. 1] # XF Nginx the tar-1.6.2.tar.gz
[the root-Nginx @ ~. 1] # CD-1.6.2 Nginx
[root @ nginx-1 nginx- 1.6.2] # ./configure --prefix = / usr / local / nginx --user = nginx --group = nginx --with-file-aio --with-http_stub_status_module - --with-http_flv_module-http_ssl_module with --with-http_gzip_static_module && && the make the make the install

--prefix = / usr / local / Nginx # specify the installation directory
--user = nginx --group = nginx specified user and group run #
- -with-file-aio # enable file modification support
--with-http_stub_status_module # enabled statistics
--with-http_ssl_module # ssl-enabled module
--with-http_flv_module # flv enabled module, seek to provide memory-based file offset time
--with-http_gzip_static_module # enable gzip compression static


configuration nginx.conf
[@ Nginx the root-Nginx-1.6.2. 1]} # CP /usr/local/nginx/conf/nginx.conf{,.bak
[root@nginx-1 nginx-1.6.2]# vim /usr/local/nginx/conf/nginx.conf
=================================================================================================================
user  nginx;
worker_processes  1;
error_log  logs/error.log;
pid        logs/nginx.pid;

events {
    use epoll;
    worker_connections  10240;
}

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;
    keepalive_timeout  65;
    upstream tomcat_server {
    server 192.168.200.103:8080 weight=1;
    server 192.168.200.104:8080 weight=1;
    }

    server {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
            proxy_pass http://tomcat_server;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
=================================================================================================================
[root@nginx-1 nginx-1.6.2]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

[root@nginx-1 nginx-1.6.2]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
[root@nginx-1 nginx-1.6.2]# netstat -anpt |grep :80
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      7184/nginx          

[root@nginx-1 nginx-1.6.2]# ps aux |grep nginx
7184 0.0 1052 0.2 45000 the root Ss 01:18 0:00 Nginx:? Master Process / usr / local / Nginx / sbin / Nginx /usr/local/nginx/conf/nginx.conf -C
? WWW 0.0 1.1 7185 5452 S 49256 0:00 nginx 01:18: worker Process                                          
root 7193 0.0 0.1 103 256 848 PTS / + 1 S 01:18 0:00 grep nginx


client test:
open a browser to access: http://192.168.200.101 # continually refresh can be seen due to the weight the same, the page will switch


nginx-2 server configuration:
configuration consistent with the server nginx-1

client test:
open a browser to access: http://192.168.200.102 # constantly refresh the same can be seen due to the heavy weight, the page will repeatedly switch
================================================ ================================================== ===============


How it works: Two Nginx generated by Keepalived two examples, two sets of VIP Nginx back up each other, if any one Nginx machine hardware damage occurred, Keepalived will automatically switch its VIP address to another machine, does not affect customers end of the visit.


On nginx1 / 2 compiler installation keepalived Service:
[nginx1 the root @ ~] # yum the install -Y-OpenSSL Kernel-devel devel

[nginx1 the root @ ~] # keepalived the tar-XF 1.2.13.tar.gz
[ ~ @. 1-Nginx the root] # CD-keepalived 1.2.13
[@ Nginx the root-1.2.13-keepalived. 1] # ./configure --prefix = /-Kernel---with the dir = / usr / the src / kernels' / 2.6.32-504.el6.x86_64 / && && the make the make the install
[the root-Nginx @ ~. 1] # the chkconfig --add keepalived
[the root-Nginx @ ~. 1] # keepalived the chkconfig ON
[the root-Nginx @ ~. 1] # --list keepalived the chkconfig  

. 3, modify the configuration file keepalived
[the root-Nginx @ ~. 1] # Vim /etc/keepalived/keepalived.conf
! keepalived the configuration file for

global_defs {
   notification_email {
        [email protected]
}
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}


vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 50
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 123
    }
    virtual_ipaddress {
        192.168.200.254
    }
}

vrrp_instance VI_2 {
    state MASTER
    interface eth0
    virtual_router_id 52
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 123
    }
    virtual_ipaddress {
        192.168.200.253
    }
}
=================================================================================================================
[root@nginx-2 ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived

global_defs {
   notification_email {
        [email protected]
}
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}


vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 123
    }
    virtual_ipaddress {
        192.168.200.254
    }
}

vrrp_instance VI_2 {
    state BACKUP
    interface eth0
    virtual_router_id 52
    priority 50
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 123
    }
    virtual_ipaddress {
        192.168.200.253
    }
}

[root@nginx-1 ~]# service keepalived start
[root@nginx-1 ~]# ip addr show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:2d:3d:97 brd ff:ff:ff:ff:ff:ff
    inet 192.168.200.202/24 brd 192.168.200.255 scope global eth0
    inet 192.168.200.254/32 scope global eth0
    inet6 fe80::20c:29ff:fe2d:3d97/64 scope link
       valid_lft forever preferred_lft forever


[root@nginx-2 ~]# service keepalived start
[root@nginx-2 ~]# ip addr show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:6f:7d:87 brd ff:ff:ff:ff:ff:ff
    inet 192.168.200.102/24 brd 192.168.200.255 scope global eth0
    inet 192.168.200.253/32 scope global eth0
    inet6 fe80::20c:29ff:fe6f:7d87/64 scope link
       valid_lft forever preferred_lft forever
       
Client test:
Open a browser to access: http://192.168.200.253 # constantly refresh the same can be seen due to the heavy weight, the page will switch
client test:
Open a browser to access: http://192.168.200.254 # can be constantly refreshed see due to the weight of the same page will be repeatedly switched   

   
nginx-1/2 two machines perform monitoring Nginx process of script
[root @ nginx-1 ~] # CAT nginx_pidcheck
! # / bin / bash
the while:
do
        nginxpid = `PS - Nginx header --no-C | WC -l`
        IF [$ nginxpid -eq 0]
        the then
                / usr / local / Nginx / sbin / Nginx
                keeppid = $ (PS -C keepalived --no-header | WC -l)
                IF [$ keeppid -eq 0]
                the then
                        /etc/init.d/keepalived Start
                Fi
                SLEEP. 5
                PS = `-C Nginx nginxpid --no-header | WC -l`
                IF [$ nginxpid -eq 0]
                the then
                        /etc/init.d/keepalived STOP
                Fi
        Fi
        SLEEP. 5
DONE

[the root-Nginx @ ~. 1] # SH & nginx_pidcheck
[the root-Nginx @ ~. 1] # Vim /etc/rc.local
SH & nginx_pidcheck

this script executes an endless loop, the machine has two Nginx execute this script, performed once every 5 seconds, by ps - C is the command to collect PID value nginx is in the end is 0 if it is 0, then, that Nginx has process dies, try to start nginx process; if it continues to 0, that Nginx fails to start, turn off the machine Keeplaived service, VIP address will be taken over by the backup machine, of course, the entire site will all be served by Nginx backup machine, thus ensuring high availability Nginx services.


Test script:
[root @ nginx-1 ~] # netstat -anpt | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4321 / nginx          
[root@nginx-1 ~]# killall -s QUIT nginx
[root@nginx-1 ~]# netstat -anpt |grep nginx
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      59418/nginx

VIP转移测试:
[root@nginx-1 ~]# ip addr show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:2d:3d:97 brd ff:ff:ff:ff:ff:ff
    inet 192.168.200.101/24 brd 192.168.200.255 scope global eth0
    inet 192.168.200.254/32 scope global eth0
    inet6 fe80::20c:29ff:fe2d:3d97/64 scope link
       valid_lft forever preferred_lft forever
       
[root@nginx-2 ~]# service keepalived stop
停止 keepalived:                                          [确定]


[the root @ Nginx-. 1 ~] # IP addr Show dev eth0
2: eth0: <BROADCAST, the MULTICAST, the UP, LOWER_UP> MTU 1500 qdisc allows users to pfifo_fast State the UP of qlen 1000
    Link / ether 00: 0c: 29: 2D: 3D: 97 brd FF: FF: FF: FF: FF: FF
    inet 192.168.200.101/24 brd 192.168.200.255 scope, Ltd. Free Join eth0
    inet 192.168.200.254/32 scope, Ltd. Free Join eth0
    inet 192.168.200.253/32 scope, Ltd. Free Join eth0
    inet6 fe80 :: 20c: 29ff: fe2d: 3d97 / 64-scope Link
       valid_lft Forever Forever preferred_lft

client test:
open a browser to access: http://192.168.200.253 # constantly refresh the same can be seen due to the heavy weight, the page will switch
client test:
open a browser to access: http://192.168.200.254 # constantly refresh the same can be seen due to the heavy weight, the page will switch   

============================= ================================================== ==================================
[root@tomcat-1 ~]# yum -y install gcc openssl-devel pcre-devel zlib-devel
[root@tomcat-1 ~]# tar xf libevent-2.0.15-stable.tar.gz
[root@tomcat-1 ~]# cd libevent-2.0.15-stable
[root@tomcat-1 libevent-2.0.15-stable]# ./configure --prefix=/usr/local/libevent && make && make install

[root@tomcat-1 ~]# tar xf memcached-1.4.5.tar.gz
[root@tomcat-1 ~]# cd memcached-1.4.5
[root@tomcat-1 memcached-1.4.5]# ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent/ && make && make install  

[root@tomcat-1 memcached-1.4.5]# ldconfig -v |grep libevent
    libevent_pthreads-2.0.so.5 -> libevent_pthreads.so
    libevent-2.0.so.5 -> libevent.so
    libevent_extra-2.0.so.5 -> libevent_extra.so
    libevent_core-2.0.so.5 -> libevent_core.so
    libevent_openssl-2.0.so.5 -> libevent_openssl.so
    libevent_extra-1.4.so.2 -> libevent_extra-1.4.so.2.1.3
    libevent_core-1.4.so.2 -> libevent_core-1.4.so.2.1.3
    libevent-1.4.so.2 -> libevent-1.4.so.2.1.3

[root@tomcat-1 memcached-1.4.5]# /usr/local/memcached/bin/memcached -u root -m 512M -n 10 -f 2 -d -vvv -c 512
/usr/local/memcached/bin/memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory

[root@localhost memcached-1.4.5]# vim /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/libevent/lib/
[root@localhost memcached-1.4.5]# ldconfig
[root @ localhost memcached-1.4.5] # / usr / local / memcached / bin / memcached -u root -m 512M -n 10 -f 2 -d -vvv -c 512

Options:
    -h # view help information
    -p # memcached is listening port number specified default 11211
    the -l #memcached server's ip address
    -u user identity using runtime #memcached program must be root
    -m # specify how much physical memory the data stored in the machine's default 64M
    -c # memcached service the maximum number of links
    -vvv # display detailed information about
    the minimum space -n #chunk size in bytes is the number of
    multiple -f #chunk size of the default size increase 1.25 times
    -d # started in the background
    
[root @ tomcat-1 ~ ] # netstat -antp | grep: 11211 # ( detection memecached is alive, memcacehd port 11211)
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 71559 / memcached     
tcp 0 0 ::: 11211 ::: * LISTEN 71559 / memcached

test memcached can access the data
[the root-Tomcat @ ~. 1] -Y # yum the install Telnet
[the root @ localhost ~] # Telnet 192.168.200.103 11211
SET username . 8 0 0     
zhangsan
STORED
GET username
of VALUE 0. 8 username
zhangsan
the END
quit
connection Closed by Foreign Host.



Finally performed so Tomcat-1 Tomcat-2 by (MSM) Memcached connected to

the "* .jar copied to / usr session package / local / tomcat7 / lib / below
[root @ tomcat-1 ~] # cp session / * / usr / local / tomcat7 / lib /

edit tomcat profile connection specified memcached server
tomcat-1 and tomcat-2 profile identical, are According to the sample to write about

[root @ tomcat-1 ~] # vim /usr/local/tomcat7/conf/context.xml
<Context>
<Manager    className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="memA:192.168.200.104:11211 memB:192.168.200.105:11211"
requestUrilgnorePattern=".*\(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
/>
</Context>

[root@tomcat-2 ~]# vim /usr/local/tomcat7/conf/context.xml
<Context>
<Manager    className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="memA:192.168.200.104:11211 memB:192.168.200.105:11211"
requestUrilgnorePattern=".*\(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
/>
</ The Context>
[the root-Tomcat @ ~. 1] # /usr/local/tomcat7/bin/shutdown.sh
[the root-Tomcat @ ~. 1] # /usr/local/tomcat7/bin/startup.sh
If successful, tomcat the port will be connected together Memcached, before and after the change
Tomcat-1 and Tomcat-2 below
[the root-Tomcat @ ~. 1] # -antp the netstat | grep Java
TCP 0 0 FFFF ::: 127.0.0.1: ::: 8005 LISTEN 62496 * / the Java          
tcp 0 0 ::: 8009 ::: * LISTEN 62496 / the Java          
tcp 0 0 ::: 8080 ::: * LISTEN 62496 / the Java          
tcp 0 0 :: ffff: 192.168.200.10: 28232 :: ffff : 192.168.200.10: 11211 ESTABLISHED 62496 / java          
tcp        0      0 ::ffff:192.168.200.10:28231 ::ffff:192.168.200.10:11211 ESTABLISHED 62496/java          
tcp        0      0 ::ffff:192.168.200.10:28230 ::ffff:192.168.200.10:11211 ESTABLISHED 62496/java          
tcp        0      0 ::ffff:192.168.200.10:28228 ::ffff:192.168.200.10:11211 ESTABLISHED 62496/java          
tcp        0      0 ::ffff:192.168.200.10:28229 ::ffff:192.168.200.10:11211 ESTABLISHED 62496/java          
[root@tomcat-1 ~]# netstat -antp|grep memcached
tcp        0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN      62402/memcached     
tcp        0      0 192.168.200.103:11211       192.168.200.103:28230       ESTABLISHED 62402/memcached     
tcp       45      0 192.168.200.103:11211       192.168.200.103:28228       ESTABLISHED 62402/memcached     
tcp        0      0 192.168.200.103:11211       192.168.200.103:28232       ESTABLISHED 62402/memcached     
tcp        0      0 192.168.200.103:11211       192.168.200.103:28229       ESTABLISHED 62402/memcached     
tcp        0      0 192.168.200.103:11211       192.168.200.103:28231       ESTABLISHED 62402/memcached     
tcp        0      0 :::11211                    :::*                        LISTEN      62402/memcached    




















Guess you like

Origin www.cnblogs.com/zc1741845455/p/10944011.html