码迷,mamicode.com
首页 > 其他好文 > 详细

tomcat(2)--集群

时间:2015-12-21 12:49:23      阅读:544      评论:0      收藏:0      [点我收藏+]

标签:tomcat

mode_jk做tomcat负载均衡

技术分享

[root@node200 conf.d]# yum install httpd-devel -y

[root@node200 ~]# ifconfig

eth0      Link encap:Ethernet  HWaddr 00:0C:29:9F:1F:E5  

          inet addr:192.168.112.200  Bcast:192.168.112.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fe9f:1fe5/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:238528 errors:0 dropped:0 overruns:0 frame:0

          TX packets:88185 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:246189087 (234.7 MiB)  TX bytes:17095170 (16.3 MiB)


eth1      Link encap:Ethernet  HWaddr 00:0C:29:9F:1F:EF  

          inet addr:172.168.254.200  Bcast:172.168.254.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fe9f:1fef/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:176 errors:0 dropped:0 overruns:0 frame:0

          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:17742 (17.3 KiB)  TX bytes:2760 (2.6 KiB)


lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:65536  Metric:1

          RX packets:146763 errors:0 dropped:0 overruns:0 frame:0

          TX packets:146763 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:65389907 (62.3 MiB)  TX bytes:65389907 (62.3 MiB)


部署192.168.112.130的tomcat

[root@node2 ~]# ls

anaconda-ks.cfg  install.log.syslog  公共的  视频  文档  音乐

install.log      ntpupdate.sh        模板    图片  下载  桌面

You have new mail in /var/spool/mail/root

[root@node2 ~]# ls

anaconda-ks.cfg              install.log         jdk-7u67-linux-x64.rpm  公共的  视频  文档  音乐

apache-tomcat-8.0.30.tar.gz  install.log.syslog  ntpupdate.sh            模板    图片  下载  桌面

You have new mail in /var/spool/mail/root

[root@node2 ~]# rpm -ivh jdk-7u67-linux-x64.rpm 

Preparing...                ########################################### [100%]

   1:jdk                    ########################################### [100%]

Unpacking JAR files...

rt.jar...

jsse.jar...

charsets.jar...

tools.jar...

localedata.jar...

jfxrt.jar...

[root@node2 ~]# vim /etc/profile.d/java.sh

  1 export JAVA_HOME=/usr/java/latest

  2 export PATH=$JAVA_HOME/bin:$PATH

[root@node2 ~]# java -version

java version "1.7.0_67"

Java(TM) SE Runtime Environment (build 1.7.0_67-b01)

Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

[root@node2 ~]# ls

anaconda-ks.cfg              install.log         jdk-7u67-linux-x64.rpm  公共的  视频  文档  音乐

apache-tomcat-8.0.30.tar.gz  install.log.syslog  ntpupdate.sh            模板    图片  下载  桌面

[root@node2 ~]# tar xf apache-tomcat-8.0.30.tar.gz -C /usr/local/

You have new mail in /var/spool/mail/root

[root@node2 ~]# cd /usr/local/

[root@node2 local]# ls

apache-tomcat-8.0.30  bin  etc  games  include  lib  lib64  libexec  sbin  share  src

[root@node2 local]# ln -sv apache-tomcat-8.0.30/ tomcat-----------------------注明:在生产环境中都要需要改变文件属组或者属主,这样就不要需要使用root用户

"tomcat" -> "apache-tomcat-8.0.30/"

[root@node2 local]# ll

总用量 44

drwxr-xr-x. 9 root root 4096 12月 16 19:18 apache-tomcat-8.0.30

drwxr-xr-x. 2 root root 4096 9月  23 2011 bin

drwxr-xr-x. 2 root root 4096 9月  23 2011 etc

drwxr-xr-x. 2 root root 4096 9月  23 2011 games

drwxr-xr-x. 2 root root 4096 9月  23 2011 include

drwxr-xr-x. 2 root root 4096 9月  23 2011 lib

drwxr-xr-x. 2 root root 4096 9月  23 2011 lib64

drwxr-xr-x. 2 root root 4096 9月  23 2011 libexec

drwxr-xr-x. 2 root root 4096 9月  23 2011 sbin

drwxr-xr-x. 5 root root 4096 8月  25 22:04 share

drwxr-xr-x. 2 root root 4096 9月  23 2011 src

lrwxrwxrwx. 1 root root   21 12月 16 19:18 tomcat -> apache-tomcat-8.0.30/

You have new mail in /var/spool/mail/root

[root@node2 local]# cd tomcat/webapps/

[root@node2 webapps]# mkdir -pv testapp/{WEB-INF,classes,lib,META-INF}

mkdir: 已创建目录 "testapp"

mkdir: 已创建目录 "testapp/WEB-INF"

mkdir: 已创建目录 "testapp/classes"

mkdir: 已创建目录 "testapp/lib"

mkdir: 已创建目录 "testapp/META-INF"

You have new mail in /var/spool/mail/root

[root@node2 webapps]# vim testapp/index.jsp

  1 <%@ page language="java" %>

  2 <html>

  3   <head><title>TomcatA</title></head>

  4   <body>

  5     <h1><font color="red">TomcatA.zye.com</font></h1>

  6     <table align="centre" border="1">

  7       <tr>

  8         <td>Session ID</td>

  9     <% session.setAttribute("zye.com","zye.com"); %>

 10         <td><%= session.getId() %></td>

 11       </tr>

 12       <tr>

 13         <td>Created on</td>

 14         <td><%= session.getCreationTime() %></td>

 15      </tr>

 16     </table>

 17   </body>

 18 </html>


[root@node2 webapps]# vim /etc/profile.d/tomcat.sh

 1 export CATALINA_HOME=/usr/local/tomcat

  2 export PATH=$CATALINA_HOME/bin:$PATH


[root@node2 webapps]# catalina.sh version

Using CATALINA_BASE:   /usr/local/tomcat

Using CATALINA_HOME:   /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME:        /usr/java/latest

Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

Server version: Apache Tomcat/8.0.30

Server built:   Dec 1 2015 22:30:46 UTC

Server number:  8.0.30.0

OS Name:        Linux

OS Version:     2.6.32-573.el6.x86_64

Architecture:   amd64

JVM Version:    1.7.0_67-b01

JVM Vendor:     Oracle Corporation


[root@node2 webapps]# catalina.sh start

Using CATALINA_BASE:   /usr/local/tomcat

Using CATALINA_HOME:   /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME:        /usr/java/latest

Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

