前言:由于服务器资源有限,keepalived未配主备。
一、架构规划
1、服务器IP地址规划
VIP:192.168.1.6
real_server1:192.168.1.7
real_server2:192.168.1.8
WebServer1:192.168.1.9
WebServer2:192.168.1.10
memcache: 192.168.1.13
mysql主:192.168.1.12
mysql从:192.168.1.2
2、服务器操作系统
所使用的操作系统均为CentOS 6.4
3、网络拓扑图
二、负载服务器配置
1.LVS主服务器配置
安装yum install keepalived ipvsadm
chkconfig keepalived on
vim /etc/ keepalived/keepalived.conf
global_defs { notification_email { [email protected] } notification_email_from smtp_server 127.0.0.1 #smtp_connect_timeout 30 router_id LVS_DEVEL_1 } vrrp_instance VI_1 { state MASTER interface eth1 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.1.6 } } virtual_server 192.168.1.6 80 { delay_loop 6 #lb_algo wrr lb_algo rr lb_kind DR #persistence_timeout 300 protocol TCP real_server 192.168.1.7 80 { weight 3 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 192.168.1.8 80 { weight 3 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } }
2.LVS前端服务器配置(real_server1)
2.1 vim /usr/local/bin/lvs_real
VIP=192.168.1.6 case "$1" in start) echo " start LVS of REALServer" /sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce ;; stop) /sbin/ifconfig lo:0 down echo "close LVS Directorserver" echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce ;; *) echo "Usage: $0 {start|stop}" exit 1 esac
2.2 编辑安装nginx,此处省略(使用我自己写的一键编译安装脚本安装)
2.3 LVS前端服务器nginx配置
server { listen 80; server_name sandy.com; location / { 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 /coocaa_status { stub_status on; access_log /data/log/nginx_status.log; auth_basic "NginxStatus"; allow 192.168.0.58; deny all; } access_log /data/log/access.log access; error_log /data/log/error.log warn; } upstream sandy { sticky; server 192.168.1.9:80; server 192.168.1.10:80; } }
三、Webserver服务器配置
1
四、Memcache服务器配置
五、Mysql服务器配置
后续整理
时间: 2024-10-26 21:49:58