初识nginx负载均衡
来源:互联网 发布:js正则获取标签属性值 编辑:程序博客网 时间:2024/06/06 09:26
环境:
主机三台,系统centos,一个为nginx服务器(1)180.150.184.156,另外两台发布tomcat服务(2)180.150.184.202(3)180.150.184.203。
(1)
nginx安装:
yum -y install nginx
修改nginx配置文件nginx.conf
vim /etc/nginx/nginx.conf
user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
use epoll;
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# Load config files from the /etc/nginx/conf.d directory
# The default server is in conf.d/default.conf
include /etc/nginx/conf.d/*.conf;
upstream 180.150.184.156 {
server 180.150.184.202:8080 weight=1;
server 180.150.184.203:8080 weight=6;
# server 180.150.184.204:8080 weight=3;
}
server {
listen 80;
server_name 180.150.184.156;
location / {
proxy_pass http://180.150.184.156;
}
}
}
(2)(3)分别安装jdk tomcat。分别发布简单的rest接口作为测试使用,接口地址:
http://180.150.184.202:8080/historylife/rest/index;
http://180.150.184.203:8080/historylife/rest/index
启动tomcat。
启动nginx: service nginx start.
访问:http://180.150.184.156:80/historylife/rest/index 按照轮询算法,将按照1:6的比例分别转发请求到(2)(3)服务器。
- 初识nginx负载均衡
- 初识Nginx负载均衡
- 初识Nginx(三):反向代理和负载均衡
- nginx负载均衡【nginx】
- nginx配置负载负载均衡
- nginx负载均衡
- Nginx负载均衡
- Nginx 负载均衡 简介
- nginx 负载均衡配置
- Nginx负载均衡
- nginx 负载均衡测试
- Nginx实现负载均衡
- Nginx负载均衡
- 解析Nginx负载均衡
- Nginx负载均衡
- nginx 实现负载均衡
- 【NGINX】负载均衡(upstream)
- nginx 负载均衡
- Qt下载地址:http://download.qt.io/
- 获取手机照片
- 浅谈服务器架构之MMORPG端游
- Java虚拟机(JVM)参数配置说明
- C# ListView用法详解
- 初识nginx负载均衡
- java 中反射机制的总结
- sql语句中判断 case when的用法
- 工厂模式、构造函数模式、原型模式范例
- PHP与.NET一致的DES(CBC)算法
- 终端模拟软件xshell设置编码方式UTF-8
- vc6.0中warning C4786:identifier was truncated to '255' characters in the debug information的原因及解决办法
- 自动升级系统OAUS
- Python从入门到精通 目录树