LNMP平臺搭建

搭建環境:Redhat6.5php

建議:將全部包放到/root下,與本文路徑相同css


 安裝mysqlhtml

下載mysql:前端

官網:https://www.mysql.com/java

連接:https://pan.baidu.com/s/1kSVk-2ibHxpPijtKIty0ow node

提取碼:ke57mysql

解壓mysql源碼包:linux

tar zxf mysql-boost-5.7.11.tar.gz -C /root  #這裏解壓到/root下,由於後面編譯的時候調用的是/root/mysql-5.7.11/自帶的boost庫nginx

安裝cmake工具:c++

連接:https://pan.baidu.com/s/19Fftaqhq8ilcJPYZGr4e1g
提取碼:4rop

yum localinstall cmake-2.8.12.2-4.el6.x86_64.rpm -y

安裝依賴性:

yum install gcc gcc-c++ ncurses-devel bison -y  #這些包Redhat鏡像中自帶

cd mysql-5.7.11/

編譯:

#若是編譯報錯,首先刪除編譯過程當中生成的CMakeCache.txt文件,解決完報錯後再使用cmake從新編譯

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=/root/mysql-5.7.11/boost/boost_1_59_0/

安裝:

make install

#安裝過程很長(大約30min),機器內存建議至少2G

建立mysql用戶:

[root@server1 ~]# groupadd -g 27 mysql
[root@server1 ~]# useradd -u 27 -g 27 -M -d /usr/local/lnmp/mysql/ mysql

-M:不自動建立用戶家目錄

-d:指定用戶家目錄
[root@server1 ~]# usermod -s /sbin/nologin mysql

#設置mysql用戶不能登陸系統

將mysql命令加入系統指令:

[root@server1 ~]# vim /root/.bash_profile

PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin

[root@server1 ~]# source /root/.bash_profile

修改mysql配置文件:

[root@server1 ~]# vim /etc/my.cnf

datadir=/usr/local/lnmp/mysql/data
socket=/usr/local/lnmp/mysql/data/mysql.sock

複製mysql啓動腳本到系統目錄下:

[root@server1 ~]# cd /usr/local/lnmp/mysql/support-files/
[root@server1 support-files]# cp mysql.server /etc/init.d/mysqld

數據庫初始化:

#初始化以後會在/usr/local/lnmp/mysql目錄下生成data目錄

#這個過程會有卡頓,等待片刻就行

[root@server1 support-files]# mysqld --initialize --user=mysql

      ...

2018-01-27T14:44:19.987069Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-01-27T14:44:19.989551Z 1 [Note] A temporary password is generated for root@localhost: /2UMx3Btelb9   #這個碼是隨機生成的數據庫初始密碼

修改文件權限:

[root@server1 support-files]# cd /usr/local/lnmp/mysql/

[root@server1 mysql]# chown mysql.mysql . -R

[root@server1 mysql]# chown root . -R

[root@server1 mysql]# chown mysql data -R

[root@server1 mysql]# ll
total 60
drwxr-xr-x 2 root mysql 4096 Jan 27 22:22 bin
-rw-r--r-- 1 root mysql 17987 Feb 2 2016 COPYING
drwxr-x--- 5 mysql mysql 4096 Jan 27 22:46 data
drwxr-xr-x 2 root mysql 4096 Jan 27 22:21 docs
drwxr-xr-x 3 root mysql 4096 Jan 27 22:21 include
drwxr-xr-x 4 root mysql 4096 Jan 27 22:22 lib
drwxr-xr-x 4 root mysql 4096 Jan 27 22:21 man
drwxr-xr-x 10 root mysql 4096 Jan 27 22:22 mysql-test
-rw-r--r-- 1 root mysql 2478 Feb 2 2016 README
drwxr-xr-x 28 root mysql 4096 Jan 27 22:23 share
drwxr-xr-x 2 root mysql 4096 Jan 27 22:23 support-files

