keepalive+nginx搭建主从负载服务器

keepalive配置文件 从:

  1. ! Configuration File for keepalived
  2. global_defs {
  3. notification_email {
  4. xuezm@yaoshi.com
  5. }
  6. notification_email_from xuezm@yaoshi.com
  7. smtp_server mail.yaoshi.com
  8. smtp_connect_timeout 30
  9. router_id LVS_DEVEL
  10. }
  11. vrrp_instance VI_1 {
  12. state MASTER
  13. interface eth0
  14. virtual_router_id 51
  15. mcast_src_ip 192.168.11.39
  16. priority 80
  17. advert_int 1
  18. authentication {
  19. auth_type PASS
  20. auth_pass chtopnet
  21. }
  22. virtual_ipaddress {
  23. 192.168.11.208
  24. }
  25. }

keepalive 主:

  1. !Configuration File for keepalived
  2. global_defs {
  3. notification_email {
  4. xuezm@yaoshi.com
  5. }
  6. notification_email_from xuezm@yaoshi.com
  7. smtp_server mail.yaoshi.com
  8. smtp_connect_timeout 30
  9. router_id LVS_DEVEL
  10. }
  11. vrrp_instance VI_1 {
  12. state MASTER
  13. interface eth0
  14. virtual_router_id 51
  15. mcast_src_ip 192.168.11.27
  16. priority 100
  17. advert_int 1
  18. authentication {
  19. auth_type PASS
  20. auth_pass chtopnet
  21. }
  22. virtual_ipaddress {
  23. 192.168.11.208
  24. }
  25. }

nginx配置 :

  1. user  nobody nobody;
  2. worker_processes  1;
  3. #error_log  logs/error.log;
  4. #error_log  logs/error.log  notice;
  5. error_log  logs/error.log  debug;
  6. pid        logs/nginx.pid;
  7. events {
  8. use epoll;
  9. worker_connections  1024;
  10. }
  11. http {
  12. include       mime.types;
  13. default_type  application/octet-stream;
  14. log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  15. '$status $body_bytes_sent "$http_referer" '
  16. '"$http_user_agent" "$http_x_forwarded_for"';
  17. access_log  logs/access.log  main;
  18. sendfile        on;
  19. #tcp_nopush     on;
  20. #keepalive_timeout  0;
  21. keepalive_timeout  65;
  22. gzip  on;
  23. gzip_min_length 1k;
  24. gzip_buffers    6   16k;
  25. gzip_http_version   1.1;
  26. gzip_comp_level 2;
  27. gzip_types  text/plain  application/x-javascript    text/css application/xml;
  28. gzip_vary   on;
  29. #   location / {
  30. #            root   html;
  31. #            index  index.html index.htm;
  32. #        }
  33. error_page  404              /404.html;
  34. upstream www.test.com {
  35. server  192.168.11.37:80;
  36. server  192.168.11.38:80;
  37. }
  38. server
  39. {
  40. listen  80;
  41. server_name www.test.com 192.168.11.208;
  42. index   index.htm  index.html;
  43. #root /web/wwwroot;
  44. location / {
  45. proxy_pass http://www.test.com;
  46. proxy_next_upstream http_500 http_502 http_503 error timeout invalid_header;
  47. proxy_set_header   Host             $host;
  48. proxy_set_header   X-Real-IP        $remote_addr;
  49. proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
  50. include proxy.conf;
  51. }
  52. log_format  blog_test_com  '$remote_addr - $remote_user [$time_local] $request '
  53. '"$status" $body_bytes_sent "$http_referer" '
  54. '"$http_user_agent" "$http_x_forwarded_for"';
  55. access_log logs/blog_test_com;
  56. }
  57. }

proxy.conf 配置

  1. [root@localhost conf]# cat proxy.conf
  2. proxy_redirect  off;
  3. proxy_set_header    Host    $host;
  4. proxy_set_header    X-Real-IP $remote_addr;
  5. proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
  6. client_body_buffer_size 128k;
  7. proxy_connect_timeout 90;
  8. proxy_send_timeout 90;
  9. proxy_read_timeout 90;
  10. proxy_buffer_size   4k;
  11. proxy_buffers 6 32k;
  12. proxy_busy_buffers_size 64k;
  13. proxy_temp_file_write_size 64k;

转载于:https://blog.51cto.com/yijiaxin/844350

