揭秘企业级web负载均衡完美架构(转载)
- #添加运行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 http://sysoev.ru/nginx/nginx-0.7.51.tar.gz
- tar zxvf nginx-0.7.51.tar.gz
- cd nginx-0.7.51/
- ./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module
- make && make install
- user www www;
- worker_processes 8;
- pid /usr/local/nginx/logs/nginx.pid;
- worker_rlimit_nofile 65535;
- events
- {
- use epoll;
- worker_connections 65535;
- }
- 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
- {
- server 192.168.1.102:80;
- server 192.168.1.103:80;
- server 192.168.1.105:80;
- }
- server {
- listen 80;
- server_name www.yuhongchun027.com;
- location / {
- root /var/www ;
- index index.jsp 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 http://backend;
- }
- location /nginx {
- access_log on;
- 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 /var/log/access.log access;
- }
- }
- wget http://www.keepalived.org/software/keepalived-1.1.15.tar.gz
- #tar zxvf keepalived-1.1.15.tar.gz
- #cd keepalived-1.1.15
- #./configure --prefix=/usr/local/keepalived
- #make
- #make install
- #cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
- #cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
- #cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
- #mkdir /etc/keepalived
- #cd /etc/keepalived/
- vim keepalived.conf
- ! Configuration File for keepalived
- global_defs {
- notification_email {
- yuhongchun027@163.com
- }
- notification_email_from keepalived@chtopnet.com
- smtp_server 127.0.0.1
- smtp_connect_timeout 30
- router_id LVS_DEVEL
- }
- vrrp_instance VI_1 {
- state MASTER
- interface eth0
- virtual_router_id 51
- mcast_src_ip 192.168.0.154 <==主nginx的IP地址
- priority 100
- advert_int 1
- authentication {
- auth_type PASS
- auth_pass chtopnet
- }
- virtual_ipaddress {
- 192.168.0.188 <==vip地址
- }
- }
- #service keepalived start
- [root@ltos ~]# tail /var/log/messages
- Oct 6 03:25:03 ltos avahi-daemon[2306]: Registering new address record for 192.168.0.188 on eth0.
- Oct 6 03:25:03 ltos avahi-daemon[2306]: Registering new address record for 192.168.0.154 on eth0.
- Oct 6 03:25:03 ltos avahi-daemon[2306]: Registering HINFO record with values 'I686'/'LINUX'.
- Oct 6 03:25:23 ltos avahi-daemon[2306]: Withdrawing address record for fe80::20c:29ff:feb9:eeab on eth0.
- Oct 6 03:25:23 ltos avahi-daemon[2306]: Withdrawing address record for 192.168.0.154 on eth0.
- Oct 6 03:25:23 ltos avahi-daemon[2306]: Host name conflict, retrying with <ltos-31>
- [root@ltos html]# ip addr
- 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
- link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
- inet 127.0.0.1/8 scope host lo
- inet6 ::1/128 scope host
- valid_lft forever preferred_lft forever
- 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
- link/ether 00:0c:29:ba:9b:e7 brd ff:ff:ff:ff:ff:ff
- inet 192.168.0.154/24 brd 192.168.0.255 scope global eth0
- inet 192.168.0.188/32 scope global eth0
- inet6 fe80::20c:29ff:feba:9be7/64 scope link
- valid_lft forever preferred_lft forever
- 3: sit0: <NOARP> mtu 1480 qdisc noop
- link/sit 0.0.0.0 brd 0.0.0.0
- vim /root/nginx_pid.sh
- #!/bin/bash
- while :
- do
- nginxpid=`ps -C nginx --no-header | wc -l`
- if [ $nginxpid -eq 0 ];then
- /usr/local/nginx/sbin/nginx
- sleep 5
- if [ $nginxpid -eq 0 ];then
- /etc/init.d/keepalived stop
- fi
- fi
- sleep 5
- done
转载于:https://blog.51cto.com/dadloveu/656154
揭秘企业级web负载均衡完美架构(转载)相关推荐
- 揭秘企业级web负载均衡完美架构
相信很多朋友对企业级的负载均衡高可用实例非常感兴趣,此篇文章根据成熟的线上环境而写,旨在帮助大家迅速架构一个企业级的负载均衡高可用的web环境. 此系统架构仅映射内网VIP的80及443端口于外网的J ...
- RedHat 7配置keepalived+LVS实现高可用的Web负载均衡
上一篇博文中我们使用keepalived实现了haproxy的高可用,但keepalived问世之初却是为LVS而设计,与LVS高度整合,LVS与haproxy一样也是实现负载均衡,结合keepali ...
- 在Linux下用LVS和Ipvsadm做Web负载均衡
在Linux下用LVS和Ipvsadm做Web负载均衡,如果想对负载均衡有一个全面.宏观上的理解,可以看:服务器负载均衡技术的原理及应用. 一.简介及环境配置 在Linux下用 LVS和Ipvsadm ...
- 基于redhat linux虚拟服务器的web负载均衡集群(piranha+LVS)
基于redhat linux虚拟服务器的web负载均衡集群 硬件环境 分发机 LB1:192.168.0.129 LB2:192.168.0.130 真实节点主机 NODE1:192.168.0.13 ...
- IIS Web负载均衡的几种方式
Web负载均衡的几种实现方式 摘要: 负载均衡(Load Balance)是集群技术(Cluster)的一种应用.负载均衡可以将工作任务分摊到多个处理单元,从而提高并发处理能力.目前最常见的负载均衡应 ...
- Web负载均衡的几种实现方式
摘要: 负载均衡(Load Balance)是集群技术(Cluster)的一种应用.负载均衡可以将工作任务分摊到多个处理单元,从而提高并发处理能力.目前最常见的负载均衡应用是Web负载均衡.根据实现的 ...
- LVS负载均衡群集架构(一):NET模式群集部署
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 一.群集的含义 1.概念 2.问题 3..解决方法 二.集群的分类 1.负载均衡群集:聚合和负载均衡 2.高可用群集(Hig ...
- 企业级Nginx负载均衡与keepalived高可用实战课-老男孩-专题视频课程
企业级Nginx负载均衡与keepalived高可用实战课-2678人已学习 课程介绍 企业级Nginx负载均衡与keepalived高可用实战分享 课程收益 互联网环境最常用 ...
- 高并发系统搭建:web负载均衡
高并发系统搭建:web负载均衡 所谓的负载均衡就是让多个请求尽量均衡的分配到不同的机器上面去 1. HTTP负载均衡 当用户的请求发来之后,web服务器通过修改HTTP响应报头中的Location标记 ...
最新文章
- 创新类编辑推荐:Sequence iBPMS平台
- 红蓝对抗 linux内网渗透
- C++正整数的素数分解的实现算法(附完整源码)
- oracle的catalog,Oracle Rman Catalog的创建方法和备份原理
- android中的资源文件
- 阶段1 语言基础+高级_1-3-Java语言高级_06-File类与IO流_05 IO字符流_7_字符输出流的续写和换行...
- 卷积的发展历程,原理和基于 TensorFlow 的实现
- 在手机上模拟kali系统(bochs)
- 夜深人静写算法(五)- 初等数论
- 颠覆传统股票证券市场的可能是ICO代币(TOKEN)
- 山东航天九通车联网:大数据技术引领为智慧物流赋能
- Adobe Photoshop 输出ICO格式图标文件
- 小米5怎么安android,小米5怎么插卡 小米5手机安装sim卡图文教程
- Android才是游戏开发者的乐土
- C-获得文件大小并动态申请内存屏幕打印文件内容小程序
- Windows的任务管理器怎么显示进程的图标
- R水文包--结果评价_气候变化指数分析
- 入行大数据,为什么一定要有进行大数据培训?
- JULLIAN MURPHY:潇洒的女性,都具有这三个特质
- Python入门级案例练习题分享!