啓動服務:

[root@server1 mysql]# /etc/init.d/mysqld start

第一次使用數據庫須要設定密碼:

#隨機生成的密碼沒法正常登錄數據庫

[root@server1 mysql]# mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:     #輸入剛纔隨機生成的數據庫初始密碼

The existing password for the user account root has expired. Please set a new password.

New password:                      #輸入新密碼

Re-enter new password:       #確認新密碼

    ...           #後面的內容是讓選擇密碼複雜度等,若是不想設定這些,直接一路按回車便可完成

登錄數據庫:

[root@server1 mysql]# mysql -p
Enter password:      #輸入剛纔設定的新密碼

 安裝php

php安裝包及其依賴包彙總:

連接:https://pan.baidu.com/s/1E7Gal6zkBcozuAU7rTsF6A
提取碼:tvoo

php官網:

http://www.php.net/

解壓源碼包:

[root@server1 ~]# tar jxf php-5.6.20.tar.bz2

安裝依賴性:

yum install gmp-devel net-snmp-devel libxml2-devel openssl-devel curl-devel -y

#下面這幾個包redhat6.5鏡像中沒有,從分享的連接中下載

yum localinstall libmcrypt-devel-2.5.8-9.el6.x86_64.rpm gd-devel-2.0.35-11.el6.x86_64.rpm re2c-0.13.5-1.el6.x86_64.rpm libmcrypt-2.5.8-9.el6.x86_64.rpm -y

編譯安裝php:

[root@server1 ~]# cd php-5.6.20/
[root@server1 php-5.6.20]# ./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --without-pear --with-gettext --with-gmp --enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash

[root@server1 php-5.6.20]# make && make install  #時間較長,7分鐘左右

創建php-fpm配置文件:(php-fpm至關因而php的監聽服務,由它守護(控制)着php服務的運行)

 [root@server1 php-5.6.20]# cd /usr/local/lnmp/php/etc/

[root@server1 etc]# cp php-fpm.conf.default php-fpm.conf

創建php配置文件:

#回到解壓出來的php包目錄中,我以前是在/root下解壓的包,所以到/root目錄下尋找php配置模板

[root@server1 etc]# cd /root/php-5.6.20

[root@server1 php-5.6.20]# cp php.ini-production /usr/local/lnmp/php/etc/php.ini

創建php-fpm啓動腳本:

[root@server1 php-5.6.20]# cd /root/php-5.6.20/sapi/fpm/
[root@server1 fpm]# cp init.d.php-fpm /etc/init.d/php-fpm
[root@server1 fpm]# chmod +x /etc/init.d/php-fpm

修改php-fpm配置文件:

[root@server1 fpm]# cd /usr/local/lnmp/php/etc/

[root@server1 etc]# vim php-fpm.conf 

 25 pid = run/php-fpm.pid

修改php配置文件:

修改時區:

[root@server1 etc]# vim php.ini

 925 date.timezone = Asia/Shanghai

1001 pdo_mysql.default_socket= /usr/local/lnmp/mysql/data/mysql.sock

1150 mysql.default_socket = /usr/local/lnmp/mysql/data/mysql.sock

1209 mysqli.default_socket = /usr/local/lnmp/mysql/data/mysql.sock

在編譯php的時候已經指定了nginx用戶(與nginx服務作接口),但目前還未安裝nginx,所以先建立nginx用戶,將php服務啓動起來:

[root@server1 etc]# useradd -u 800 -M -d /usr/local/lnmp/nginx nginx

啓動php服務:(php-fpm在9000端口運行)

[root@server1 etc]# /etc/init.d/php-fpm start

[root@server1 etc]# netstat -antlp |grep :9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 502/php-fpm

安裝nginx

安裝包:

連接:https://pan.baidu.com/s/1JJlEc-fLeB1MssLznpYIGA
提取碼:yl3o