Tomcat started.

You have new mail in /var/spool/mail/root

[root@node2 webapps]# ss -tnl

State       Recv-Q Send-Q                   Local Address:Port                     Peer Address:Port 

LISTEN      0      1                     ::ffff:127.0.0.1:8005                               :::*     

LISTEN      0      100                                 :::8009                               :::*     

LISTEN      0      100                                 :::8080                               :::*     

LISTEN      0      128                                 :::80                                 :::*     

LISTEN      0      128                                 :::22                                 :::*     

LISTEN      0      128                                  *:22                                  *:*     

LISTEN      0      128                          127.0.0.1:631                                 *:*     

LISTEN      0      128                                ::1:631                                :::*     

LISTEN      0      100                                ::1:25                                 :::*     

LISTEN      0      100                          127.0.0.1:25                                  *:*     

LISTEN      0      128                          127.0.0.1:6010                                *:*     

LISTEN      0      128                                ::1:6010                               :::*   


技术分享

技术分享


[root@node200 ~]# vim /etc/httpd/conf/httpd.conf 

 292 #DocumentRoot "/var/www/html"

990 NameVirtualHost *:80


[root@node200 ~]# vim /etc/httpd/conf.d/ajp-tomcat.conf

  1 <Virtualhost *:80>

  2         ServerName www.zye.com

  3         ProxyVia On

  4         ProxyRequests Off

  5         ProxyPreserveHost On

  6         <proxy *>

  7                 Order deny,allow

  8                 Allow from all

  9         </Proxy>

 10         ProxyPass /status !

 11         ProxyPass / ajp://192.168.112.130:8009/

 12         ProxyPassReverse / ajp://192.168.112.130:8009/

 13         <Location />

 14                 Order deny,allow

 15                 Allow from all

 16         </Location>

 17 </VirtualHost>


[root@node200 ~]# httpd -t

Syntax OK


[root@node200 ~]# service httpd restart

停止 httpd:                                               [确定]

正在启动 httpd:                                           [确定]


技术分享


技术分享

mode_jk安装(第三方)

[root@node200 ~]# ls

anaconda-ks.cfg                   install.log.syslog                   公共的

apache-tomcat-8.0.30.tar.gz       JavaCenter_Home_2.0_GBK              模板

apr-1.4.6                         JavaCenter_Home_2.0_GBK.tar.bz2      视频

apr-1.4.6.tar.bz2                 jdk-7u67-linux-x64.rpm               说明.htm

apr-util-1.4.1.tar.bz2            mariadb-10.0.10-linux-x86_64.tar.gz  图片

connect-web.war                   nginx-1.8.0-1.el6.ngx.x86_64.rpm     文档

epel-release-latest-6.noarch.rpm  shopxx-a5-Beta.zip                   下载

httpd-2.4.6.tar.bz2               shopxx-v3.0-Beta                     音乐

install.log                       tomcat-connectors-1.2.40-src.tar.gz  桌面

[root@node200 ~]# tar xf tomcat-connectors-1.2.40-src.tar.gz 

[root@node200 ~]# cd tomcat-connectors-1.2.40-src

[root@node200 tomcat-connectors-1.2.40-src]# ls

conf  docs  HOWTO-RELEASE.txt  jkstatus  LICENSE  native  NOTICE  README.txt  support  tools  xdocs

[root@node200 tomcat-connectors-1.2.40-src]# cd native/

[root@node200 native]# ls

aclocal.m4  buildconf.sh  configure     iis          netscape    STATUS.txt

apache-1.3  BUILDING.txt  configure.ac  Makefile.am  README.txt  TODO.txt

apache-2.0  common        docs          Makefile.in  scripts

[root@node200 native]# less README.txt 

[root@node200 native]# less BUILDING.txt 

[root@node200 native]# whereis apxs

apxs: /usr/sbin/apxs /usr/share/man/man8/apxs.8.gz

[root@node200 native]# ./configure --with-apxs=/usr/sbin/apxs

[root@node200 native]# make && make install

[root@node200 native]# cd /usr/lib64/httpd/modules/

[root@node200 modules]# ls

mod_actions.so          mod_authz_user.so  mod_filter.so          mod_proxy_http.so

mod_alias.so            mod_autoindex.so   mod_headers.so         mod_proxy_scgi.so

mod_asis.so             mod_cache.so       mod_ident.so           mod_proxy.so

mod_auth_basic.so       mod_cern_meta.so   mod_include.so         mod_reqtimeout.so

mod_auth_digest.so      mod_cgid.so        mod_info.so            mod_rewrite.so

mod_authn_alias.so      mod_cgi.so         mod_jk.so              mod_setenvif.so

mod_authn_anon.so       mod_dav_fs.so      mod_ldap.so            mod_speling.so

mod_authn_dbd.so        mod_dav.so         mod_log_config.so      mod_status.so

mod_authn_dbm.so        mod_dbd.so         mod_log_forensic.so    mod_substitute.so

mod_authn_default.so    mod_deflate.so     mod_logio.so           mod_suexec.so

mod_authn_file.so       mod_dir.so         mod_mime_magic.so      mod_unique_id.so

mod_authnz_ldap.so      mod_disk_cache.so  mod_mime.so            mod_userdir.so

mod_authz_dbm.so        mod_dnssd.so       mod_negotiation.so     mod_usertrack.so

mod_authz_default.so    mod_dumpio.so      mod_proxy_ajp.so       mod_version.so

mod_authz_groupfile.so  mod_env.so         mod_proxy_balancer.so  mod_vhost_alias.so

mod_authz_host.so       mod_expires.so     mod_proxy_connect.so

mod_authz_owner.so      mod_ext_filter.so  mod_proxy_ftp.so

[root@node200 modules]# mv /etc/httpd/conf.d/

ajp-tomcat.conf       mod_dnssd.conf        welcome.conf          

http-tomcat.conf.bak  README                

[root@node200 modules]# mv /etc/httpd/conf.d/ajp-tomcat.conf{,.bak}

[root@node200 modules]# cd /etc/httpd/conf.d/

[root@node200 conf.d]# ls

ajp-tomcat.conf.bak  http-tomcat.conf.bak  mod_dnssd.conf  README  welcome.conf

[root@node200 conf.d]# vim mod_jk.conf

1 LoadModule jk_module modules/mod_jk.so

[root@node200 ~]# httpd -M | grep jk

[Wed Dec 16 21:28:43 2015] [warn] NameVirtualHost *:80 has no VirtualHosts

