nginx反向代理oracle+负载均衡配置
通过TCP协议访问oracle
软件基本信息
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
#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;
}
}
本文为原创文章,想了解更多信息欢迎访问我的博客
https://www.cnblogs.com/ihappycat/