背景:
阅读新闻
Nginx+Keepalived主主负载均衡服务器
[日期:2012-09-16] 来源:Linux社区 作者:yijiaxin [字体:]
Nginx+keepalived主主负载均衡服务器
测试实验环境:
主Nginx之一:192.168.11.27
主Nginx之二:192.168.11.28
Web服务器一:192.168.11.37
Web服务器二:192.168.11.38
VIP地址一:192.168.11.208
VIP地址二:192.168.11.209
环境:
以下环境均使用的是CentOS 5.7 x86_64位系统
[root@localhost ~]# lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 5.7 (Final)
Release: 5.7
Codename: Final
[root@localhost ~]# uname -a
Linux localhost 2.6.18-274.el5 #1 SMP Fri Jul 22 04:43:29 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
安装nginx负载均衡服务器
#添加运行nginx的用户和组www
groupadd www
useradd -g www www
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.8.tar.gz
tar zxvf pcre-7.8.tar.gz
cd pcre-7.8/
./configure
make && make install
wget
tar zxvf nginx-0.7.51.tar.gz
cd nginx-0.7.51/
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
配置nginx负载均衡器的配置文件vim /usr/local/nginx/conf/nginx.conf,此篇文章仅仅只是我的某项目的配置文档,纯80转发;
主Nginx之一:192.168.11.27
主Nginx之二:192.168.11.28 均需要安装,相同即可
[root@localhost conf]# vim /usr/local/nginx/conf/nginx.conf
user www www;
worker_processes 8;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-Javascript text/css application/xml;
gzip_vary on;
upstream backend
{
ip_hash;
server 192.168.11.37:80;
server 192.168.11.38:80;
}
server {
listen 80;
server_name ;
location / {
root /var/www/html ;
index index.php index.htm index.html;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass ;
}
location /nginx {
access_log off;
auth_basic "NginxStatus";
#auth_basic_user_file /usr/local/nginx/htpasswd;
}
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log /usr/local/nginx/logs/access.log access;
}
}
linuxidc配置文件 /usr/local/nginx/sbin/nginx -t
启动 /usr/local/nginx/sbin/nginx
Pure-FTPd虚拟用户的配置及基于MySQL的虚拟用户配置详解
相关资讯 负载均衡
本文评论 查看全部评论 (0)
尊重网上道德,遵守中华人民共和国的各项有关法律法规 承担一切因您的行为而直接或间接导致的民事或刑事法律责任 本站管理人员有权保留或删除其管辖留言中的任意内容 本站有权在网站内转载或引用您的评论 参与本评论即表明您已经阅读并接受上述条款
评论声明
最新资讯