1. Nginx在安装的时候,需要加上一个参数:--with-stream 

    即Nginx安装指令为:./configure --prefix=/u01/app/nginx  --with-stream

    Nginx的安装教程,可参见:https://www.cnblogs.com/Charles-Yuan/articles/9737617.html

 

  2. nginx安装完成后,编辑nginx.conf文件,指令:

    vim  /u01/app/nginx/conf/nginx.conf

    在文件的最下方(位置也可以不是最下方,stream必须和http平级)添加如下内容:

    stream {

      upstream cloudsocket {
        hash $remote_addr consistent;
        server 数据库实际IP:数据库实际端口号 weight=5 max_fails=3 fail_timeout=30s;
      }
      server {
        listen 数据库代理端口号;
        proxy_connect_timeout 10s;
        proxy_timeout 300s;
        proxy_pass cloudsocket;
      }
    }

 

  3. 重启nginx服务器.

 

如有问题,欢迎纠正!!!

如有转载,请标明源处:https://www.cnblogs.com/Charles-Yuan/p/9738023.html 

  

相关文章:

  • 2021-11-28
  • 2022-01-30
  • 2022-02-01
  • 2021-12-30
  • 2021-08-17
  • 2021-11-18
  • 2021-07-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-20
  • 2021-06-10
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案