nginx负载均衡postgresql步骤

本文详细介绍了如何从零开始安装 Nginx 1.13.7,并配置其与 OpenSSL 1.1.0e、PCRE 8.40 和 zlib 1.2.11 的依赖。此外,还提供了如何配置 Nginx 使用 stream 模块来实现负载均衡的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.

安装之前的准备

安装gcc

sudo apt-get  build-dep  gcc 

安装openssl1.1.0e

wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz

安装pcre8.40

wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz

安装zlib1.2.11

wget https://downloads.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz

2

安装

Nginx1.13.7

wget http://nginx.org/download/nginx-1.13.7.tar.gz

执行下面命令进行编译

./configure --prefix=/usr/local/nginx --with-stream --with-stream_ssl_module \

--sbin-path=/home/nginx/nginx \

--conf-path=/home/nginx/nginx.conf \

--pid-path=/home/nginx/nginx.pid \

--with-http_ssl_module \

--with-pcre=/home/pcre-8.40 \

--with-zlib=/home/zlib-1.2.11 \

--with-openssl=/home/openssl-1.1.0e


安装注意事项

stream模块默认没有编译到nginx, 编译nginx时候 ./configure –with-stream 即可


3.

stream{
  upstream pg{
    server  192.168.0.184:5432;
    server  192.168.0.185:5432;
   }
server{
    listen 1111;
    proxy_pass pg;
   }

}

4.

通过虚拟机部署三台Linux服务,post1部署nginx环境,在postgres1postgres2部署postgres-xl,实现post1负载postgres1postgres2


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值