heartbeat之part2

部署高可用
业务需求描述
假设有两台服务器data-1-1/data-1-2 其实际ip分别为192.168.0.107和192.168.0.108(data-1-2),
配置目标,要求heartbeat服务启动后,data-1-1初始启动vip192.168.0.07,data-1-2初始启动vip192.168.0.08.
一旦任意一台服务器宕机,在宕机的机器上初始启动的虚拟vip就会切换到运转正常的机器上,实现了ip资源的
自动接管,从而达到高可用的目的
环境里的虚拟机双网卡桥接
[root@localhost  ~]# setup空格切换
-->network configuration-->device configuration
eth0
Name                 eth0________________ │
                 │ Device               eth0________________ │
                 │ Use DHCP             [ ]                  │
                 │ Static IP            192.168.0.107____________ │
                 │ Netmask              255.255.255_________ │
                 │ Default gateway IP   10.0.0.254__________ │
                 │ Primary DNS Server   ____________________ │
                 │ Secondary DNS Server _____________
                
eth1             
                
                 Name                 eth1________________ │
                 │ Device               eth1________________ │
                 │ Use DHCP             [ ]                  │
                 │ Static IP            192.168.1.107___________ │
                 │ Netmask              255.255.255.0_______ │
                 │ Default gateway IP   ____________________ │
                 │ Primary DNS Server   ____________________ │
                 │ Secondary DNS Server ____________________

[root@localhost  ~]# /etc/init.d/network restart
Shutting down interface eth0:  Device state: 3 (disconnected)
                                                           [  OK  ]
Shutting down interface eth1:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Active connection state: activating
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/1
state: activated
Connection activated
                                                           [  OK  ]
data-1-2                                                           
                                                           
 [root@localhost  ~]# setup
 -->network configuration-->device configuration
 eth0
  Name                 eth0________________ │
                 │ Device               eth0________________ │
                 │ Use DHCP             [ ]                  │
                 │ Static IP            192.168.0.108___________ │
                 │ Netmask              255.255.255.0_______ │
                 │ Default gateway IP   10.0.0.254__________ │
                 │ Primary DNS Server   ____________________ │
                 │ Secondary DNS Server ____________________
                  Name                 eth1________________ │
eth1
                 │ Device               eth1________________ │
                 │ Use DHCP             [ ]                  │
                 │ Static IP            192.168.1.108___________ │
                 │ Netmask              255.255.255.0______
若出现Bringing up interface eth0:  Error: Unknown connection: cfae0b8b-6a2e-4df8-a009-9c6570ca906d.
                                                           [FAILED]
那么
[root@localhost  ~]# chkconfig NetworkManager off
[root@localhost  ~]# service NetworkManager stop
分别配置主机名与hosts
[data-1-1]
[root@localhost ~]# hostname data-1-1
[root@localhost etc]# vi /etc/sysconfig/network
HOSTNAME=data-1-1
[root@localhost etc]# cd /etc
[root@localhost etc]# cp hosts hosts_bak
[root@localhost etc]#vi hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.107  data-1-1
192.168.88.108  data-1-2    
[root@data-1-1 ~]# tail -2 /etc/hosts
192.168.0.107    data-1-1
192.168.0.108    data-1-2
[root@data-1-1 ~]# uname -n
data-1-1

[data-1-2]
[root@localhost ~]# hostname data-1-2
[root@localhost etc]# vi /etc/sysconfig/network
HOSTNAME=data-1-2
[root@localhost etc]# cd /etc
[root@localhost etc]# cp hosts hosts_bak
[root@localhost etc]#vi hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.107    data-1-1
192.168.0.108    data-1-2                     
[root@data-1-2 ~]# tail -2 /etc/hosts
192.168.0.107    data-1-1
192.168.0.108    data-1-2
[root@data-1-2 ~]# uname -n
data-1-2
[root@data-1-1 ~]# ifconfig eth1[若ip为broadcast]就 ifup eth1;同理data-1-2
eth1      Link encap:Ethernet  HWaddr 00:0C:29:34:72:3F  
          inet addr:192.168.1.107  Bcast:10.0.10.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe34:723f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7 errors:0 dropped:0 overruns:0 frame:0
          TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:801 (801.0 b)  TX bytes:1440 (1.4 KiB)
          Interrupt:16 Base address:0x2024


          
添加主机路由
[data-1-1]
[root@data-1-1 ~]# route add -host 192.168.1.108 dev eth1 [/sbin/route add -host 192.168.1.108 dev eth1]
[root@data-1-1 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.108       0.0.0.0         255.255.255.255 UH    0      0        0 eth1已经配置好了
10.0.0.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
10.0.10.0       0.0.0.0         255.255.255.0   U     0      0        0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U     1003   0        0 eth0
0.0.0.0         10.0.0.254      0.0.0.0         UG    0      0        0 eth0

echo '/sbin/route add -host 192.168.1.108 dev eth1' >>/etc/rc.local永久生效
[data-1-2]
[root@data-1-2 ~]# route add -host 192.168.1.107 dev eth1 [/sbin/route add -host 192.168.1.107 dev eth1]
[root@data-1-2 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.107       0.0.0.0         255.255.255.255 UH    0      0        0 eth1
10.0.0.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
10.0.10.0       0.0.0.0         255.255.255.0   U     0      0        0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U     1003   0        0 eth0
0.0.0.0         10.0.0.254      0.0.0.0         UG    0      0        0 eth0
echo '/sbin/route add -host 192.168.1.107 dev eth1' >>/etc/rc.local
[root@data-1-2 ~]#
安装heart beat软件

你可能感兴趣的:(heartbeat之part2)