nginx负载均衡搭建
来源:互联网 发布:lb网络用语 编辑:程序博客网 时间:2024/05/17 11:36
下载相关软件:
nginx-1.7.6.tar.gz:https://pan.baidu.com/s/1o8k5aNw
pcre-8.36.tar.gz:https://pan.baidu.com/s/1miNOEwS
zlib-1.2.8.tar.gz:https://pan.baidu.com/s/1cqZdpk
软件安装
第一步:安装pcre
将安装包上传到服务器/home下。执行命令
tar -zxvf pcre-8.36.tar.gz
解压安装包。
cd /home/pcre-8.36
./configure
make && make install
安装pcre完成。
第二步:安装zlib
将安装包上传到服务器/home下。执行命令
tar -zxvfzlib-1.2.8.tar.gz
解压安装包。
cd /home/zlib-1.2.8
./configure
make && make install
安装zlib完成。
第三步:安装nginx
zlib-1.2.8.tar.gz
将安装包上传到服务器/home下。执行命令
tar -zxvf nginx-1.7.6.tar.gz
解压安装包。
cd /home/nginx-1.7.6
./configure --prefix=/home/nginx --with-pcre=/home/pcre-8.36 --with-zlib=/home/zlib-1.2.8
make && make install
安装nginx完成。
配置nginx
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
use epoll;#linux下性能最好的io模式
worker_connections 1024;#单个处理的最大连接数
}
#include 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 logs/access.log main;
sendfile off;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
upstream ws{
server 10.132.28.116:8080;
server 10.128.115.5:8080;
}
ip_hash;#按ip做负载分配
server 10.132.28.116:8080;
server 10.128.115.5:8080;
}
listen 8080;
server_name 10.132.28.116;
#charset koi8-r;
#access_log logs/host.access.log main;
proxy_pass http://web; #指定代理的协议和负载id
proxy_redirect off ;#代理重定向
proxy_set_header Host $host:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
启动nginx
./nginx -t -c /home/nginx/conf/nginx.conf
配置文件无问题,启动nginxnginx: [error]invalid PID number "" in"/usr/local/var/run/nginx/nginx.pid"
解决办法:./nginx -c /home/nginx/conf/nginx.confnginx关闭:
./nginx -s stop
或者
ps -ef |grep nginx查询id直接kill
- nginx搭建负载均衡
- nginx 负载均衡搭建
- nginx负载均衡搭建
- 搭建nginx负载均衡
- 搭建nginx 负载均衡
- 搭建nginx的负载均衡
- nginx+tomcat负载均衡搭建
- nginx服务器搭建负载均衡
- Nginx+Tomcat搭建负载均衡
- windows nginx -- 搭建 负载均衡
- openfire+nginx搭建负载均衡
- Nginx+Tomcat搭建负载均衡
- Nginx+Tomcat搭建负载均衡
- Nginx负载均衡搭建胜过Apache十倍?
- Nginx负载均衡搭建胜过Apache十倍?
- Nginx负载均衡纯文本搭建
- Mac 搭建nginx+tomcat 实现负载均衡
- windows利用Nginx搭建网站负载均衡
- golang fork 系统资源共享可行性验证
- 对测试人员或开发人员来说相互沟通有多重要?
- leetcode-300-Longest Increasing Subsequence 动态规划
- JQuery在XSS攻击中的表现
- 算法练习题——坐出租车
- nginx负载均衡搭建
- 001 Gradle For Android Training
- FlipGame循环解法(此方法未能体现bfs精髓,有冗余之处)
- MemoryStream
- MySQL优化—工欲善其事,必先利其器之EXPLAIN
- Linux 路由表和静态路由
- JS两种function声明的区别
- H5\web轻应用,限制手机系统字体大小对应用的影响方法
- Spring 事物机制总结