keepalive+nginx搭建主从负载服务器相关推荐

  1. Nginx搭建部署Web服务器并与NFS结合搭建负载均衡服务器

    Nginx搭建部署Web服务器并与NFS结合搭建负载均衡服务器 一.搭建NginxWeb服务器     此种方式是用yum安装Nginx,为保证安装成功需在安装之前提前安装epel扩展源.     用 ...

  2. Nginx搭建flv视频点播服务器

    Nginx搭建flv视频点播服务器 前一段时间使用Nginx搭建的多媒体服务器只能在缓冲过的时间区域内拖放, 而不能拖放到未缓冲的地方. 这就带来了一个问题: 如果视频限速的速率很小, 那么客户端观看 ...

  3. 使用 NGINX 搭建 RTMP 流媒体服务器实现直播功能

    使用 NGINX 搭建 RTMP 流媒体服务器实现直播功能 本文介绍了如何使用 Nginx 搭建 RTMP 流媒体服务器,并提供配置文件和前端示例,实现直播功能. 环境 操作系统: Ubuntu 18 ...

  4. nginx搭建静态文件服务器,利用nginx搭建静态资源服务器的方法步骤

    以windows为例,linux其实一样: 搭建静态资源服务器 我电脑上的work文件夹下面有很多图片,我想通过nginx搭建静态资源服务器,通过在地址栏输入ip+port的方式完成目录的映射 找到n ...

  5. 前后端分离项目nginx搭建静态页面服务器cors做后台跨域接收前台请求

    自己在闲暇时间里,无聊的我试着做了一个前后台分离的入门demo.在编写代码前通过查询百度,csdn,博学谷等做了一些准备工作,具体还只是做到前台发送的请求能顺利的发送到后端,时间仓促做的也有不足之处, ...

  6. nginx+keepalived搭建主从负载均衡并迅速切换

    大家都听说过主从服务器或者负载均衡之类的专业术语,作为衡量一个中高级运维工程师的标准,集群和负载是运维工程师必须掌握的技术,然而在一家小公司是根本不会体会到运维的重要性的.首先从理论上讲一下,当用户量 ...

  7. Linux环境下搭建主从DNS服务器

    2017年09月21日 23:33:04 张应明 阅读数 2075 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/zhangym199312/art ...

  8. 使用Nginx搭建前端静态服务器+文件服务器

    大家可能被虚拟主机不太了解,那我们的解释一下,虚拟主机指在一台物理主机服务器上划分出多个磁盘空间,每个磁盘空间都是一个虚拟主机,每台虚拟主机都可以对外提供Web服务,并且互不干扰. 一.Nginx的虚 ...

  9. Windows基于Nginx搭建RTMP流媒体服务器(附带所有组件下载地址及验证方法)

    RTMP服务时常用于直播时提供拉流推流传输数据的一种服务.前段时间由于朋友想搭建一套直播时提供稳定数据传输的服务器,所以就研究了一下如何搭建及使用. 1.下载nginx 首先我们要知道一般nginx不 ...

最新文章

  1. flask secure_filename 不能识别中文名的解决办法
  2. CUBRID学习笔记 1 简介 cubrid教程
  3. mysql err 1118_MySQL ERROR1118报错详解 Row size too large
  4. 【XSY2720】区间第k小 整体二分 可持久化线段树
  5. mysql中的生日应该是什么类型_MySQL中的定点数类型
  6. echarts legend不显示_ECharts地图系列一(定制区域水波纹显示,以及其他区域圆点颜色不统一)...
  7. Redis中struct运用
  8. 计算机组成原理—cpu于主存的连接(例题)
  9. 人脸对齐(九)--SDM算法
  10. label标签 for属性
  11. 部署war包到tomcat根目录
  12. 微会动平台与微云推战略携手赋能企业数字营销推广与业绩增长闭环
  13. 下载代码的两种方式ssh 和 https
  14. JAVA计算机毕业设计劳务外包管理系统(附源码、数据库)
  15. 数据库 ER图、关系模式相互转换 关系代数表达式 查询树,优化查询树 SQL题目
  16. retinex(SSR,MSR,MSRCR)的优缺点
  17. 用python绘制叠加等边三角形_python 叠加等边三角形的绘制
  18. leelen可视对讲怎么接线_电子门铃怎么安装 电子对讲门铃安装方法【详细介绍】...
  19. 游安军编著的计算机数学答案,计算机数学
  20. matplotlib——画布分辨率和尺寸

热门文章

  1. InnoDB 存储引擎详细解析
  2. python3.7,显卡CUDA版本11.1,安装pytorch-CUDA
  3. PHP调用jsignature生成图片,App端jSignature签字版生成透明背景png图片
  4. 使用Linux训练LoRA模型
  5. 自动控制原理知识点梳理——6.线性系统的校正方法
  6. Embeded linux之网卡驱动
  7. form提交--jquery.form.js
  8. sqlplus set linesize/pagesize等命令详解
  9. java中getchars是什么意思_java中的getChars()方法
  10. MySQL(二)锁 ----- 表锁