[root@server1 ~]# tar zxf nginx-1.10.1.tar.gz

[root@server1 ~]# cd nginx-1.10.1

[root@server1 nginx-1.10.1]# vim src/core/nginx.h

 14 #define NGINX_VER          "nginx"        #去掉版本號後綴

[root@server1 nginx-1.10.1]# vim auto/cc/gcc

 178 # debug
 179 #CFLAGS="$CFLAGS -g"                  #去掉debug過程,減小編譯時間

安裝依賴包、編譯:

[root@server1 nginx-1.10.1]# yum install pcre-devel -y

[root@server1 nginx-1.10.1]# ./configure --prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_stub_status_module --with-file-aio --with-threads --user=nginx --group=nginx

[root@server1 nginx-1.10.1]# make && make install

nginx啓動腳本作軟連接並加入系統指令中,方便使用:

[root@server1 nginx-1.10.1]# ln -s /usr/local/lnmp/nginx/sbin/nginx /usr/local/sbin/

vim /root/.bash_profile

PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin:/usr/local/lnmp/nginx/sbin

source /root/.bash_profile

修改nginx配置文件,使之支持php:

[root@server1 nginx-1.10.1]# vim /usr/local/lnmp/nginx/conf/nginx.conf

  2 user  nginx;

27 sendfile        on;
28 tcp_nopush     on;  #去掉註釋
29 tcp_nodelay    on;  #增長一行

34  gzip  on;

46             index  index.php index.html index.htm;     #將默認網頁換爲php網頁

66 location ~ \.php$ {
67    root      html;
68    fastcgi_pass  127.0.0.1:9000;
69    fastcgi_index  index.php;
70 #    fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
71    include      fastcgi.conf;
72 }

#修改66~72行時注意格式保持不變,以下圖:

 

 新建php網頁前端文件:

[root@server1 nginx-1.10.1]# vim /usr/local/lnmp/nginx/html/index.php

<?php
phpinfo()
?>

檢查nginx配置文件是否有語法錯誤:

[root@server1 nginx-1.10.1]# nginx -t
nginx: the configuration file /usr/local/lnmp/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/lnmp/nginx/conf/nginx.conf test is successful

啓動服務:

[root@server1 nginx-1.10.1]# nginx

測試:(server1主機ip=172.25.254.1)

#通常這裏須要設置防火牆規則,容許相關服務經過,這裏選擇直接關閉安全規則(關閉防火牆和selinux),執行如下兩條命令:

iptables -F

setenforce 0

測試結果:

 安裝discuz:

建立虛擬主機:

mkdir /bbs

vim /usr/local/lnmp/nginx/conf/nginx.conf  #倒數第二行增長以下內容

 

117     server {
118         listen 80;
119         server_name bbs.vaon.org;
120         location / {
121                 root /bbs;
122                 index index.php;
123         }
124         location ~ \.php$ {
125                 root /bbs;
126                 fastcgi_pass 127.0.0.1:9000;
127                 fastcgi_index index.php;
128                 include fastcgi.conf;
129         }
130     }
131 }  #注意這個括號是配置文件中原本就有的括號,實際並不加這行

nginx -s reload

安裝論壇:

軟件包:

連接:https://pan.baidu.com/s/1mf5e4MGkH6EiJcoe1X4bzA
提取碼:fn33

yum install unzip -y

unzip Discuz_X3.2_SC_UTF8.zip

cd upload/

mv * /bbs/

修改discuz裏面文件的權限:

cd /bbs/

chmod 777 config/ data/ -R

chmod 777 uc_client/ uc_server/ -R

修改數據庫權限:

cd /usr/local/lnmp/mysql/

chmod 755 data/

nginx -s reload

瀏覽器訪問bbs.vaon.org,完成discuz論壇安裝:

