1.先开4台机器,因为想做lvs 的keepalived高可用所以开四台
1.下载keepallived 和 ipvsadm (ipvsadm是一个查看配置的工具)
开始就把防火墙关掉
yum -y install keepalived ipvsadm #安装
vim /etc/keepalived/keepalived.conf #修改配置文件
2.发送配置文件
scp /etc/keepalived/keepalived.conf root@192.168.242.134:/etc/keepalived/keepalived.conf
把从上面的向上面改一下 MASTER改为BACKUP 100改为90
3.在web上操作另一台web上也要操作
yum -y install httpd #下载httpd
echo "web1" > /var/www/html/index.html #改个页面
4.复制网卡
cd /etc/sysconfig/network-scripts/
cp ifcfg-lo ifcfg-lo:0DEVICE=lo:0
5.修改网卡的配置文件
vim ifcfg:0 #底下是没修改前
IPADDR=192.168.242.100 #VIP
NETMASK=255.255.255.255 #子网掩码
ONBOOT=yes
6.启动网卡查看网卡
ifup lo:0
[root@localhost network-scripts] ifconfig lo:0
lo:0: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 192.168.242.100 netmask 255.255.255.255 出现则为成功
loop txqueuelen 1000 (Local Loopback)
7.加6行
vim /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
下面是添加的
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.default.arp_ignore = 1
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce =
8.检测添加的有没问题
[root@localhost network-scripts]# sysctl -p
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.default.arp_ignore = 1
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
9.router
vim /etc/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
/sbin/route add -host 192.168.242.100 dev lo:0 #加这一行
10.在命令行执行一遍
[root@localhost network-scripts]# route add -host 192.168.242.100 dev lo:0