LVS-keepalived高可用
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LVS-keepalived高可用相关的知识,希望对你有一定的参考价值。
LVS-Keepalived高可用
一、实验环境
二、实验步骤
LVS-keepalived 1配置(主)
实验步骤:
加载ip_vs模块
安装ipvsadm管理工具
安装keepalived源码包。
修改内核参数( /etc/sysctl.conf)文件,关闭ICMP重定向
IP:vmnet2:192.168.1.2 网关:192.168.1.1
#modprobe ip_vs
#yum install -y kernel-devel popt-devel openssl-devel
#yum install -y ipvsadm gcc gcc-c++
#tar zxf keepalived-1.2.13.tar.gz
#cd keepalived-1.2.13
#./configure --prefix=/
--with-kernel-dir=/usr/src/kernels/2.6.32-431.e16.x86_64
#make && make install
#chkconfig --add keepalived
#chkconfig keepalived on
#vim /etc/sysctl.conf
#sysctl -p 使配置生效
#cd /etc/keepalived/
#cp keepalived.conf keepalived.conf.bak 备份一份以防配错
#vim keepalived.conf
#service keepalived start
LVS-keepalived 2配置(备份)
IP:vmnet 2:192.168.1.3 网关:192.168.1.1
#modprobe ip_vs
#yum install -y kernel-devel popt-devel openssl-devel
#yum install -y ipvsadm gcc gcc-c++
#tar zxf keepalived-1.2.13.tar.gz
#cd keepalived-1.2.13
#./configure --prefix=/
--with-kernel-dir=/usr/src/kernels/2.6.32-431.e16.x86_64
#make && make install
#chkconfig --add keepalived
#chkconfig keepalived on
#scp [email protected]2:/etc/sysctl.conf /etc/
#sysctl -p
#scp [email protected]2:/etc/keepalived/keepalived.conf /etc/keepalived/
#vim /etc/keepalived/keepalived.conf
#service keepalived start
#ip addr show eth0
NFS共享存储配置
Ip:vmnet 3:192.168.2.1
#yum install rpcbind nfs-utils
#chkconfig rpcbind on
#chkconfig nfs on
#mkdir -p /opt/wwwroot
#vim /etc/exports
/opt/wwwroot 192.168.2.0/24(rw,sync,no_root_squash)
#echo www.itdby.com > /opt/wwwroot/index.html
#service rpcbind start
#service nfs start
#netstat -anpt | grep rpcbind
WEB 1节点服务器配置
Ip:wmnet 2:192.168.1.4 vmnet 3:192.168.2.2
配置步骤:
ifcfg-lo:0配置群集ip地址192.168.1.254,子网掩码为255.255.255.255
修改内核参数( /etc/sysctl.conf)文件,关闭ARP应答。
#cd /etc/sysconfig/network-scripts/ 配置虚拟VIP
#cp ifcfg-lo ifcfg-lo:0
#vim ifcfg-lo:0
#ifconfig lo:0;ifup lo:0
#echo “/sbin/route add -host 192.168.1.254 dev lo:0” >> /etc/rc.local 重启后生效
#route add -host 192.168.1.254 dev lo:0 临时添加VIP本地访问路由,即时生效。
#vim /etc/sysctl.conf 修改内核参数( /etc/sysctl.conf)文件,关闭ARP应答。
#sysctl -p 使配置生效
#yum install -y httpd rpcbind nfs-utils
#service httpd start
#chkconfig httpd on
#echo 11111 > /var/www/html/index.html
WEB 2节点服务器配置
Ip:wmnet 2:192.168.1.5 vmnet 3:192.168.2.3
配置步骤:
ifcfg-lo:0配置群集ip地址192.168.1.254,子网掩码为255.255.255.255
修改内核参数( /etc/sysctl.conf)文件,关闭ARP应答。
#scp [email protected]:/etc/sysconfig/network-scripts/ifcfg-lo:0
/etc/sysconfig/network-scripts/
#cat /etc/sysconfig/network-scripts/ifcfg-lo:0
#ifconfig lo:0;ifup lo:0
#echo “/sbin/route add -host 192.168.1.254 dev lo:0” >> /etc/rc.local 重启后生效
#route add -host 192.168.1.254 dev lo:0 临时添加VIP本地访问路由,即时生效。
#scp [email protected]:/etc/sysctl.conf /etc/
#sysctl -p 使配置生效
#vim /etc/sysctl.conf 修改内核参数( /etc/sysctl.conf)文件,关闭ARP应答。
#yum install -y httpd rpcbind nfs-utils
#service httpd start
#chkconfig httpd on
#echo 22222 > /var/www/html/index.html
Windwos 7客户机测试http://192.168.1.254
把主调度器网卡断开
再次测试http://192.168.1.254
查看从服务器
再次配置各节点服务器
#service rpcbind start
#service nfs start
#mount 192.168.2.1:/opt/wwwroot /var/www/html
Windows 7客户端测试http://192.168.1.254
本文出自 “IT大本营” 博客,转载请与作者联系!
以上是关于LVS-keepalived高可用的主要内容,如果未能解决你的问题,请参考以下文章