#在訪問以前須要在客戶端(windows)設置解析(若是是linux客戶機配置文件在/etc/hosts):打開C:\Windows\System32\drivers\etc\hosts文件,在最後面加上一條解析(服務器ip+域名)172.25.254.1 bbs.vaon.org

 安裝memcache

server2(172.25.254.2):

[root@server2 ~]# yum install -y memcached

[root@server2 ~]# /etc/init.d/memcached start

[root@server2 ~]# rpm -qa |grep memcache
memcached-1.4.4-3.el6.x86_64

[root@server2 ~]# yum install telnet -y
[root@server2 ~]# telnet localhost 11211
set name 0 0 6
vaon

STORED
get name
VALUE name 0 6
vaon

END
quit

關閉server2的防火牆規則:iptables -F && setenforce 0

server1:
#將php命令加入全局變量中:

[root@server1 ~]# vim /root/.bash_profile

PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin:/usr/local/lnmp/nginx/sbin:/usr/local/lnmp/php/bin

[root@server1 ~]# source /root/.bash_profile

連接:https://pan.baidu.com/s/12PVjMOEM-ddFBUGenjn5Mw
提取碼:99ym

[root@server1 ~]# tar zxf memcache-2.2.5.tar.gz
[root@server1 ~]# cd memcache-2.2.5
[root@server1 memcache-2.2.5]# phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
[root@server1 memcache-2.2.5]# ./configure --prefix=/usr/local/lnmp/php/memcache

[root@server1 memcache-2.2.5]# make && make install
      ...

Installing shared extensions:     /usr/local/lnmp/php/lib/php/extensions/no-debug-non-zts-20131226/
[root@server1 memcache-2.2.5]# ls /usr/local/lnmp/php/lib/php/extensions/no-debug-non-zts-20131226/

memcache.so  opcache.a  opcache.so

#修改php配置文件(去掉註釋並修改參數便可):

[root@server1 etc]# vim /usr/local/lnmp/php/etc/php.ini

 862 extension=memcache.so

[root@server1 etc]# /etc/init.d/php-fpm reload

[root@server1 etc]# cd /root/memcache-2.2.5
[root@server1 memcache-2.2.5]# cp memcache.php /usr/local/lnmp/nginx/html/

[root@server1 memcache-2.2.5]# cp example.php /usr/local/lnmp/nginx/html/

[root@server1 memcache-2.2.5]# cd /usr/local/lnmp/nginx/html/

[root@server1 html]# vim example.php  #注意這裏寫的是server2的ip

  3 $memcache = memcache_connect('172.25.254.2', 11211);

[root@server1 html]# vim memcache.php

 23 define('ADMIN_PASSWORD','redhat');      // Admin Password
 28 $MEMCACHE_SERVERS[] = '172.25.254.2:11211'; // add more as an array
 29 #$MEMCACHE_SERVERS[] = 'mymemcache-server2:11211'; // add more as an ar    ray

#訪問到這個頁面表示memcache安裝成功

#訪問這個狀態頁面須要輸入memcache.php文件中設置過的用戶名密碼才能進入(用戶名memcache密碼redhat)

 #壓力測試(root@station是真機,充當客戶端):

[root@station ~]# ab -c 100 -n 5000 http://172.25.254.1/index.php
    ...

Complete requests:      5000    #全部請求
Failed requests:        488          #失敗的請求
    ...

openresty

和nginx功能同樣

轉自:https://kb.cnblogs.com/page/117183/

server3:

yum install -y memcached

/etc/init.d/memcached start

關閉iptables和selinux

server1:

#關閉以前的nginx:

[root@server1 ~]# nginx -s stop

#安裝openresty:

連接:https://pan.baidu.com/s/1FBSeGYT3iENmqCXcYdJdgQ
提取碼:7icl

[root@server1 ~]# tar zxf openresty-1.13.6.1.tar.gz

[root@server1 ~]# cd openresty-1.13.6.1

[root@server1 openresty-1.13.6.1]# ./configure

