lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache

目录

    • 一、nginx实现负载均衡
    • 二、Nginx的平滑升级
    • 三、添加sticky模块
    • 四、Nginx配置
      • 自动索引
      • 日志轮询
      • 站点目录和文件的限制
      • 中文乱码
      • 防止域名恶意解析到服务器IP&重定向
      • 80端口定向到443端口
    • 五、Nginx限流
    • 六、goccess日志可视化
    • 七、tomcat结合memcache


一、nginx实现负载均衡

1 2、3台机子安装httpd服务,并为实验方便写好易区分的测试页
yum install httpd -y
systemctl enable --now httpd
echo server2 > /var/www/html/index.html
echo server3 > /var/www/html/index.html

events {
    use epoll;
    worker_connections 65535;
}
http {
     upstream westos {
     server 172.25.56.12:80;
     server 172.25.56.13:80;
     }
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

....

        #location / {
        #    root   html;
        #    index  index.php index.html index.htm;
        #
        #}
        location / {
             proxy_pass http://westos;
        }

lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第1张图片

lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第2张图片
nginx -t
nginx

访问测试:
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第3张图片

二、Nginx的平滑升级

备份源程序:

[root@server1 nginx-1.19.1]# cd /usr/local/nginx/sbin/
[root@server1 sbin]# ls
nginx
[root@server1 sbin]# mv nginx nginx.old
[root@server1 sbin]# ls
nginx.old

拷贝新程序:

[root@server1 ~]# cd nginx-1.19.1/
[root@server1 nginx-1.19.1]# cd objs/
[root@server1 objs]# ls
autoconf.err  nginx    ngx_auto_config.h   ngx_modules.c  src
Makefile      nginx.8  ngx_auto_headers.h  ngx_modules.o
[root@server1 objs]# cp -f nginx /usr/local/nginx/sbin/
[root@server1 objs]# cd /usr/local/nginx/sbin/
[root@server1 sbin]# ls
nginx  nginx.old
[root@server1 sbin]# ./nginx -v
nginx version: nginx/1.19.1
[root@server1 sbin]# ./nginx.old -v
nginx version: nginx/1.18.0
[root@server1 sbin]# ps ax | grep nginx
 3191 ?        Ss     0:00 nginx: master process /usr/local/nginx/sbin/nginx
 3192 ?        S      0:00 nginx: worker process
 6223 pts/0    S+     0:00 grep --color=auto nginx

lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第4张图片

[root@server1 sbin]# ps ax | grep nginx
 3191 ?        Ss     0:00 nginx: master process /usr/local/nginx/sbin/nginx
 3192 ?        S      0:00 nginx: worker process
 6231 pts/0    S+     0:00 grep --color=auto nginx
[root@server1 sbin]# kill -USR2  3191 
[root@server1 sbin]# ps ax | grep nginx
 3191 ?        Ss     0:00 nginx: master process /usr/local/nginx/sbin/nginx
 3192 ?        S      0:00 nginx: worker process
 6232 ?        S      0:00 nginx: master process /usr/local/nginx/sbin/nginx
 6233 ?        S      0:00 nginx: worker process
 6235 pts/0    S+     0:00 grep --color=auto nginx
 关闭原woker进程但保留主进程:为了回退
[root@server1 sbin]# kill -WINCH  3191
[root@server1 sbin]# ps ax | grep nginx
 3191 ?        Ss     0:00 nginx: master process /usr/local/nginx/sbin/nginx
 6232 ?        S      0:00 nginx: master process /usr/local/nginx/sbin/nginx
 6233 ?        S      0:00 nginx: worker process
 6237 pts/0    R+     0:00 grep --color=auto nginx

lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第5张图片

lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第6张图片
版本回退:

[root@server1 ~]# cd /usr/local/nginx/sbin/
[root@server1 sbin]# ls
nginx  nginx.old
[root@server1 sbin]# mv nginx nginx.new
[root@server1 sbin]# mv nginx.old nginx
[root@server1 sbin]# ls
nginx  nginx.new
[root@server1 sbin]# ps ax | grep nginx
 3191 ?        Ss     0:00 nginx: master process /usr/local/nginx/sbin/nginx
 6232 ?        S      0:00 nginx: master process /usr/local/nginx/sbin/nginx
 6233 ?        S      0:00 nginx: worker process
 6266 pts/0    S+     0:00 grep --color=auto nginx
[root@server1 sbin]# kill -HUP  3191
[root@server1 sbin]# ps ax | grep nginx
 3191 ?        Ss     0:00 nginx: master process /usr/local/nginx/sbin/nginx
 6232 ?        S      0:00 nginx: master process /usr/local/nginx/sbin/nginx
 6233 ?        S      0:00 nginx: worker process
 6267 ?        S      0:00 nginx: worker process
 6269 pts/0    S+     0:00 grep --color=auto nginx
[root@server1 sbin]# kill -WINCH 6232
[root@server1 sbin]# ps ax | grep nginx
 3191 ?        Ss     0:00 nginx: master process /usr/local/nginx/sbin/nginx
 6232 ?        S      0:00 nginx: master process /usr/local/nginx/sbin/nginx
 6267 ?        S      0:00 nginx: worker process
 6271 pts/0    S+     0:00 grep --color=auto nginx

lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第7张图片
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第8张图片

三、添加sticky模块

[root@server1 ~]# ls
 nginx-goodies-nginx-sticky-module-ng-08a395c66e42
goaccess-1.4                         nginx-goodies-nginx-sticky-module-ng-08a395c66e42.zip nginx-1.18.0 
[root@server1 ~]# cd nginx-1.18.0/
[root@server1 nginx-1.18.0]# ls
[root@server1 nginx-1.18.0]#  ./configure  --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --add-module=/root/nginx-goodies-nginx-sticky-module-ng-08a395c66e42
 [root@server1 nginx-1.18.0]# make
[root@server1 nginx-1.18.0]# cd objs/
[root@server1 objs]# ls
addon         Makefile  nginx.8            ngx_auto_headers.h  ngx_modules.o
autoconf.err  nginx     ngx_auto_config.h  ngx_modules.c       src
[root@server1 objs]# cp nginx /usr/local/nginx/sbin/
[root@server1 objs]# nginx -v
nginx version: nginx/1.18.0
[root@server1 conf]# vim nginx.conf
http {
     upstream westos {
     sticky;
     server 172.25.56.12:80;
     server 172.25.56.13:80;
     }
[root@server1 conf]# 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


语法检测没问题就表明添加成功!

四、Nginx配置

[root@server1 conf]# cat nginx.conf
#user  nobody;
user  nginx nginx;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    use epoll;
    worker_connections 65535;
}


http {
     upstream westos {
     server 172.25.56.12:80;
     server 172.25.56.13:80;
     }
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.html;
        
        }
#        location / {
#             proxy_pass http://westos;
#        }
#
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi.conf;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    server {
        listen       443 ssl;
        server_name  localhost;

        ssl_certificate      cert.pem;
        ssl_certificate_key  cert.pem;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        location / {
            root   html;
            index  index.html index.htm;
        }
    }


server {
        listen 80;
        server_name     www.westos.org;

        location / {
        proxy_pass http://westos;
        }
}

server {
        listen 80;
        server_name     www.linux.org;

        location / {
                root  /web1;
                index   index.html;
        }
}
}


