Tomcat+Nginx+Memcacheed集群部署
主机环境 RedHat6.5 64位
实验环境 服务端1 ip172.25.29.1 nginx
服务端2 ip 172.25.29.2 tomcat+memcached
服务端3 ip 172.25.29.3 tomcat+memcaceed
安装包 jdk-7u79-linux-x64.tar.gz
apache-tomcat-7.0.37.tar.gz
nginx-goodies-nginx-sticky-module-ng-c78b7dd79d0d.tar.gz
asm-3.2.jar
kryo-1.04.jar
kryo-serializers-0.10.jar
memcached-session-manager-1.6.3.jar
memcached-session-manager-tc7-1.6.3.jar
minlog-1.2.jar
msm-kryo-serializer-1.6.3.jar
reflectasm-1.01.jar
spymemcached-2.7.3.jar
防火墙状态 关闭
1.jdk安装、环境配置及测试服务端2
1.解压、作软链接
[root@server2mnt]# tar zxf jdk-7u79-linux-x64.tar.gz -C /usr/local/ #解压jdk
[root@server2mnt]# cd /usr/local/ #切换到解压目录
[root@server2local]# ls
bin etc games include jdk1.7.0_79 lib lib64 libexec sbin share src
[root@server2local]# ln -s jdk1.7.0_79/ Java #作软链接
[root@server2local]# ll
total44
drwxr-xr-x.2 root root 4096 Jun 28 2011 bin
drwxr-xr-x.2 root root 4096 Jun 28 2011 etc
drwxr-xr-x.2 root root 4096 Jun 28 2011 games
drwxr-xr-x.2 root root 4096 Jun 28 2011 include
lrwxrwxrwx.1 root root 12 Sep 24 10:50 java ->jdk1.7.0_79/ #查看
drwxr-xr-x.8 uucp 143 4096 Apr 11 2015 jdk1.7.0_79
drwxr-xr-x.2 root root 4096 Jun 28 2011 lib
drwxr-xr-x.2 root root 4096 Jun 28 2011 lib64
drwxr-xr-x.2 root root 4096 Jun 28 2011 libexec
drwxr-xr-x.2 root root 4096 Jun 28 2011 sbin
drwxr-xr-x.5 root root 4096 Aug 8 21:38 share
drwxr-xr-x.2 root root 4096 Jun 28 2011 src
2.将jdk添加到环境变量
[root@server2local]# vim /etc/profile
79 export JAVA_HOME=/usr/local/java
80 exportCLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
81 export PATH=$PATH:$JAVA_HOME/bin
[root@server2local]# source /etc/profile
3.测试
[root@server2local]# echo $JAVA_HOME #测试添加环境变量是否成功
/usr/local/java
[root@server2local]# echo $CLASSPATH
.:/usr/local/java/lib:/usr/local/java/jre/lib
[root@server2local]# echo $JAVA_HOME
/usr/local/java
[root@server2local]# cd java #测试java的环境是否配置成功
[root@server2java]# vim test.java #写个简单的测试页
1 public class test{
2 public static void main(String[] args)
3 {
4 System.out.println("Helloworld!");
5 }
6 }
[root@server2java]# javac test.java #链接生成test.class文件
[root@server2mnt]# java test #执行
Helloworld!
2.tomcat的安装服务端2
1.解压、作软链接
[root@server2mnt]# tar zxf apache-tomcat-7.0.8.tar.gz -C /usr/local/ #解压
[root@server2mnt]# cd /usr/local/
[root@server2local]# ls
apache-tomcat-7.0.8 etc include jdk1.7.0_79 lib64 sbin src
bin games java lib libexec share
[root@server2local]# ln -s apache-tomcat-7.0.8/ tomcat #作软链接
[root@server2local]# ll
total48
drwxr-xr-x.9 root root 4096 Sep 24 11:11 apache-tomcat-7.0.8
drwxr-xr-x.2 root root 4096 Jun 28 2011 bin
drwxr-xr-x.2 root root 4096 Jun 28 2011 etc
drwxr-xr-x.2 root root 4096 Jun 28 2011 games
drwxr-xr-x.2 root root 4096 Jun 28 2011 include
lrwxrwxrwx.1 root root 12 Sep 24 10:50 java ->jdk1.7.0_79/
drwxr-xr-x.8 uucp 143 4096 Sep 24 11:02 jdk1.7.0_79
drwxr-xr-x.2 root root 4096 Jun 28 2011 lib
drwxr-xr-x.2 root root 4096 Jun 28 2011 lib64
drwxr-xr-x.2 root root 4096 Jun 28 2011 libexec
drwxr-xr-x.2 root root 4096 Jun 28 2011 sbin
drwxr-xr-x.5 root root 4096 Aug 8 21:38 share
drwxr-xr-x.2 root root 4096 Jun 28 2011 src
lrwxrwxrwx.1 root root 20 Sep 24 11:12 tomcat-> apache-tomcat-7.0.8/ #查看
[root@server2local]# cd tomcat/bin
[root@server2bin]# ./startup.sh #开启tomcat
2.测试
[root@server2bin]#cd ..
[root@server2tomcat]# vim webapps/ROOT/test.jsp #写测试仪页
1 server2-The Time is <%=newjava.util.Date()%>
#测试 172.25.29.2:8080
172.25.29.2:8080/test.jsp