• tomcat项目集群部署


    单节点改多节点以三个节点为例:

    (1)nginx配置

    (2)使用redis存储用户session完成session共享

    (3)基于redis的发布订阅模式实现的websocket的集群部署

    1,nginx配置

    worker_processes  1;
    
    events {
        worker_connections  1024;
    }
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
        send_timeout 25;
         
        sendfile        on;
        keepalive_timeout  65;
        fastcgi_connect_timeout 75;
        fastcgi_read_timeout 600;
        fastcgi_send_timeout 600;
        
        map $http_upgrade $connection_upgrade {
            default upgrade;
            '' close;
        }
        
        upstream wygyxt {
            server 192.168.11.3:8084;
            server 192.168.11.3:8082;
            server 192.168.11.3:8083;
        }
        
        server{
            listen 7778;
            server_name localhost;
            
            location / {
                proxy_pass   http://wygyxt/;
                include  uwsgi_params;
                proxy_set_header Host $host;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection $connection_upgrade;
            }
        }
        
    }

    测试的三个服务分别为:

    192.168.11.3:8084;
    192.168.11.3:8082;
    192.168.11.3:8083;
    每个服务都是单独可以访问的,使用nginx代理后通过代理地址
    192.168.11.3:7778 访问

    这个配置涉及到websocket的代理:
    (1)添加
        map $http_upgrade $connection_upgrade {
            default upgrade;
            '' close;
        }

    (2)在server中添加(三部分都不能少)

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;

    (3)postman测试

     

    必须是post请求;需要在header中设置Content-Type:Content-Type:text/xml;charset=utf-8;参数选择raw-xml,参数体为xml格式.

    (2)redis缓存用户信息

    (3)发布订阅模式解决websocket集群模式

     
  • 相关阅读:
    set的使用
    this.$watch(),this.$set(),this.$nextTick()=>{})
    web 错误代码解析
    samba 问题解决
    Linux postfix配置方法
    Linux rhcsa认证考试试题模拟
    Linux 使用nmcli配置网络
    Linux 链路聚合
    Linux ISCSI服务配置
    Linux Apache配置https访问
  • 原文地址:https://www.cnblogs.com/excellencesy/p/14539389.html
Copyright © 2020-2023  润新知