[root@server1 certs]# pwd
/etc/pki/tls/certs
[root@server1 certs]# make cert.pem
umask 77 ; \
PEM1=`/bin/mktemp /tmp/openssl.XXXXXX` ; \
PEM2=`/bin/mktemp /tmp/openssl.XXXXXX` ; \
/usr/bin/openssl req -utf8 -newkey rsa:2048 -keyout $PEM1 -nodes -x509 -days 365 -out $PEM2  ; \
cat $PEM1 >  cert.pem ; \
echo ""    >> cert.pem ; \
cat $PEM2 >> cert.pem ; \
rm -f $PEM1 $PEM2
Generating a 2048 bit RSA private key
.........................................................................................................................+++
..........................................................................................................................+++
writing new private key to '/tmp/openssl.b12t28'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:cn
State or Province Name (full name) []:shaanxi
Locality Name (eg, city) [Default City]:xi'an
Organization Name (eg, company) [Default Company Ltd]:westos
Organizational Unit Name (eg, section) []:linux
Common Name (eg, your name or your server's hostname) []:server1
Email Address []:[email protected]
[root@server1 certs]# ls
ca-bundle.crt  ca-bundle.trust.crt  cert.pem  make-dummy-cert  Makefile  renew-dummy-cert
[root@server1 certs]# mv cert.pem /usr/local/nginx/conf/
[root@server1 conf]# mkdir /web1
[root@server1 conf]# cd /web1/
[root@server1 web1]# echo web1 > index.html
[root@server1 conf]#nginx -t
[root@server1 conf]#nginx -s reload

访问不同域名有不同测试页
访问Ip为源测试页
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第9张图片
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第10张图片

自动索引

lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第11张图片
nginx -s reload
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第12张图片

lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第13张图片

 location ~ .*\.(gif|jpg|png)$ {
           expires 365d;
           root html;
         }

nginx -s reload
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第14张图片

日志轮询

[root@server1 logs]# date +%F -d -1day
2021-04-02
[root@server1 logs]# ls
access.log  error.log  nginx.pid  nginx.pid.oldbin
[root@server1 logs]# cd /opt/
[root@server1 opt]# vim nginx_log.sh
[root@server1 opt]# chmod +x  nginx_log.sh
[root@server1 opt]# ./nginx_log.sh 
[root@server1 opt]# cd /usr/local/nginx/logs/
[root@server1 logs]# ls
access_2021-04-03.log  access.log  error.log  nginx.pid  nginx.pid.oldbin
[root@server1 opt]# cat nginx_log.sh 
#!/bin/bash
cd /usr/local/nginx/logs && mv access.log access_$(date +%F -d -1day).log
kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`

禁用不必要的日志采集,减少内存消耗
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第15张图片

站点目录和文件的限制

lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第16张图片
此时无法访问
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第17张图片

中文乱码

lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第18张图片
出现乱码现象:
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第19张图片
如何修复?
加入以下参数
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第20张图片
nginx -s reload
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第21张图片

防止域名恶意解析到服务器IP&重定向

lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第22张图片
nginx -s reload
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第23张图片
重定向:
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第24张图片
rewrite ^(.*) http://www.westos.org permanent;
nginx -s reload

访问被重定向到指定路径
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第25张图片

80端口定向到443端口

lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第26张图片
rewrite ^/(.*)$ https://www.westos.org/$1 permanent;
nginx -s reload
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第27张图片

五、Nginx限流

官方文档查看!
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第28张图片
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第29张图片

[root@server1 html]# mkdir download
[root@server1 html]# ls
50x.html  download  example.php  index.html  index.php  memcache.php  phpadmin  test.html
[root@server1 html]# cd download/
lftp 172.25.254.250:/pub/docs> get vim.jpg 
453575 bytes transferred                    
[root@server1 download]# ls
vim.jpg
[root@server1 download]# du - h *
444	vim.jpg

lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第30张图片
限制带宽:
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第31张图片
444M 限速50K,大约8秒
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第32张图片
限制单位时间内请求次数:
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第33张图片
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第34张图片
压测:一秒只处理一次请求,其他9次被拒绝
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第35张图片
可处理5个
When the zone is full, excessive requests will be queued (burst), the size of this queue is 5 requests. Request processing in the queue is delayed in such a way that the overall rate is not greater than specified. Requests above the burst limit will be rejected with the 503 error.
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第36张图片

nginx -s reload

进行排队,处理一个请求要1秒
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第37张图片
不等待,只处理5个
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第38张图片
压测:
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第39张图片

六、goccess日志可视化

[root@server1 ~]#yum install GeoIP-devel-1.5.0-13.el7.x86_64.rpm 
[root@server1 ~]# cd goaccess-1.4/
[root@server1 goaccess-1.4]# ls
ABOUT-NLS   config        configure.ac  install-sh   NEWS       TODO
aclocal.m4  config.guess  COPYING       m4           po
AUTHORS     config.rpath  depcomp       Makefile.am  README
ChangeLog   config.sub    goaccess.1    Makefile.in  resources
compile     configure     INSTALL       missing      src
[root@server1 goaccess-1.4]# ./configure --enable-utf8 --enable-geoip=legacy
[root@server1 goaccess-1.4]# make && make install
[root@server1 logs]# goaccess access.log -o /usr/local/nginx/html/report.html --log-format=COMBINED --real-time-html

访问测试:
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第40张图片

七、tomcat结合memcache

2、3上均部署

[root@server2 ~]# ls
apache-tomcat-7.0.37.tar.gz  jdk-8u121-linux-x64.rpm
[root@server2 ~]# rpm -ivh  jdk-8u121-linux-x64.rpm 
[root@server2 ~]# tar zxf apache-tomcat-7.0.37.tar.gz 
[root@server2 ~]# mv apache-tomcat-7.0.37 /usr/local/tomcat
[root@server2 ~]# cd /usr/local/tomcat
[root@server2 tomcat]# ls
bin   lib      logs    RELEASE-NOTES  temp     work
conf  LICENSE  NOTICE  RUNNING.txt    webapps
[root@server2 tomcat]# bin/startup.sh 
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@server2 tomcat]# netstat -antlupe | grep :8080
tcp6       0      0 :::8080                 :::*                    LISTEN      0          36876      4172/java      

lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第41张图片
server3上类似

我们想实现client–>nginx:80–>*.jsp–>tomcat
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第42张图片

lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第43张图片
nginx -t
nginx -s reload
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第44张图片

[root@server2 ROOT]# ls | grep test
test.jsp
[root@server2 ROOT]# scp test.jsp server3:/usr/local/tomcat/webapps/ROOT/
root@server3's password: 
test.jsp                                      100%  968     1.1MB/s   00:00   

访问测试,默认是轮询的方式 12、13切换
每次递交原本信息会被覆盖
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第45张图片
修复:
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第46张图片
nginx -t
nginx -s reload
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第47张图片
Session:

[root@server2 ~]# ls
apache-tomcat-7.0.37.tar.gz  jar  jdk-8u121-linux-x64.rpm
[root@server2 ~]# cd jar/
[root@server2 jar]# ls
asm-3.2.jar                              memcached-session-manager-tc7-1.6.3.jar
kryo-1.04.jar                            minlog-1.2.jar
kryo-serializers-0.10.jar                msm-kryo-serializer-1.6.3.jar
memcached-session-manager-1.6.3.jar      reflectasm-1.01.jar
memcached-session-manager-tc6-1.6.3.jar  spymemcached-2.7.3.jar
[root@server2 jar]# rm -fr memcached-session-manager-1.6.3.jar 
[root@server2 jar]# cp * /usr/local/tomcat/lib/
[root@server2 jar]# cd /usr/local/tomcat/lib/
[root@server2 lib]# cd ..
[root@server2 tomcat]# bin/startup.sh 
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@server2 tomcat]# netstat -antlupe
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      0          23735      3174/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      0          24669      3351/master         
tcp        0      0 172.25.56.12:22         172.25.56.105:51836     ESTABLISHED 0     
[root@server3 ~]# cd /usr/local/tomcat/lib/
[root@server3 lib]# ls
annotations-api.jar  jsp-api.jar                              tomcat-api.jar
asm-3.2.jar          kryo-1.04.jar                            tomcat-coyote.jar
catalina-ant.jar     kryo-serializers-0.10.jar                tomcat-dbcp.jar
catalina-ha.jar      memcached-session-manager-tc6-1.6.3.jar  tomcat-i18n-es.jar
catalina.jar         memcached-session-manager-tc7-1.6.3.jar  tomcat-i18n-fr.jar
catalina-tribes.jar  minlog-1.2.jar                           tomcat-i18n-ja.jar
ecj-4.2.1.jar        msm-kryo-serializer-1.6.3.jar            tomcat-jdbc.jar
el-api.jar           reflectasm-1.01.jar                      tomcat-util.jar
jasper-el.jar        servlet-api.jar
jasper.jar           spymemcached-2.7.3.jar
[root@server3 lib]# cd ..
[root@server3 tomcat]# bin/shutdown.sh 
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

[root@server2 conf]# vim context.xml
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第48张图片

<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:172.25.56.12:11211,n2:172.25.56.13:11211"
failoverNodes="n1"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
/>

[root@server2 conf]# yum install -y memcached
[root@server2 conf]# systemctl enable --now memcached.service

3上相同:
lamp架构--Nginx配置管理、负载均衡、平滑升级及限流;日志可视化&tomcat结合memcache_第49张图片

[root@server3 conf]# yum install memcached -y
[root@server3 tomcat]# systemctl enable --now memcached.service 
[root@server3 tomcat]# bin/startup.sh 
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

你可能感兴趣的:(企业实战,乱码,nginx,linux,运维)