对于一些企业,我们不用花费大把的资金去购进负载均衡设备,也可以进行负载均衡的实现。现在我们来说一下nginx负载均衡器,这种适合于中小型企业的设备,同样可以达到负载平衡的效果,现在我们就来介绍一下nginx负载均衡器的相关安装和设置问题。
一、拓扑环境:
用途 IP
主nginx负载均衡器 192.168.0.154
辅nginx负载均衡器 192.168.0.155
VIP地址 192.168.0.188
二、安装keepalived
wgethttp://www.keepalived.org/software/keepalived-1.1.15.tar.gz
tarzxvfkeepalived-1.1.15.tar.gz cdkeepalived-1.1.15 ./configure--prefix=/usr/local/keepalived make makeinstall 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/ vimkeepalived.conf !ConfigurationFileforkeepalived global_defs{ notification_email{ yuhongchun027@163.com } notification_email_fromkeepalived@chtopnet.com smtp_server127.0.0.1 smtp_connect_timeout30 router_idLVS_DEVEL } vrrp_instanceVI_1{ stateMASTER interfaceeth0 virtual_router_id51 mcast_src_ip192.168.0.154<==主nginx负载均衡器的IP地址 priority100 advert_int1 authentication{ auth_typePASS auth_passchtopnet } virtual_ipaddress{ 192.168.0.188<==vip地址 } } #servicekeepalivedstart
主nginx负载均衡器日志:
[root@ltos~]#tail/var/log/messages
Oct603:25:03ltosavahi-daemon[2306]:Registeringnewaddressrecordfor192.168.0.188oneth0. Oct603:25:03ltosavahi-daemon[2306]:Registeringnewaddressrecordfor192.168.0.154oneth0. Oct603:25:03ltosavahi-daemon[2306]:RegisteringHINFOrecordwithvalues'I686'/'LINUX'. Oct603:25:23ltosavahi-daemon[2306]:Withdrawingaddressrecordforfe80::20c:29ff:feb9:eeaboneth0. Oct603:25:23ltosavahi-daemon[2306]:Withdrawingaddressrecordfor192.168.0.154oneth0. Oct603:25:23ltosavahi-daemon[2306]:Hostnameconflict,retryingwith<ltos-31>Oct603:25:23ltosavahi-daemon[2306]:Registeringnewaddressrecordforfe80::20c:29ff:feb9:eeaboneth0. Oct603:25:23ltosavahi-daemon[2306]:Registeringnewaddressrecordfor192.168.0.188oneth0. Oct603:25:23ltosavahi-daemon[2306]:Registeringnewaddressrecordfor192.168.0.154oneth0. Oct603:25:23ltosavahi-daemon[2306]:RegisteringHINFOrecordwithvalues'I686'/'LINUX'.
发表评论