LVS+HEARTBEAT+CENTOS4.4+LDIRECTORD+GUI
Edited by erico
Date:2007-04-19
安装前网络环境设定:
========================================================
LVS server
node1: 主机名:LB1 (HA01)
eth0: 10.10.10.77 //对外IP地址
eth1: 168.168.168.77 //HA心跳使用地址
node2: 主机名:LB2(HA02)
eth0: 10.10.10.111 //对外IP地址
eth1: 168.168.168.111 //HA心跳使用地址
Realserver
node1: 主机名:
eth0: 10.10.10.79 //对外IP地址
eth1:
node2: 主机名:
eth0: 10.10.10.102 //对外IP地址
eth1:
1.下载rpm软件包
heartbeat-2.0.8-2.el4.centos.i386.rpm
heartbeat-gui-2.0.8-2.el4.centos.i386.rpm
heartbeat-ldirectord-2.0.8-2.el4.centos.i386.rpm
heartbeat-pils-2.0.8-2.el4.centos.i386.rpm
heartbeat-stonith-2.0.8-2.el4.centos.i386.rpm
ipvsadm-1.24-6.i386.rpm
2.下载ldirectord依赖补丁包(要不ldirectord安装不了)
(http://ftp.hostrino.com/pub/centos/4.4/extras/i386/RPMS)
perl-IO-Socket-SSL.rpm
perl-Mail-POP3-client
perl-MailTools
perl-Net-IMAP-Simple
perl-Net-IMAP-Simple-SSL
perl-Net-SSLeay
perl-TimeDate
perl-Authen-Radius-0.12-3.c4.noarch.rpm
3。安装rpm包
rpm --install ipvsadm*.rpm
rpm --install heartbeat-pils-*.rpm
rpm --install heartbeat-stonith-*.rpm
rpm --install heartbeat-2.0.8-*.rpm
rpm --install heartbeat-gui-*.rpm
yum install heartbeat-ldirectord
4.把相关配置文件放到/etc/ha.d/下
cp /usr/share/doc/heartbeat2.0.8/ha.cf haresources authkeys /etc/ha.d/
cp /usr/share/doc/heartbeat-ldirectord-2.0.7/ldirectord.cf /etc/ha.d/
5.配置heartbeat
配置ha.cf
#
# There are lots of options in this file. All you have to have is a set
# of nodes listed {"node ...} one of {serial, bcast, mcast, or ucast},
# and a value for "auto_failback".
#
# ATTENTION: As the configuration file is read line by line,
# THE ORDER OF DIRECTIVE MATTERS!
#
# In particular, make sure that the udpport, serial baud rate
# etc. are set before the heartbeat media are defined!
# debug and log file directives go into effect when they
# are encountered.
#
# All will be fine if you keep them ordered as in this example.
#
#
# Note on logging:
# If any of debugfile, logfile and logfacility are defined then they
# will be used. If debugfile and/or logfile are not defined and
# logfacility is defined then the respective logging and debug
# messages will be loged to syslog. If logfacility is not defined
# then debugfile and logfile will be used to log messges. If
# logfacility is not defined and debugfile and/or logfile are not
# defined then defaults will be used for debugfile and logfile as
# required and messages will be sent there.
#
# File to write debug messages to
debugfile /var/log/ha-debug
#
#
# File to write other messages to
#
logfile /var/log/ha-log
#
#
# Facility to use for syslog()/logger
#
logfacility local0
#
#
# A note on specifying "how long" times below...
#
# The default time unit is seconds
# 10 means ten seconds
#
# You can also specify them in milliseconds
# 1500ms means 1.5 seconds
#
#
# keepalive: how long between heartbeats?
#
keepalive 2
#
# deadtime: how long-to-declare-host-dead?
#
# If you set this too low you will get the problematic
# split-brain (or cluster partition) problem.
# See the FAQ for how to use warntime to tune deadtime.
#
deadtime 30
#
# warntime: how long before issuing "late heartbeat" warning?
# See the FAQ for how to use warntime to tune deadtime.
#
warntime 10
#
#
# Very first dead time (initdead)
#
# On some machines/OSes, etc. the network takes a while to come up
# and start working right after you've been rebooted. As a result
# we have a separate dead time for when things first come up.
# It should be at least twice the normal dead time.
#
initdead 120
#
#
# What UDP port to use for bcast/ucast communication?
#
udpport 694
#
# Baud rate for serial ports...
#
#baud 19200
#
# serial serialportname ...
#serial /dev/ttyS0 # Linux
#serial /dev/cuaa0 # FreeBSD
#serial /dev/cua/a # Solaris
#
#
# What interfaces to broadcast heartbeats over?
#
bcast eth1
#bcast eth1 eth2 # Linux
#bcast le0 # Solaris
#bcast le1 le2 # Solaris
#
# Set up a multicast heartbeat medium
# mcast [dev] [mcast group] [port] [ttl] [loop]
#
# [dev] device to send/rcv heartbeats on
# [mcast group] multicast group to join (class D multicast address
# 224.0.0.0 - 239.255.255.255)
# [port] udp port to sendto/rcvfrom (set this value to the
# same value as "udpport" above)
# [ttl] the ttl value for outbound heartbeats. this effects
# how far the multicast packet will propagate. (0-255)
# Must be greater than zero.
# [loop] toggles loopback for outbound multicast heartbeats.
# if enabled, an outbound packet will be looped back and
# received by the interface it was sent on. (0 or 1)
# Set this value to zero.
#
#
#mcast eth1 225.0.0.1 694 1 0
#
# Set up a unicast / udp heartbeat medium
# ucast [dev] [peer-ip-addr]
#
# [dev] device to send/rcv heartbeats on
# [peer-ip-addr] IP address of peer to send packets to
#
#ucast eth0 192.168.1.2
#
#
# About boolean values...
#
# Any of the following case-insensitive values will work for true:
# true, on, yes, y, 1
# Any of the following case-insensitive values will work for false:
# false, off, no, n, 0
#
#
#
# auto_failback: determines whether a resource will
# automatically fail back to its "primary" node, or remain
# on whatever node is serving it until that node fails, or
# an administrator intervenes.
#
# The possible values for auto_failback are:
# on - enable automatic failbacks
# off - disable automatic failbacks
# legacy - enable automatic failbacks in systems
# where all nodes do not yet support
# the auto_failback option.
#
# auto_failback "on" and "off" are backwards compatible with the old
# "nice_failback on" setting.
#
# See the FAQ for information on how to convert
# from "legacy" to "on" without a flash cut.
# (i.e., using a "rolling upgrade" process)
#
# The default value for auto_failback is "legacy", which
# will issue a warning at startup. So, make sure you put
# an auto_failback directive in your ha.cf file.
# (note: auto_failback can be any boolean or "legacy")
#
auto_failback on
#
#
# Basic STONITH support
# Using this directive assumes that there is one stonith
# device in the cluster. Parameters to this device are
# read from a configuration file. The format of this line is:
#
# stonith
#
# NOTE: it is up to you to maintain this file on each node in the
# cluster!
#
#stonith baytech /etc/ha.d/conf/stonith.baytech
#
# STONITH support
# You can configure multiple stonith devices using this directive.
# The format of the line is:
# stonith_host
#
# to or * to mean it is accessible from any host.
#
# supported drives is in /usr/lib/stonith.)
#
# format for a particular device, run:
# stonith -l -t
#
#
# Note that if you put your stonith device access information in
# here, and you make this file publically readable, you're asking
# for a denial of service attack ;-)
#
# To get a list of supported stonith devices, run
# stonith -L
# For detailed information on which stonith devices are supported
# and their detailed configuration options, run this command:
# stonith -h
#
#stonith_host * baytech 10.0.0.3 mylogin mysecretpassword
#stonith_host ken3 rps10 /dev/ttyS1 kathy 0
#stonith_host kathy rps10 /dev/ttyS1 ken3 0
#
# Watchdog is the watchdog timer. If our own heart doesn't beat for
# a minute, then our machine will reboot.
# NOTE: If you are using the software watchdog, you very likely
# wish to load the module with the parameter "nowayout=0" or
# compile it without CONFIG_WATCHDOG_NOWAYOUT set. Otherwise even
# an orderly shutdown of heartbeat will trigger a reboot, which is
# very likely NOT what you want.
#
#watchdog /dev/watchdog
#
# Tell what machines are in the cluster
# node nodename ... -- must match uname -n
node HA01
node HA02
#
# Less common options...
#
# Treats 10.10.10.254 as a psuedo-cluster-member
# Used together with ipfail below...
#
#ping 10.10.10.254
#
# Treats 10.10.10.254 and 10.10.10.253 as a psuedo-cluster-member
# called group1. If either 10.10.10.254 or 10.10.10.253 are up
# then group1 is up
# Used together with ipfail below...
#
ping_group group1 168.168.168.79 168.168.168.111
#
# HBA ping derective for Fiber Channel
# Treats fc-card-name as psudo-cluster-member
# used with ipfail below ...
#
# You can obtain HBAAPI from http://hbaapi.sourceforge.net. You need
# to get the library specific to your HBA directly from the vender
# To install HBAAPI stuff, all You need to do is to compile the common
# part you obtained from the sourceforge. This will produce libHBAAPI.so
# which you need to copy to /usr/lib. You need also copy hbaapi.h to
# /usr/include.
#
# The fc-card-name is the name obtained from the hbaapitest program
# that is part of the hbaapi package. Running hbaapitest will produce
# a verbose output. One of the first line is similar to:
# Apapter number 0 is named: qlogic-qla2200-0
# Here fc-card-name is qlogic-qla2200-0.
#
#hbaping fc-card-name
#
#
# Processes started and stopped with heartbeat. Restarted unless
# they exit with rc=100
#
#respawn userid /path/name/to/run
respawn root /usr/lib/heartbeat/ipfail
#
# Access control for client api
# default is no access
#
#apiauth client-name gid=gidlist uid=uidlist
apiauth ipfail gid=root uid=root
###########################
#
# Unusual options.
#
###########################
#
# hopfudge maximum hop count minus number of nodes in config
#hopfudge 1
#
# deadping - dead time for ping nodes
#deadping 30
#
# hbgenmethod - Heartbeat generation number creation method
# Normally these are stored on disk and incremented as needed.
#hbgenmethod time
#
# realtime - enable/disable realtime execution (high priority, etc.)
# defaults to on
#realtime off
#
# debug - set debug level
# defaults to zero
#debug 1
#
# API Authentication - replaces the fifo-permissions-based system of the past
#
#
# You can put a uid list and/or a gid list.
# If you put both, then a process is authorized if it qualifies under either
# the uid list, or under the gid list.
#
# The groupname "default" has special meaning. If it is specified, then
# this will be used for authorizing groupless clients, and any client groups
# not otherwise specified.
#
# There is a subtle exception to this. "default" will never be used in the
# following cases (actual default auth directives noted in brackets)
# ipfail (uid=HA_CCMUSER)
# ccm (uid=HA_CCMUSER)
# ping (gid=HA_APIGROUP)
# cl_status (gid=HA_APIGROUP)
#
# This is done to avoid creating a gaping security hole and matches the most
# likely desired configuration.
#
#apiauth ipfail uid=hacluster
#apiauth ccm uid=hacluster
#apiauth cms uid=hacluster
#apiauth ping gid=haclient uid=alanr,root
#apiauth default gid=haclient
# message format in the wire, it can be classic or netstring,
# default: classic
#msgfmt classic/netstring
# do we use logging daemon?
# detail policy:
# 1. if there is any entry for debugfile/logfile/logfacility in ha.cf
# a) if use_logd is not set, logging daemon will not be used
# b) if use_logd is set to on, logging daemon will be used
# c) if use_logd is set to off, logging daemon will not be used
#
#
# 2. if there is no entry for debugfile/logfile/logfacility in ha.cf
# a) if use_logd is not set, logging daemon will be used
# b) if use_logd is set to on, logging daemon will be used
# c) if use_logd is set to off, config error, i.e. you can not turn
# off all logging options
#
# If logging daemon is used, logfile/debugfile/logfacility in this file
# are not meaningful any longer. You should check the config file for logging
# daemon (the default is /etc/logd.cf)
#
# If you are not sure about this option, don't configure it
#
# use_logd yes/no
#
# the interval we reconnect to logging daemon if the previous connection failed
# default: 60 seconds
#conn_logd_time 60
nice_failback off
配置haresources
#
# This is a list of resources that move from machine to machine as
# nodes go down and come up in the cluster. Do not include
# "administrative" or fixed IP addresses in this file.
#
#
# The haresources files MUST BE IDENTICAL on all nodes of the cluster.
#
# The node names listed in front of the resource group information
# is the name of the preferred node to run the service. It is
# not necessarily the name of the current machine. If you are running
# auto_failback ON (or legacy), then these services will be started
# up on the preferred nodes - any time they're up.
#
# If you are running with auto_failback OFF, then the node information
# will be used in the case of a simultaneous start-up, or when using
# the hb_standby {foreign,local} command.
#
# BUT FOR ALL OF THESE CASES, the haresources files MUST BE IDENTICAL.
# If your files are different then almost certainly something
# won't work right.
#
#
#
# We refer to this file when we're coming up, and when a machine is being
# taken over after going down.
#
# You need to make this right for your installation, then install it in
# /etc/ha.d
#
# Each logical line in the file constitutes a "resource group".
# A resource group is a list of resources which move together from
# one node to another - in the order listed. It is assumed that there
# is no relationship between different resource groups. These
# resource in a resource group are started left-to-right, and stopped
# right-to-left. Long lists of resources can be continued from line
# to line by ending the lines with backslashes ("\").
#
# These resources in this file are either IP addresses, or the name
# of scripts to run to "start" or "stop" the given resource.
#
# The format is like this:
#
#node-name resource1 resource2 ... resourceN
HA01 IPaddr::10.10.10.70 DRlvs_Server httpd
#
# If the resource name contains an :: in the middle of it, the
# part after the :: is passed to the resource script. as an argument.
# Multiple arguments are separated by the :: delimeter
#
# In the case of IP addresses, the resource script. name IPaddr is
# implied.
#
# For example, the IP address 135.9.8.7 could also be represented
# as IPaddr::135.9.8.7
#
# THIS IS IMPORTANT!! vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
#
# The given IP address is directed to an interface which has a route
# to the given address. This means you have to have a net route
# set up outside of the High-Availability structure. We don't set it
# up here -- we key off of it.
#
# The broadcast address for the IP alias that is created to support
# an IP address defaults to the highest address on the subnet.
#
# The netmask for the IP alias that is created defaults to the same
# netmask as the route that it selected in in the step above.
#
# The base interface for the IPalias that is created defaults to the
# same netmask as the route that it selected in in the step above.
#
# If you want to specify that this IP address is to be brought up
# on a subnet with a netmask of 255.255.255.0, you would specify
# this as IPaddr::135.9.8.7/24 .
#
# If you wished to tell it that the broadcast address for this subnet
# was 135.9.8.210, then you would specify that this way:
# IPaddr::135.9.8.7/24/135.9.8.210
#
# If you wished to tell it that the interface to add the address to
# is eth0, then you would need to specify it this way:
# IPaddr::135.9.8.7/24/eth0
#
# And this way to specify both the broadcast address and the
# interface:
# IPaddr::135.9.8.7/24/eth0/135.9.8.210
#
# The IP addresses you list in this file are called "service" addresses,
# since they're they're the publicly advertised addresses that clients
# use to get at highly available services.
#
# For a hot/standby (non load-sharing) 2-node system with only
# a single service address,
# you will probably only put one system name and one IP address in here.
# The name you give the address to is the name of the default "hot"
# system.
#
# Where the nodename is the name of the node which "normally" owns the
# resource. If this machine is up, it will always have the resource
# it is shown as owning.
#
# The string you put in for nodename must match the uname -n name
# of your machine. Depending on how you have it administered, it could
# be a short name or a FQDN.
#
#-------------------------------------------------------------------
#
# Simple case: One service address, default subnet and netmask
# No servers that go up and down with the IP address
#
#just.linux-ha.org 135.9.216.110
#
#-------------------------------------------------------------------
#
# Assuming the adminstrative addresses are on the same subnet...
# A little more complex case: One service address, default subnet
# and netmask, and you want to start and stop http when you get
# the IP address...
#
#just.linux-ha.org 135.9.216.110 http
#-------------------------------------------------------------------
#
# A little more complex case: Three service addresses, default subnet
# and netmask, and you want to start and stop http when you get
# the IP address...
#
#just.linux-ha.org 135.9.216.110 135.9.215.111 135.9.216.112 httpd
#-------------------------------------------------------------------
#
# One service address, with the subnet, interface and bcast addr
# explicitly defined.
#
#just.linux-ha.org 135.9.216.3/28/eth0/135.9.216.12 httpd
#
#-------------------------------------------------------------------
#
# An example where a shared filesystem is to be used.
# Note that multiple aguments are passed to this script. using
# the delimiter '::' to separate each argument.
#
#node1 10.0.0.170 Filesystem::/dev/sda1::/data1::ext2
#
# Regarding the node-names in this file:
#
# They must match the names of the nodes listed in ha.cf, which in turn
# must match the `uname -n` of some node in the cluster. So they aren't
# virtual in any sense of the word.
#
配置ldriectored
Sample ldirectord configuration file to configure various virtual services.
#
# Ldirectord will connect to each real server once per second and request
# /index.html. If the data returned by the server does not contain the
# string "Test Message" then the test fails and the real server will be
# taken out of the available pool. The real server will be added back into
# the pool once the test succeeds. If all real servers are removed from the
# pool then localhost:80 is added to the pool as a fallback measure.
# Global Directives
checktimeout=3
checkinterval=1
fallback=127.0.0.1:80
autoreload=yes
logfile="/var/log/ldirectord.log"
logfile="local0"
quiescent=no
# A sample virual with a fallback that will override the gobal setting
virtual=10.10.10.70:80
real=10.10.10.102:80 gate
real=10.10.10.77:80 gate
fallback=127.0.0.1:80 gate
service=http
request="healthy.html"
receive="Test Page"
virtualhost=10.10.10.70
scheduler=rr
persistent=100
#netmask=255.255.255.255
protocol=tcp
# Sample configuration for a fwmark based service For an explination of
# fwmark see the ipvsadm(8) man page
#virtual=1
# real=192.168.6.2 gate
# real=192.168.6.3 gate
# real=192.168.6.6 gate
# service=http
# checkport=80
# request="index.html"
# receive="Test Page"
# scheduler=rr
# #persistent=600
# #netmask=255.255.255.255
# protocol=fwm
# checktype=connect
# Sample configuration for a service using a range of real servers
# and a single real server for a virtual service
#virtual=192.168.6.240:80
# real=192.168.6.2->192.168.6.7:80 gate
# real=192.168.6.32:80 gate
# service=http
# request="index.html"
# receive="Test Page"
# scheduler=rr
# protocol=tcp
#Sample configuration for an https virtual service.
#Fallback setting overides global
#virtual=192.168.6.240:443
# real=192.168.16.3:443 masq
# real=192.168.16.5:443 masq
# fallback=127.0.0.1:443
# service=https
# virtualhost=some.domain.com.au
# #request="index.html"
# #receive="Test Page"
# scheduler=rr
# #persistent=600
# #netmask=255.255.255.255
# protocol=tcp
#Sample configuration for an ftp virtual service.
#Fallback setting overides global
#virtual=192.168.6.240:21
# real=192.168.16.3:21 masq
# real=192.168.16.5:21 masq
# fallback=127.0.0.1:21
# service=ftp
# scheduler=wlc
# login="anonymous"
# passwd="ldirectord@localhost"
# request="welcome.msg"
# receive="test"
# persistent=600
# #netmask=255.255.255.255
# protocol=tcp
#Sample configuration for an smtp virtual service.
#Fallback setting overides global
#virtual=192.168.6.240:25
# real=192.168.16.3:25 masq
# real=192.168.16.5:25 masq
# fallback=127.0.0.1:25
# service=smtp
# scheduler=wlc
# persistent=600
# protocol=tcp
#Sample configuration for an pop virtual service.
#Fallback setting overides global
#virtual=192.168.6.240:110
# real=192.168.16.3:110 masq
# real=192.168.16.5:110 masq
# fallback=127.0.0.1:110
# service=pop
# scheduler=wlc
# #login="test"
# #passwd="test"
# persistent=600
# protocol=tcp
##Sample configuration for an imap virtual service.
#Fallback setting overides global
#virtual=192.168.6.240:143
# real=127.0.0.1:143 masq
# real=192.168.16.3:143 masq
# real=192.168.16.5:143 masq
# fallback=127.0.0.1:143
# service=imap
# scheduler=wlc
# #login="test"
# #passwd="test"
# persistent=600
# protocol=tcp
#Sample configuration for an ldap virtual service.
#Fallback setting overides global
#virtual=192.168.84.5:389
# real=10.0.1.4:389 masq
# real=10.0.1.6:389 masq
# fallback=127.0.0.1:389
# service=ldap
# scheduler=wlc
# request="dc=upmc, dc=fr"
# receive="dc=upmc, dc=fr"
# #login="test"
# #passwd="test"
# persistent=600
# #netmask=255.255.255.255
# protocol=tcp
#Sample configuration for an nntp virtual service.
#Fallback setting overides global
#virtual=192.168.84.5:119
# real=10.0.1.4:119 masq
# real=10.0.1.6:119 masq
# fallback=127.0.0.1:119
# service=nntp
# scheduler=wlc
# #persistent=600
# #netmask=255.255.255.255
# protocol=tcp
#Sample configuration for a UDP DNS virtual service.
#Fallback setting overides global
#virtual=192.168.84.5:53
# real=10.0.1.4:53 masq
# real=10.0.1.6:53 masq
# fallback=127.0.0.1:53
# request="some.domain.com.au"
# recieve="127.0.0.1"
# service=dns
# scheduler=wlc
# #persistent=600
# #netmask=255.255.255.255
# protocol=udp
#Sample configuration for a MySQL virtual service.
#virtual = 192.168.10.74:3306
# real=sql01->sql03:3306 gate 10
# checktype=negotiate
# login="readuser"
# passwd="genericpassword"
# database="portal"
# request="SELECT * FROM link"
# service=mysql
# scheduler=wrr
#Sample configuration for a PostgreSQL virtual service.
#virtual = 192.168.10.74:5432
# real=sql01->sql03:5432 gate 10
# checktype=negotiate
# login="readuser"
# passwd="genericpassword"
# database="portal"
# request="SELECT * FROM link"
# service=pgsql
# scheduler=wrr
#Sample configuration for an unsuported protocol
#The real servers will just be brought up without checking for availability
#Fallback setting overides global
#virtual=192.168.6.240:23
# real=192.168.16.3:23 masq
# real=192.168.16.5:23 masq
# fallback=127.0.0.1:21
# service=none
# scheduler=wlc
# request="welcome.msg"
# receive="test"
# persistent=600
# #netmask=255.255.255.255
# protocol=tcp
# A sample virtual services that uses a ping check.
# Note that using checktype=connect and protocol=udp
# will also effect ping checks
#virtual=192.168.6.240:53
# real=192.168.6.2:53 gate
# real=192.168.6.3:53 gate
# real=192.168.6.6:53 gate
# fallback=127.0.0.1:53 gate
# scheduler=rr
# #persistent=600
# #netmask=255.255.255.255
# checktype=ping
# checkcount=3
# protocol=udp
# A sample virtual services that uses a SIP check on UDP.
# Note that using checktype=connect and protocol=udp
# will also effect ping checks
#virtual=192.168.6.240:5060
# real=192.168.6.2::5060 gate
# real=192.168.6.3::5060 gate
# real=192.168.6.6::5060 gate
# #fallback=127.0.0.1:5060 gate
# scheduler=rr
# #persistent=600
# #netmask=255.255.255.255
# checktype=negotiate
# service=sip
# checktimeout=1
# protocol=udp
配置authkeys
#
# Authentication file. Must be mode 600
#
#
# Must have exactly one auth directive at the front.
# auth send authentication using this method-id
#
# Then, list the method and key that go with that method-id
#
# Available methods: crc sha1, md5. Crc doesn't need/want a key.
#
# You normally only have one authentication method-id listed in this file
#
# Put more than one to make a smooth transition when changing auth
# methods and/or keys.
#
#
# sha1 is believed to be the "best", md5 next best.
#
# crc adds no security, except from packet corruption.
# Use only on physically secure networks.
#
auth 1
1 crc
#2 sha1 HI!
#3 md5 Hello!
修改authkeys属性
Chmod 600 authkeys
6.修改系统配置文件
修改HA02服务器/etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
10.10.10.111 LB2 HA02
168.168.168.111 HA02
168.168.168.79 HA01
10.10.10.79 LB1
修改HA01服务器/etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
10.10.10.79 LB1 HA01
168.168.168.79 HA01
168.168.168.111 HA02
10.10.10.111 LB1
7.配置ipvsadm脚本(DRlvs_Server 放到lvs服务器/etc/init.d/)
#!/bin/sh
#create in 20070413 from erico
# description: start LVS of Directorserver at LVSserver
VIP=10.10.10.70
RIP1=10.10.10.77
RIP2=10.10.10.102
#RIPn=192.168.0.128~254
GW=10.10.10.1
. /etc/rc.d/init.d/functions
case "$1" in
start)
echo " start LVS of DirectorServer at LVSserver"
# set the Virtual IP Address
/sbin/ifconfig eth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up
/sbin/route add -host $VIP dev eth0:0
#Clear IPVS table
/sbin/ipvsadm -C
#set LVS
/sbin/ipvsadm -A -t $VIP:80 -s rr
/sbin/ipvsadm -a -t $VIP:80 -r $RIP1:80 -g
/sbin/ipvsadm -a -t $VIP:80 -r $RIP2:80 -g
#/sbin/ipvsadm -a -t $VIP:80 -r $RIP3:80 -g
#Run LVS
/sbin/ipvsadm
#end
;;
stop)
echo "close LVS Directorserver"
/sbin/ipvsadm -C
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
8.配置realserver脚本,屏蔽ARP(DRlvs_Realserver 放到realserver /etc/init.d/)
#!/bin/bash
#description : start in realserver
#create in 20070413 by erico
VIP=10.10.10.70
/sbin/ifconfig lo:0 10.10.10.70 broadcast 10.10.10.70 netmask 255.255.255.255 up
/sbin/route add -host $VIP dev lo:0
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
sysctl -p
#end
9.修改系统自动启动heartbeat和ldirectord服务(针对lvs服务器)
修改/etc/rc.local
#!/bin/sh
#
# This script. will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style. init stuff.
touch /var/lock/subsys/local
/etc/init.d/heartbeat start
service heartbeat restart
10.修改系统自动启动屏蔽ARP(针对realserver)
修改/etc/rc.local
#!/bin/sh
#
# This script. will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style. init stuff.
touch /var/lock/subsys/local
service httpd stop
service httpd start
/etc/init.d/ DRlvs_Realserver
11.配置realserver健康检查页面
Echo ‘Test Page’ >>/var/www/html/healthy.html
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8404772/viewspace-609251/ ,如需转载,请注明出处,否则将追究法律责任。