keepalived架设简单高可用的nginx的web服务器----那些你不知道的秘密
如果均衡件不使用LVS的,那keepalived的配置是相的蔚模�恍枰�渲煤ASTER和SLAVE的vrrp相配置就可以了,後端realServer的y就可以交均衡件去做,比如我使用的均衡件是haproxy,人楸VS更高效、更省源、配置更巍l理更清晰。
下面碚f我在配置keepalived和nginx程中遇到的一些,之所以�霈F很多,就在於keepalived]有配置文件查的C制,不管你的配置文件成了啥樱�阏涌梢猿晒eepalived,它不�o你任斟e提示,就像它]有出一樱�悴榭催M程r也不�X得它常,和普通的正常的程一模一樱�虼艘坏┡渲梦募�渲缅e就很要命了。
nginx的配置就]啥好的了,重keepalived。
1,环境
test2为主ngin服务器,test3为辅的nginx服务器
test2 eth2: 192.168 . 46.132 test3 eth2: 192.168 . 46.133 |
如果你使用LVS作樨均衡器的,需要程序能找到你的linux群怂�谀夸,要-- with -kernel-dir=/usr/src/linux稻,因此你需要先安群碎_包: with -kernel-dir=/usr/src/linux稻,因此你需要先安群碎_包: yum install kernel-devel 接著群嗽次募�夸做一接: ln -s /usr/src/kernels/`uname -r` /usr/src/linux ./configure --prefix=/usr/local/keepalived -- with -kernel-dir=/usr/src/linux with -kernel-dir=/usr/src/linux 如果不使用LVS,就不需要- with -kernel-dir担�矣玫氖ginx,因此]有指定此怠 with -kernel-dir担�矣玫氖ginx,因此]有指定此怠configure束,始maker,出现了以下: /usr/ include /stdint.h: 41 : error: conflicting types for 'int64_t' include /stdint.h: 41 : error: conflicting types for include /stdint.h: 41 : error: conflicting types for 'int64_t' /usr/src/linux/ include /linux/types.h: 126 : error: previous declaration of 'int64_t' was here include /linux/types.h: 126 : error: previous declaration of 'int64_t' was here /usr/ include /stdint.h: 56 : error: conflicting types for 'uint64_t' include /stdint.h: 56 : error: conflicting types for include /stdint.h: 56 : error: conflicting types for 'uint64_t' /usr/src/linux/ include /linux/types.h: 124 : error: previous declaration of 'uint64_t' was here include /linux/types.h: 124 : error: previous declaration of 'uint64_t' was here In file included from /usr/ include /stdlib.h: 438 , include /stdlib.h: 438 , 在源目找到keepalived/libipvs- 2.6 /ip_vs.h文件,它,把 # include <linux/types.h> 移动到 # include <sys/types.h> 的下面即可,再次make正常,make install安完。 2.6 /ip_vs.h文件,它,把 # include <linux/types.h> 移动到 # include 2.6 /ip_vs.h文件,它,把 # include <linux/types.h> 移动到 # include <sys/types.h> 的下面即可,再次make正常,make install安完。 |
3、配置
3.1主服务器test2的keepalived的配置
/etc/keepalived/keepalived.conf notification_email { notification_email_from root@localhost smtp_server 127.0 . 0.1 smtp_connect_timeout 30 router_id LVS_DEVEL vrrp_script chk_http_port { script "/root/nginx_pid.sh" vrrp_instance VI_1 {
订阅:
博文评论 (Atom)
|
没有评论:
发表评论