使用nginx 代理oracle服务  

nginx 代理oracle  


1、文件下载

nginx版本至少1.9的版本,版本太低没有stream这个功能,pcre-3.8.5

安装依赖:openssl、gcc、g++、pcre等

2   编译
   

   pcre安装     ./configure --prefix=/usr/local/pcre2-10.36
  nginx安装      ./configure --prefix=/usr/local/nginx  --with-stream    --with-pcre=/usr/local/pcre2-10.36

make  && make instal

3 配置文件 nginx/nginx.conf

软件基本信息

nginx版本:1.17.4
nginx所在服务器ip:192.168.21.100
oracleA信息:oracle11g,ip:192.168.21.213:1521
oracleB信息:oracle11g,ip:192.168.21.214:1521

反向代理oracle  

nginx/nginx.conf

#user  nobody;
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 {
    worker_connections  1024;
}


stream {    
    
    upstream oracle {   
        server 192.168.21.213:1521 weight=1 max_fails=2 fail_timeout=30s;   #原oracle地址
    }
    
 server {
        listen       3335;# 反向代理后监听的端口,nginx启动后访问192.168.21.100:3335就可以访问到oracleA
        proxy_connect_timeout 1s;
        proxy_timeout 3s;
        proxy_pass oracle;
    }
}

oracle负载均衡

主要用于查询的时候进行负载均衡,oracleA和oracleB两个库内容相关。

#user  nobody;
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 {
    worker_connections  1024;
}


stream {    
    
    upstream oracle {   
        server 192.168.21.213:1521 weight=1 max_fails=2 fail_timeout=30s;   #原oracle地址
        server 192.168.21.214:1521 weight=2 max_fails=2 fail_timeout=30s;
    }
    
 server {
        listen 3335 so_keepalive=on; #so_keepalive,会话保持,防止查询飘走       
        proxy_pass oracle;
    }
}


————————————————
nginx反向代理oracle+负载均衡配置
参考:https://blog.csdn.net/jijiuqiu6646/article/details/78675891
参考  https://www.cnblogs.com/ihappycat/p/11830560.html  

上一篇:4.小程序-路由跳转


下一篇:Nginx系列(6)- nginx: [error] CreateFile() "D:\nginx-1.20.1/logs/nginx.pid" failed (2: The s