ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

使用nginx 代理oracle服务  

2021-03-17 15:29:07  阅读:101  来源: 互联网

标签:logs 代理 192.168 nginx error oracle log


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  

标签:logs,代理,192.168,nginx,error,oracle,log
来源: https://blog.csdn.net/u014265442/article/details/114932253

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有