[root@server1 openresty-1.13.6.1]# gmake && gmake install

[root@server1 openresty-1.13.6.1]# cd /usr/local/openresty/nginx/
[root@server1 nginx]# vim html/index.php

<?php
phpinfo()
?>
[root@server1 nginx]# vim conf/nginx.conf
  3 worker_processes  1;
 17 http {
 18
 19         upstream memcache {
 20         server 172.25.254.2:11211;
 21         server 172.25.254.3:11211;
 22         keepalived 512 single;
 23         }
 24     include       mime.types;
 25     default_type  application/octet-stream;
 49         location / {
 50             root   html;
 51             index  index.php index.html index.htm;
 52         }
 69         location /memc {
 70         internal;
 71
 72         memc_connect_timeout 100ms;
 73         memc_send_timeout 100ms;
 74         memc_read_timeout 100ms;
 75
 76         set $memc_key $query_string;
 77         set $memc_exptime 300;
 78
 79         memc_pass memcache;
 80         }
 81         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9    000
 82         #
 83         location ~ \.php$ {
 84            set $key $uri$args;
 85             srcache_fetch GET /memc $key;
 86             srcache_store PUT /memc $key;
 87             root           html;
 88             fastcgi_pass   127.0.0.1:9000;
 89             fastcgi_index  index.php;
 90         #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name    ;
 91             include        fastcgi.conf;
 92         }
#開啓服務:
[root@server1 nginx]# ./sbin/nginx
nginx: [emerg] unknown directive "keepalived" in /usr/local/openresty/nginx/conf/nginx.conf:22  #報錯,未解決
server2|3:
/etc/init.d/memcached restart
宿主機:
作壓力測試

 安裝jsp、tomcat

server2:

#安裝jsp:

redhat6.5鏡像中帶的java是open-jdk,但與原生的java還有區別的(缺乏一些模塊)。下載jdk-7u79-linux-x64

連接:https://pan.baidu.com/s/15KRKL22D2PtCC8urUCucsw
提取碼:uou9

[root@server2 ~]# tar zxf jdk-7u79-linux-x64.tar.gz -C /usr/local/
c[root@server2 ~]# cd /usr/local/
[root@server2 local]# ln -s jdk1.7.0_79/ java
[root@server2 local]# vim /etc/profile

 export JAVA_HOME=/usr/local/java
 export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
# .表示本地目錄(java運行時的當前目錄)  :表示分隔
 export PATH=$PATH:SJAVA_HOME/bin
[root@server2 local]# source /etc/profile
#安裝tomcat:

連接:https://pan.baidu.com/s/1V0CZpjkeNpZzdCmuSRnwtA
提取碼:2co9

[root@server2 ~]# tar zxf apache-tomcat-7.0.37.tar.gz -C /usr/local/

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

[root@server2 local]# ln -s apache-tomcat-7.0.37/ tomcat
[root@server2 local]# cd tomcat/
[root@server2 tomcat]# bin/startup.sh       #啓動tomcat服務
[root@server2 tomcat]# cd webapps/ROOT/
[root@server2 ROOT]# vim test.jsp    #寫一個jsp網頁文件
server2 time is <%=new java.util.Date() %>      #表示顯示當前時間,在瀏覽器上每刷新一下變一次

#將java和tomcat複製一份到server3上去:

cd /usr/local
scp -r java/ tomcat/ root@server3:/usr/local/

server3:

vim /etc/profile
export JAVA_HOME=/usr/local/java
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$PATH:SJAVA_HOME/bin

 

source /etc/profile
cd /usr/local/tomcat
bin/startup.sh
cd webapps/ROOT/
vim test.jsp
server3 time is <%=new java.util.Date() %>

memcache交叉互備

server1:

#重新編譯nginx,增長sticky模塊:

連接:https://pan.baidu.com/s/15VIYlem8XURIQlV_zhn_AQ
提取碼:solc

[root@server1 ~]# tar zxf nginx-sticky-module-ng.tar.gz

[root@server1 ~]# cd nginx-1.10.1

[root@server1 nginx-1.10.1]# make clean   #清除以前編譯殘留的Makefile文件

[root@server1 nginx-1.10.1]# ./configure --prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_stub_status_module --with-file-aio --with-threads --user=nginx --group=nginx --add-module=/root/nginx-sticky-module-ng
[root@server1 nginx-1.10.1]# make && make install
[root@server1 nginx-1.10.1]# cd /usr/local/lnmp/nginx/
[root@server1 nginx]# vim conf/nginx.conf
 17 http {
 18
 19     upstream tomcat {
 20     sticky;
 21     server 172.25.254.2:8080;
 22     server 172.25.254.3:8080;
 23     }
 24
 25     include       mime.types;
 26     default_type  application/octet-stream;
 27
 

 67         location ~ \.jsp$ {
 68             proxy_pass   http://tomcat;
 69         }
[root@server1 nginx]# /etc/init.d/php-fpm reload
[root@server1 nginx]# nginx    #在安裝openresty的時候已經停了nginx,所以這裏直接開啓nginx便可
server2:

#寫一個jsp頁面

[root@server2 local]# cd /usr/local/tomcat/webapps/ROOT/
[root@server2 ROOT]# vim test.jsp
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.util.*" %>
<html><head><title>Cluster App Test</title></head>
<body>
Server Info:
<%
out.println(request.getLocalAddr() + " : " + request.getLocalPort()+"<br>");%>
<%
out.println("<br> ID " + session.getId()+"<br>");
String dataName = request.getParameter("dataName");
if (dataName != null && dataName.length() > 0) {
String dataValue = request.getParameter("dataValue");
session.setAttribute(dataName, dataValue);
}
out.print("<b>Session list</b>");
Enumeration e = session.getAttributeNames();
while (e.hasMoreElements()) {
String name = (String)e.nextElement();
String value = session.getAttribute(name).toString();
out.println( name + " = " + value+"<br>");
System.out.println( name + " = " + value);
}
%>
<form action="test.jsp" method="POST">
name:<input type=text size=20 name="dataName">
<br>
key:<input type=text size=20 name="dataValue">
<br>
<input type=submit>
</form>
</body>
</html>

#server3與server2保持一致:

[root@server2 ROOT]# scp test.jsp server3:/usr/local/tomcat/webapps/ROOT/

#server2和server3上增長交叉備份模組:

連接:https://pan.baidu.com/s/1BHQoxDP5rqA_CQorME4XaQ
提取碼:etc9

#這些jar文件就是java的memcache交叉備份的模塊:
asm-3.2.jar                              minlog-1.2.jar
kryo-1.04.jar                            msm-kryo-serializer-1.6.3.jar
kryo-serializers-0.10.jar                reflectasm-1.01.jar
memcached-session-manager-1.6.3.jar      spymemcached-2.7.3.jar
memcached-session-manager-tc7-1.6.3.jar

#將他們放到server2和server3的/usr/local/tomcat/lib/目錄下


server2|3:
vim /usr/local/tomcat/conf/context.xml  #直接將下面這段放到19行<Context>下面便可,注意要刪除中文註釋以及註釋前的兩個空格:

             ...
 <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
 memcachedNodes="n1:172.25.2.2:11211,n2:172.25.2.3:11211"
 failoverNodes="n1"    #故障轉移節點,在server3上是n2
 requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
 transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
 />
    ...

/etc/init.d/memcached start
cd /usr/local/tomcat

bin/startup.sh

測試:

當客戶端訪問172.25.254.1(server1)時,會自動分配給server2或者server3(基於緩存的)。當分配給server2上的tomcat時,關閉server2服務(bin/shutdown.sh),會自動取server2在server3主機上備份的session,使用戶操做不消失

相關文章
相關標籤/搜索