Syntax OK

 jk_module (shared)


[root@node200 ~]# vim /etc/httpd/conf.d/mod_jk.conf 

  1 LoadModule jk_module modules/mod_jk.so

  2 JkWorkersFile /etc/httpd/conf.d/workers.properties

  3 JkLogFile logs/mod_jk.log

  4 JkLogLevel info

  5 JkMount /status !

  6 JkMount /* TomcatA

  7 JkMount /status StatA


[root@node200 ~]# vim /etc/httpd/conf.d/workers.properties

  1 worker.list=TomcatA,StatA

  2 worker.TomcatA.host=192.168.112.130

  3 worker.TomcatA.port=8009

  4 worker.TomcatA.type=ajp13

  5 worker.StatA.type=status


[root@node200 ~]# httpd -t

[Wed Dec 16 22:29:54 2015] [warn] NameVirtualHost *:80 has no VirtualHosts

Syntax OK


[root@node200 ~]# service httpd restart

停止 httpd:                                               [确定]

正在启动 httpd:[Wed Dec 16 22:34:41 2015] [warn] NameVirtualHost *:80 has no VirtualHosts

                                                           [确定]


技术分享 

技术分享


[root@node200 ~]# tail /var/log/httpd/mod_jk.log 

[Wed Dec 16 22:41:01.088 2015] [24637:139695854090208] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized

[Wed Dec 16 22:41:01.121 2015] [24638:139695854090208] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized

[root@node200 ~]# 



Tomcat负载均衡

主机112.130;112.140;0.20(112.200)


112.130

[root@node2 ~]# scp /etc/profile.d/{java.sh,tomcat.sh} 192.168.112.140:/etc/profile.d/

The authenticity of host ‘192.168.112.140 (192.168.112.140)‘ can‘t be established.

RSA key fingerprint is 0e:95:8d:de:b9:2f:c4:75:8d:70:af:e2:84:65:7f:86.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘192.168.112.140‘ (RSA) to the list of known hosts.

root@192.168.112.140‘s password: 

java.sh                                                                                100%   67     0.1KB/s   00:00    

tomcat.sh                                                                              100%   76     0.1KB/s   00:00    

You have new mail in /var/spool/mail/root

[root@node2 ~]# scp apache-tomcat-8.0.30.tar.gz jdk-7u67-linux-x64.rpm 192.168.112.140:/root

root@192.168.112.140‘s password: 

apache-tomcat-8.0.30.tar.gz                                                            100% 8936KB   8.7MB/s   00:00    

jdk-7u67-linux-x64.rpm                                                                 100%  121MB  20.2MB/s   00:06    

You have new mail in /var/spool/mail/root


112.140

[root@node2 ~]# scp /etc/profile.d/{java.sh,tomcat.sh} 192.168.112.140:/etc/profile.d/

The authenticity of host ‘192.168.112.140 (192.168.112.140)‘ can‘t be established.

RSA key fingerprint is 0e:95:8d:de:b9:2f:c4:75:8d:70:af:e2:84:65:7f:86.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘192.168.112.140‘ (RSA) to the list of known hosts.

root@192.168.112.140‘s password: 

java.sh                                                                                100%   67     0.1KB/s   00:00    

tomcat.sh                                                                              100%   76     0.1KB/s   00:00    

You have new mail in /var/spool/mail/root

[root@node2 ~]# scp apache-tomcat-8.0.30.tar.gz jdk-7u67-linux-x64.rpm 192.168.112.140:/root

root@192.168.112.140‘s password: 

apache-tomcat-8.0.30.tar.gz                                                            100% 8936KB   8.7MB/s   00:00    

jdk-7u67-linux-x64.rpm                                                                 100%  121MB  20.2MB/s   00:06    

You have new mail in /var/spool/mail/root


[root@node3 ~]# cd /usr/local/

[root@node3 local]# ls

apache-tomcat-8.0.30  bin  etc  games  include  lib  lib64  libexec  sbin  share  src

[root@node3 local]# ln -sv apache-tomcat-8.0.30/ tomcat

"tomcat" -> "apache-tomcat-8.0.30/"

[root@node3 local]# ls

apache-tomcat-8.0.30  bin  etc  games  include  lib  lib64  libexec  sbin  share  src  tomcat

[root@node3 local]# cd tomcat/

[root@node3 tomcat]# ls

bin  conf  lib  LICENSE  logs  NOTICE  RELEASE-NOTES  RUNNING.txt  temp  webapps  work


[root@node3 webapps]# ls

docs  examples  host-manager  manager  ROOT

[root@node3 webapps]# mkdir -pv testapp/{classes,lib,WEB-INF,META-INF}

mkdir: 已创建目录 "testapp"

mkdir: 已创建目录 "testapp/classes"

mkdir: 已创建目录 "testapp/lib"

mkdir: 已创建目录 "testapp/WEB-INF"

mkdir: 已创建目录 "testapp/META-INF"

[root@node3 webapps]# ls

docs  examples  host-manager  manager  ROOT  testapp

You have new mail in /var/spool/mail/root

[root@node3 webapps]# ll

总用量 24

drwxr-xr-x. 14 root root 4096 12月 17 21:16 docs

drwxr-xr-x.  6 root root 4096 12月 17 21:16 examples

drwxr-xr-x.  5 root root 4096 12月 17 21:16 host-manager

drwxr-xr-x.  5 root root 4096 12月 17 21:16 manager

drwxr-xr-x.  3 root root 4096 12月 17 21:16 ROOT

drwxr-xr-x.  6 root root 4096 12月 17 21:19 testapp

[root@node3 webapps]# ll testapp/

总用量 16

drwxr-xr-x. 2 root root 4096 12月 17 21:19 classes

drwxr-xr-x. 2 root root 4096 12月 17 21:19 lib

drwxr-xr-x. 2 root root 4096 12月 17 21:19 META-INF

drwxr-xr-x. 2 root root 4096 12月 17 21:19 WEB-INF

[root@node3 webapps]# vim testapp/index.jsp

<%@ page language="java" %>

<html>

  <head><title>TomcatB</title></head>

  <body>

    <h1><font color="blue">TomcatB.zye.com</font></h1>

    <table align="centre" border="1">

      <tr>

        <td>Session ID</td>

    <% session.setAttribute("zye.com","zye.com"); %>

        <td><%= session.getId() %></td>

      </tr>

      <tr>

        <td>Created on</td>

        <td><%= session.getCreationTime() %></td>

     </tr>

    </table>

  </body>

</html>

   

[root@node3 webapps]# . /etc/profile.d/tomcat.sh 

[root@node3 webapps]# vim /usr/local/tomcat/conf/server.xml

103     <Engine name="Catalina" defaultHost="localhost" jvmRoute="TomcatB">

[root@node3 webapps]# catalina.sh version

Using CATALINA_BASE:   /usr/local/tomcat

Using CATALINA_HOME:   /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME:        /usr/java/latest

Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

Server version: Apache Tomcat/8.0.30

Server built:   Dec 1 2015 22:30:46 UTC

Server number:  8.0.30.0

OS Name:        Linux

OS Version:     2.6.32-573.el6.x86_64

Architecture:   amd64

JVM Version:    1.7.0_67-b01

JVM Vendor:     Oracle Corporation

[root@node3 webapps]# catalina.sh start

Using CATALINA_BASE:   /usr/local/tomcat

Using CATALINA_HOME:   /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME:        /usr/java/latest

Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

Tomcat started.


[root@node3 webapps]# ss -tnl

State       Recv-Q Send-Q                            Local Address:Port                              Peer Address:Port 

LISTEN      0      1                              ::ffff:127.0.0.1:8005                                        :::*     

LISTEN      0      100                                          :::8009                                        :::*     

LISTEN      0      128                                          :::36751                                       :::*     

LISTEN      0      128                                          :::111                                         :::*     

LISTEN      0      128                                           *:111                                          *:*     

LISTEN      0      100                                          :::8080                                        :::*     

LISTEN      0      128                                           *:44177                                        *:*     

LISTEN      0      128                                          :::22                                          :::*     

LISTEN      0      128                                           *:22                                           *:*     

LISTEN      0      128                                   127.0.0.1:631                                          *:*     

LISTEN      0      128                                         ::1:631                                         :::*     

LISTEN      0      100                                         ::1:25                                          :::*     

LISTEN      0      100                                   127.0.0.1:25                                           *:*     

LISTEN      0      128                                   127.0.0.1:6010                                         *:*     

LISTEN      0      128                                         ::1:6010                                        :::* 


技术分享

技术分享



112.130

[root@node2 ~]# vim /usr/local/tomcat/conf/server.xml 

103     <Engine name="Catalina" defaultHost="localhost" jvmRoute="TomcatA">

[root@node2 ~]# catalina.sh stop

Using CATALINA_BASE:   /usr/local/tomcat

Using CATALINA_HOME:   /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME:        /usr/java/latest

Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

[root@node2 ~]# catalina.sh start

Using CATALINA_BASE:   /usr/local/tomcat

Using CATALINA_HOME:   /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME:        /usr/java/latest

Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

Tomcat started.


[root@node2 ~]# ss -tnl

State       Recv-Q Send-Q                            Local Address:Port                              Peer Address:Port 

LISTEN      0      100                                          :::8009                                        :::*     

LISTEN      0      100                                          :::8080                                        :::*     

LISTEN      0      128                                          :::22                                          :::*     

LISTEN      0      128                                           *:22                                           *:*     

LISTEN      0      128                                   127.0.0.1:631                                          *:*     

LISTEN      0      128                                         ::1:631                                         :::*     

LISTEN      0      100                                         ::1:25                                          :::*     

LISTEN      0      100                                   127.0.0.1:25                                           *:*     

LISTEN      0      128                                   127.0.0.1:6010                                         *:*     

LISTEN      0      128                                         ::1:6010                                        :::*     

You have new mail in /var/spool/mail/root


0.20(代理服务器)

[root@node200 ~]# cd /etc/httpd/conf.d/

[root@node200 conf.d]# vim mod_jk.conf

  1 LoadModule jk_module modules/mod_jk.so

  2 JkWorkersFile /etc/httpd/conf.d/workers.properties

  3 JkLogFile logs/mod_jk.log

  4 JkLogLevel info

  5 JkMount /status !

  6 JkMount /* TomcatB

  7 JkMount /status StatA

~                           


[root@node200 conf.d]# vim workers.properties

  1 worker.list=TomcatB,StatA

  2 worker.TomcatB.host=192.168.112.140

  3 worker.TomcatB.port=8009

  4 worker.TomcatB.type=ajp13

  5 worker.StatA.type=status

~                                  

[root@node200 conf.d]# service httpd reload

重新载入 httpd:


技术分享

技术分享


0.20(负载)

[root@node200 conf.d]# vim mod_jk.conf 

  1 LoadModule jk_module modules/mod_jk.so

  2 JkWorkersFile /etc/httpd/conf.d/workers.properties

  3 JkLogFile logs/mod_jk.log

  4 JkLogLevel debug

  5 JkMount /status !

  6 JkMount /* tcsrvs

  7 JkMount /status StatA


[root@node200 conf.d]# vim workers.properties

  1 worker.list=tcsrvs,StatA

  2 worker.TomcatB.host=192.168.112.140

  3 worker.TomcatB.port=8009

  4 worker.TomcatB.type=ajp13

  5 worker.TomcatB.lbfactor=1

  6 worker.TomcatA.host=192.168.112.130

  7 worker.TomcatA.port=8009

  8 worker.TomcatA.type=ajp13

  9 worker.TomcatA.lbfactor=1

 10 worker.StatA.type=status

 11 worker.tcsrvs.type=lb

 12 worker.tcsrvs.balance_workers=TomcatA,TomcatB---------跟之前调用要匹配


[root@node200 conf.d]# !ser

service httpd reload

重新载入 httpd:


以下基于session绑定

技术分享

[root@node200 conf.d]# vim workers.properties

  1 worker.list=tcsrvs,StatA

  2 worker.TomcatB.host=192.168.112.140

  3 worker.TomcatB.port=8009

  4 worker.TomcatB.type=ajp13

  5 worker.TomcatB.lbfactor=1

  6 worker.TomcatA.host=192.168.112.130

  7 worker.TomcatA.port=8009

  8 worker.TomcatA.type=ajp13

  9 worker.TomcatA.lbfactor=1

 10 worker.StatA.type=status

 11 worker.tcsrvs.type=lb

 12 worker.tcsrvs.balance_workers=TomcatA,TomcatB

 13 worker.tcsrvs.sticky_session=0--------基于浏览器做粘性,一般为1


[root@node200 conf.d]# !ser

service httpd reload

重新载入 httpd:


技术分享    

                                       

技术分享


[root@node200 conf.d]# !tail

tail /var/log/httpd/mod_jk.log ------工作环境中不会开启debug级别

[Thu Dec 17 22:24:21.114 2015] [25040:139695854090208] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1403): 03d0    FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00  - ................

[Thu Dec 17 22:24:21.114 2015] [25040:139695854090208] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1403): 03e0    00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF  - ................

[Thu Dec 17 22:24:21.114 2015] [25040:139695854090208] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1403): 03f0    FF FF FF FC FC FC 5F 5F 5F C5 C5 C5 FF FF FF 9F  - ......___.......

[Thu Dec 17 22:24:21.114 2015] [25040:139695854090208] [debug] ws_write::mod_jk.c (552): written 5262 out of 5262

[Thu Dec 17 22:24:21.114 2015] [25040:139695854090208] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1403): received from ajp13 pos=0 len=2 max=8192

[Thu Dec 17 22:24:21.114 2015] [25040:139695854090208] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1403): 0000    05 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00  - ................

[Thu Dec 17 22:24:21.114 2015] [25040:139695854090208] [debug] ajp_process_callback::jk_ajp_common.c (2054): AJP13 protocol: Reuse is OK

[Thu Dec 17 22:24:21.115 2015] [25040:139695854090208] [debug] ajp_reset_endpoint::jk_ajp_common.c (810): (TomcatA) resetting endpoint with socket 14

[Thu Dec 17 22:24:21.115 2015] [25040:139695854090208] [debug] ajp_done::jk_ajp_common.c (3144): recycling connection pool for worker TomcatA and socket 14

[Thu Dec 17 22:24:21.115 2015] [25040:139695854090208] [debug] jk_handler::mod_jk.c (2790): Service finished with status=200 for worker=tcsrvs


技术分享



基于mod_porxy做负载均衡----接上

[root@node200 conf.d]# mv mod_jk.conf mod_jk.conf.bak

[root@node200 conf.d]# ls

ajp-tomcat.conf.bak  http-tomcat.conf.bak  mod_dnssd.conf  mod_jk.conf.bak  README  welcome.conf  workers.properties

[root@node200 conf.d]# mv ajp-tomcat.conf.bak mod_proxy.conf

[root@node200 conf.d]# vim mod_proxy.conf 

  1 <proxy balancer://tcsrvs>

  2         BalancerMember http://192.168.112.130:8080 loadfactor=1

  3         BalancerMember http://192.168.112.140:8080 loadfactor=1

  4 

  5 </proxy>

  6 <Virtualhost *:80> 

  7         ServerName www.zye.com

  8         ProxyVia On

  9         ProxyRequests Off 

 10         ProxyPreserveHost On

 11         <proxy *>

 12                 Order deny,allow

 13                 Allow from all

 14         </Proxy>

 15         ProxyPass /status ! 

 16         ProxyPass / balancer://tcsrvs/

 17         ProxyPassReverse / balancer://tcsrvs/

 18         <Location />

 19                 Order deny,allow

 20                 Allow from all

 21         </Location>

 22 </VirtualHost>


[root@node200 conf.d]# httpd -t

Syntax OK


[root@node200 conf.d]# httpd -t

Syntax OK

[root@node200 conf.d]# service httpd start

正在启动 httpd:                                           [确定]


技术分享



根据请求来调度

[root@node200 conf.d]# vim mod_proxy.conf 

  1 <proxy balancer://tcsrvs>

  2         BalancerMember http://192.168.112.130:8080 loadfactor=1

  3         BalancerMember http://192.168.112.140:8080 loadfactor=1

  4         ProxySet lbmethod=byrequests

  5 </proxy>

  6 <Virtualhost *:80>

  7         ServerName www.zye.com

  8         ProxyVia On

  9         ProxyRequests Off

 10         ProxyPreserveHost On

 11         <proxy *>

 12                 Order deny,allow

 13                 Allow from all

 14         </Proxy>

 15         ProxyPass /status !

 16         ProxyPass / balancer://tcsrvs/

 17         ProxyPassReverse / balancer://tcsrvs/

 18         <Location />

 19                 Order deny,allow

 20                 Allow from all

 21         </Location>

 22 </VirtualHost>


[root@node200 conf.d]# httpd -t

Syntax OK

[root@node200 conf.d]# service httpd reload

重新载入 httpd:


技术分享

技术分享


根据流量做调度

[root@node200 conf.d]# vim mod_proxy.conf 

  1 <proxy balancer://tcsrvs>

  2         BalancerMember http://192.168.112.130:8080 loadfactor=1

  3         BalancerMember http://192.168.112.140:8080 loadfactor=1

  4         ProxySet lbmethod=bytraffic 

  5 </proxy>

  6 <Virtualhost *:80>

  7         ServerName www.zye.com

  8         ProxyVia On

  9         ProxyRequests Off

 10         ProxyPreserveHost On

 11         <proxy *>

 12                 Order deny,allow

 13                 Allow from all

 14         </Proxy>

 15         ProxyPass /status !

 16         ProxyPass / balancer://tcsrvs/

 17         ProxyPassReverse / balancer://tcsrvs/

 18         <Location />

 19                 Order deny,allow

 20                 Allow from all

 21         </Location>

 22 </VirtualHost>


[root@node200 conf.d]# httpd -t

Syntax OK

[root@node200 conf.d]# service httpd reload

重新载入 httpd:


技术分享

技术分享


根据主机的繁忙程度

[root@node200 conf.d]# vim mod_proxy.conf 

  1 <proxy balancer://tcsrvs>

  2         BalancerMember http://192.168.112.130:8080 loadfactor=1

  3         BalancerMember http://192.168.112.140:8080 loadfactor=1

  4         ProxySet lbmethod=bybusyness 

  5 </proxy>

  6 <Virtualhost *:80>

  7         ServerName www.zye.com

  8         ProxyVia On

  9         ProxyRequests Off

 10         ProxyPreserveHost On

 11         <proxy *>

 12                 Order deny,allow

 13                 Allow from all

 14         </Proxy>

 15         ProxyPass /status !

 16         ProxyPass / balancer://tcsrvs/

 17         ProxyPassReverse / balancer://tcsrvs/

 18         <Location />

 19                 Order deny,allow

 20                 Allow from all

 21         </Location>

 22 </VirtualHost>


[root@node200 conf.d]# httpd -t

Syntax OK

[root@node200 conf.d]# service httpd reload

重新载入 httpd:


技术分享

技术分享

http修改ajp

[root@node200 conf.d]# vim mod_proxy.conf 

  1 <proxy balancer://tcsrvs>

  2         BalancerMember ajp://192.168.112.130:8009 loadfactor=1

  3         BalancerMember ajp://192.168.112.140:8009 loadfactor=1

  4         ProxySet lbmethod=bybusyness 

  5 </proxy>

  6 <Virtualhost *:80>

  7         ServerName www.zye.com

  8         ProxyVia On

  9         ProxyRequests Off

 10         ProxyPreserveHost On

 11         <proxy *>

 12                 Order deny,allow

 13                 Allow from all

 14         </Proxy>

 15         ProxyPass /status !

 16         ProxyPass / balancer://tcsrvs/

 17         ProxyPassReverse / balancer://tcsrvs/

 18         <Location />

 19                 Order deny,allow

 20                 Allow from all

 21         </Location>

 22 </VirtualHost>


[root@node200 conf.d]# httpd -t

Syntax OK

[root@node200 conf.d]# service httpd reload

重新载入 httpd:


技术分享

技术分享


会话粘性

[root@node200 conf.d]# vim mod_proxy.conf 

  1 <proxy balancer://tcsrvs>

  2         BalancerMember ajp://192.168.112.130:8009 loadfactor=1

  3         BalancerMember ajp://192.168.112.140:8009 loadfactor=1

  4         ProxySet lbmethod=bybusyness

  5 </proxy>

  6 <Virtualhost *:80>

  7         ServerName www.zye.com

  8         ProxyVia On

  9         ProxyRequests Off

 10         ProxyPreserveHost On

 11         <proxy *>

 12                 Order deny,allow

 13                 Allow from all

 14         </Proxy>

 15         ProxyPass /status !

 16         ProxyPass / balancer://tcsrvs/ stickysession=JSESSIONID

 17         ProxyPassReverse / balancer://tcsrvs/ stickysession=JSESSIONID

 18         <Location />

 19                 Order deny,allow

 20                 Allow from all

 21         </Location>

 22 </VirtualHost>


[root@node200 conf.d]# httpd -t

Syntax OK

[root@node200 conf.d]# service httpd reload

重新载入 httpd:


session没有实现



实现状态查看

[root@node200 conf.d]# vim mod_proxy.conf 


  1 <proxy balancer://tcsrvs>

  2         BalancerMember ajp://192.168.112.130:8009 loadfactor=1

  3         BalancerMember ajp://192.168.112.140:8009 loadfactor=1

  4         ProxySet lbmethod=bybusyness

  5 </proxy>

  6 <Virtualhost *:80>

  7         ServerName www.zye.com

  8         ProxyVia On

  9         ProxyRequests Off

 10         ProxyPreserveHost On

 11         <proxy *>

 12                 Order deny,allow

 13                 Allow from all

 14         </Proxy>

 15         ProxyPass /status !

 16         ProxyPass / balancer://tcsrvs/ stickysession=JSESSIONID

 17         ProxyPassReverse / balancer://tcsrvs/ stickysession=JSESSIONID

 18         <Location />

 19                 Order deny,allow

 20                 Allow from all

 21         </Location>

 22         <Location /status>

 23              SetHandler balancer-manager

 24              Proxypass !

 25              Order Deny,Allow

 26              Allow from all

 27        </Location>

 28 </VirtualHost>


[root@node200 conf.d]# httpd -t

Syntax OK

[root@node200 conf.d]# service httpd reload

重新载入 httpd:


技术分享



多播的会话集群

tomcat支持标准会话管理器和持久会话管理器

tomcat默认的标准会话管理器

delta会话管理器,如果是对所有主机,放在引擎内部;否则放入host中,对于单个主机


将两个后端主机(0.130;0.140)tomcat停掉

[root@node2 ~]# 

[root@node2 ~]# catalina.sh stop

Using CATALINA_BASE:   /usr/local/tomcat

Using CATALINA_HOME:   /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME:        /usr/java/latest

Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

You have new mail in /var/spool/mail/root


[root@node3 ~]# catalina.sh stop

Using CATALINA_BASE:   /usr/local/tomcat

Using CATALINA_HOME:   /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME:        /usr/java/latest

Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

You have new mail in /var/spool/mail/root


0.130

[root@node2 conf]# pwd

/usr/local/tomcat/conf

[root@node2 conf]# cp server.xml{,.bak}

[root@node2 conf]# ls

Catalina         catalina.properties  logging.properties  server.xml.bak    tomcat-users.xsd

catalina.policy  context.xml          server.xml          tomcat-users.xml  web.xml


[root@node2 conf]# vim server.xml

123       <Host name="localhost"  appBase="webapps"

124             unpackWARs="true" autoDeploy="true">

125         <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"

126          channelSendOptions="8">

127 

128           <Manager className="org.apache.catalina.ha.session.DeltaManager"

129              expireSessionsOnShutdown="false"

130              notifyListenersOnReplication="true"/>

131 

132           <Channel className="org.apache.catalina.tribes.group.GroupChannel">

133             <Membership className="org.apache.catalina.tribes.membership.McastService"

134                        address="228.103.40.41"

135                         port="45564"

136                        frequency="500"

137                        dropTime="3000"/>

138             <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"

139                       address="192.168.112.130"

140                       port="4000"

141                       autoBind="100"

142                       selectorTimeout="5000"

143                       maxThreads="6"/>

144 

145             <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">

146                 <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>

147             </Sender>

148             <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>

149             <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>

150           </Channel>

151 

152           <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"

153            filter=""/>

154           <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>

155 

156           <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"

157               tempDir="/tmp/war-temp/"

158               deployDir="/tmp/war-deploy/"

159               watchDir="/tmp/war-listen/"

160               watchEnabled="false"/>

161 

162          <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>

163      </Cluster>

[root@node2 conf]# catalina.sh configtest

Using CATALINA_BASE:   /usr/local/tomcat

Using CATALINA_HOME:   /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME:        /usr/java/latest

Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

十二月 19, 2015 1:03:15 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Server version:        Apache Tomcat/8.0.30

十二月 19, 2015 1:03:15 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Server built:          Dec 1 2015 22:30:46 UTC

十二月 19, 2015 1:03:15 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Server number:         8.0.30.0

十二月 19, 2015 1:03:15 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: OS Name:               Linux

十二月 19, 2015 1:03:15 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: OS Version:            2.6.32-573.el6.x86_64

十二月 19, 2015 1:03:15 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Architecture:          amd64

十二月 19, 2015 1:03:15 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Java Home:             /usr/java/jdk1.7.0_67/jre

十二月 19, 2015 1:03:15 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: JVM Version:           1.7.0_67-b01

十二月 19, 2015 1:03:15 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: JVM Vendor:            Oracle Corporation

十二月 19, 2015 1:03:15 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: CATALINA_BASE:         /usr/local/apache-tomcat-8.0.30

十二月 19, 2015 1:03:15 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: CATALINA_HOME:         /usr/local/apache-tomcat-8.0.30

十二月 19, 2015 1:03:16 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

十二月 19, 2015 1:03:16 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Command line argument: -Djava.endorsed.dirs=/usr/local/tomcat/endorsed

十二月 19, 2015 1:03:16 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Command line argument: -Dcatalina.base=/usr/local/tomcat

十二月 19, 2015 1:03:16 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Command line argument: -Dcatalina.home=/usr/local/tomcat

十二月 19, 2015 1:03:16 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp

十二月 19, 2015 1:03:16 上午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent

信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib

十二月 19, 2015 1:03:17 上午 org.apache.coyote.AbstractProtocol init

信息: Initializing ProtocolHandler ["http-nio-8080"]

十二月 19, 2015 1:03:18 上午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector

信息: Using a shared selector for servlet write/read

十二月 19, 2015 1:03:18 上午 org.apache.coyote.AbstractProtocol init

信息: Initializing ProtocolHandler ["ajp-nio-8009"]

十二月 19, 2015 1:03:18 上午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector

信息: Using a shared selector for servlet write/read

十二月 19, 2015 1:03:18 上午 org.apache.catalina.startup.Catalina load

信息: Initialization processed in 6942 ms

You have new mail in /var/spool/mail/root


创建支持集群会话的集群化管理器

一般在webapp文件里的WEB-INF的xml文件

[root@node2 conf]# cd /usr/local/tomcat/webapps/testapp/WEB-INF/

[root@node2 WEB-INF]# ls

[root@node2 WEB-INF]# cp /usr/local/tomcat/conf/web.xml ./

You have new mail in /var/spool/mail/root

[root@node2 WEB-INF]# ls

web.xml

[root@node2 WEB-INF]# vim web.xml 

You have new mail in /var/spool/mail/root

101   <!--                       listings is enabled? [true]                    -->

 102 

 103 <distributable />

 104     

 105     <servlet>

 106         <servlet-name>default</servlet-name>

 107         <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>

 108         <init-param>

[root@node2 WEB-INF]# scp web.xml 192.168.112.140:/usr/local/tomcat/webapps/testapp/WEB-INF/

root@192.168.112.140‘s password: 

web.xml                                                                                     100%  165KB 164.9KB/s   00:00    

You have new mail in /var/spool/mail/root


[root@node2 WEB-INF]# 

[root@node2 WEB-INF]# catalina.sh start

Using CATALINA_BASE:   /usr/local/tomcat

Using CATALINA_HOME:   /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME:        /usr/java/latest

Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

Tomcat started.

You have new mail in /var/spool/mail/root


[root@node2 tomcat]# tail -f logs/catalina.out

[root@node2 tomcat]# tail -200 logs/catalina.out

19-Dec-2015 01:32:53.595 INFO [Catalina-startStop-1] org.apache.catalina.tribes.membership.McastServiceImpl.setupSocket Setting cluster mcast soTimeout to 500

19-Dec-2015 01:32:53.618 INFO [Catalina-startStop-1] org.apache.catalina.tribes.membership.McastServiceImpl.waitForMembers Sleeping for 1000 milliseconds to establish cluster membership, start level:4

19-Dec-2015 01:32:54.620 INFO [Catalina-startStop-1] org.apache.catalina.tribes.membership.McastServiceImpl.waitForMembers Done sleeping, membership established, start level:4

19-Dec-2015 01:32:54.636 INFO [Catalina-startStop-1] org.apache.catalina.tribes.membership.McastServiceImpl.waitForMembers Sleeping for 1000 milliseconds to establish cluster membership, start level:8

19-Dec-2015 01:32:55.638 INFO [Catalina-startStop-1] org.apache.catalina.tribes.membership.McastServiceImpl.waitForMembers Done sleeping, membership established, start level:8

19-Dec-2015 01:32:55.646 INFO [Catalina-startStop-1] org.apache.catalina.ha.deploy.FarmWarDeployer.start Cluster FarmWarDeployer started.

19-Dec-2015 01:32:55.823 INFO [Catalina-startStop-1] org.apache.catalina.ha.session.JvmRouteBinderValve.startInternal JvmRouteBinderValve started

19-Dec-2015 01:32:59.292 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]

19-Dec-2015 01:32:59.331 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]

19-Dec-2015 01:32:59.336 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 5861 ms

19-Dec-2015 01:35:59.648 INFO [Tribes-Task-Receiver-1] org.apache.catalina.tribes.io.BufferPool.getBufferPool Created a buffer pool with max size:104857600 bytes of type: org.apache.catalina.tribes.io.BufferPool15Impl

19-Dec-2015 01:36:00.537 INFO [Membership-MemberAdded.] org.apache.catalina.ha.tcp.SimpleTcpCluster.memberAdded Replication member added:org.apache.catalina.tribes.membership.MemberImpl[tcp://{192, 168, 112, 140}:4000,{192, 168, 112, 140},4000, alive=1149, securePort=-1, UDP Port=-1, id={23 38 105 -109 78 41 64 -63 -79 -106 115 93 27 -33 -123 -19 }, payload={}, command={}, domain={}, ]



0.140

[root@node3 ~]# cd /usr/local/tomcat/conf/

You have new mail in /var/spool/mail/root

[root@node3 conf]# ls

Catalina         catalina.properties  logging.properties  tomcat-users.xml  web.xml

catalina.policy  context.xml          server.xml          tomcat-users.xsd

[root@node3 conf]# cp server.xml{,.bak}

[root@node3 conf]# ls

Catalina         catalina.properties  logging.properties  server.xml.bak    tomcat-users.xsd

catalina.policy  context.xml          server.xml          tomcat-users.xml  web.xml


[root@node3 conf]# vim server.xml

123       <Host name="localhost"  appBase="webapps"

124             unpackWARs="true" autoDeploy="true">

125                  <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"

126                                  channelSendOptions="8">

127 

128                           <Manager className="org.apache.catalina.ha.session.DeltaManager"

129                                    expireSessionsOnShutdown="false"

130                                    notifyListenersOnReplication="true"/>

132                           <Channel className="org.apache.catalina.tribes.group.GroupChannel">

133                             <Membership className="org.apache.catalina.tribes.membership.McastService"

134                                         address="228.103.40.41"

135                                         port="45564"

136                                         frequency="500"

137                                         dropTime="3000"/>

138                             <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"

139                                       address="192.168.112.140"

140                                       port="4000"

141                                       autoBind="100"

142                                       selectorTimeout="5000"

143                                       maxThreads="6"/>

144 

145                             <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">

146                               <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>

147                             </Sender>

148                             <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>

149                             <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interce    ptor"/>

150                           </Channel>

151 

152                           <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"

153                                  filter=""/>

154                           <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>

155 

156                           <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"

157                                     tempDir="/tmp/war-temp/"

158                                     deployDir="/tmp/war-deploy/"

159                                     watchDir="/tmp/war-listen/"

160                                     watchEnabled="false"/>

161 

162                   <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>

163                 </Cluster>


[root@node3 conf]# catalina.sh configtest

Using CATALINA_BASE:   /usr/local/tomcat

Using CATALINA_HOME:   /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME:        /usr/java/latest

Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

十二月 19, 2015 1:01:39 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Server version:        Apache Tomcat/8.0.30

十二月 19, 2015 1:01:39 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Server built:          Dec 1 2015 22:30:46 UTC

十二月 19, 2015 1:01:39 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Server number:         8.0.30.0

十二月 19, 2015 1:01:39 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: OS Name:               Linux

十二月 19, 2015 1:01:39 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: OS Version:            2.6.32-573.el6.x86_64

十二月 19, 2015 1:01:39 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Architecture:          amd64

十二月 19, 2015 1:01:39 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Java Home:             /usr/java/jdk1.7.0_67/jre

十二月 19, 2015 1:01:39 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: JVM Version:           1.7.0_67-b01

十二月 19, 2015 1:01:39 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: JVM Vendor:            Oracle Corporation

十二月 19, 2015 1:01:39 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: CATALINA_BASE:         /usr/local/apache-tomcat-8.0.30

十二月 19, 2015 1:01:39 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: CATALINA_HOME:         /usr/local/apache-tomcat-8.0.30

十二月 19, 2015 1:01:39 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

十二月 19, 2015 1:01:39 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Command line argument: -Djava.endorsed.dirs=/usr/local/tomcat/endorsed

十二月 19, 2015 1:01:39 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Command line argument: -Dcatalina.base=/usr/local/tomcat

十二月 19, 2015 1:01:39 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Command line argument: -Dcatalina.home=/usr/local/tomcat

十二月 19, 2015 1:01:39 上午 org.apache.catalina.startup.VersionLoggerListener log

信息: Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp

十二月 19, 2015 1:01:39 上午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent

信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib

十二月 19, 2015 1:01:42 上午 org.apache.coyote.AbstractProtocol init

信息: Initializing ProtocolHandler ["http-nio-8080"]

十二月 19, 2015 1:01:42 上午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector

信息: Using a shared selector for servlet write/read

十二月 19, 2015 1:01:42 上午 org.apache.coyote.AbstractProtocol init

信息: Initializing ProtocolHandler ["ajp-nio-8009"]

十二月 19, 2015 1:01:42 上午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector

信息: Using a shared selector for servlet write/read

十二月 19, 2015 1:01:42 上午 org.apache.catalina.startup.Catalina load

信息: Initialization processed in 8859 ms


[root@node2 WEB-INF]# catalina.sh start

Using CATALINA_BASE:   /usr/local/tomcat

Using CATALINA_HOME:   /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME:        /usr/java/latest

Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

Tomcat started.

You have new mail in /var/spool/mail/root


[root@node3 conf]# tail -f ../logs/catalina.out

19-Dec-2015 01:35:43.136 INFO [localhost-startStop-1] org.apache.catalina.ha.session.DeltaManager.startInternal Starting clustering manager at /testapp

19-Dec-2015 01:35:43.187 INFO [localhost-startStop-1] org.apache.catalina.ha.session.DeltaManager.getAllClusterSessions Manager [/testapp], requesting session state from org.apache.catalina.tribes.membership.MemberImpl[tcp://{192, 168, 112, 130}:4000,{192, 168, 112, 130},4000, alive=194469, securePort=-1, UDP Port=-1, id={91 -22 -120 26 40 -91 78 -64 -84 101 -114 112 28 34 81 121 }, payload={}, command={}, domain={}, ]. This operation will timeout if no session state has been received within 60 seconds.

19-Dec-2015 01:35:43.491 INFO [localhost-startStop-1] org.apache.catalina.ha.session.DeltaManager.waitForSendAllSessions Manager [/testapp]; session state send at 12/19/15 1:35 AM received in 354 ms.

19-Dec-2015 01:35:43.550 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/apache-tomcat-8.0.30/webapps/testapp has finished in 702 ms

19-Dec-2015 01:35:43.560 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]

19-Dec-2015 01:35:43.586 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]

19-Dec-2015 01:35:43.587 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 9636 ms

19-Dec-2015 01:35:43.187 INFO [localhost-startStop-1] org.apache.catalina.ha.session.DeltaManager.getAllClusterSessions Manager [/testapp], requesting session state from org.apache.catalina.tribes.membership.MemberImpl[tcp://{192, 168, 112, 130}:4000,{192, 168, 112, 130},4000, alive=194469, securePort=-1, UDP Port=-1, id={91 -22 -120 26 40 -91 78 -64 -84 101 -114 112 28 34 81 121 }, payload={}, command={}, domain={}, ]. This operation will timeout if no session state has been received within 60 seconds.

19-Dec-2015 01:35:43.491 INFO [localhost-startStop-1] org.apache.catalina.ha.session.DeltaManager.waitForSendAllSessions Manager [/testapp]; session state send at 12/19/15 1:35 AM received in 354 ms.

19-Dec-2015 01:35:43.550 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/apache-tomcat-8.0.30/webapps/testapp has finished in 702 ms

19-Dec-2015 01:35:43.560 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]

19-Dec-2015 01:35:43.586 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]

19-Dec-2015 01:35:43.587 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 9636 ms


技术分享

技术分享


tomcat(2)--集群

标签:tomcat

原文地址:http://youenstudy.blog.51cto.com/6722910/1726686

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!