Linux 下安装及配置Heartbeat(6)

示例文件描述
[root@orasrv1 ha.d]# more 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!

3、haresources 资源配置
haresources文件用于指定集群系统的节点、集群IP、子网掩码、广播地址以及启动的相关服务等。
其配置语句格式如下:
    node-name  network-config resouce-group
node-name:指定集群系统的节点名称,取值必须匹配ha.cf文件中node选项设置的主机名中的相同。   
network-config:用于网络设置,包括指定集群IP、子网掩码、广播地址等。
resource-group:用于设置heartbeat管理的相关集群服务,也就是这些服务可以由Heartbeat来启动和关闭。
对于使用heartbeat接管的相关服务,必须将服务写成可以通过start/stop来启动和关闭的脚步,然后放到/etc /init.d/
或者/etc/ha.d/resource.d/目录下,Heartbeat(TE)会根据脚本的名称自动去上述目录下找到相应脚本进行启动或关闭操作。

示例描述:
node1 IPaddr::192.168.21.10/24/eth0/  Filesystem:: /dev/sdb2::/webdata::ext3  httpd tomcat

node1:
    节点名称

IPaddr::192.168.21.10/24/eth0/
    IPaddr为heartbeat提供的一个脚本,位于/etc/ha.d/resource.d目录
    执行/etc/ha.d/resource.d/IPaddr 192.168.21.10/24 start的操作
    虚拟出一个子网掩码为255.255.255.0,IP为192.168.21.10的地址。
    此IP为Heartbeat对外提供服务的网络地址,同时指定此IP使用的网络接口为eth0

Filesystem:: /dev/sdb2::/webdata::ext3
    Filesystem为heartbeat提供的一个脚本,位于/etc/ha.d/resource.d目录
    执行共享磁盘分区的挂载操作,等同于命令行下的mount -t ext3 /dev/sdb2 /webdata

httpd tomcat
    依次启动httpd,以及tomcat服务

注:对于多个网络接口,不同子网的情行,IP地址,通常会使用别名绑定在跟VIP在同一网段内的网络接口上。
如: eth0 : 172.16.100.6  eth1 : 192.168.0.6 VIP : 172.16.100.5
则VIP 会绑定在eth0上,因为2个地址在同一网段,由这个命令来完成/usr/lib64/heartbeat/findif

示例文件描述 
[root@orasrv1 ha.d]# more 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.
#      集群中的节点停机和启动时,这里配置的资源列表会从一个节点转移到另一个节点,
#      不过资源列表中不要包含管理或已经配置在服务器上的IP地址在这个文件中。
# <VERY IMPORTANT NOTE>
#      The haresources files MUST BE IDENTICAL on all nodes of the cluster.
#      此haresources文件在所有的集群节点中都必须相同
#
#      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.
#
#      列在resource组信息前的节点名称是主机的hostname,它不需要是当前机器的名称,如果你配置auto_failback on
#      (或者legacy),那么这些服务将会在首选的节点上启动,只要主机是运行的。
#
#      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.
#      如果你配置的是auto_failback off,在集群重构或者使用hb_standby {foreign,local}命令,节点信息将被使用
#
#      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.
#      但是对于所有的这些情况,此haresources文件都必须相同。如果你的文件不同那么肯定有某些功能将不能正常工作。
# </VERY IMPORTANT NOTE>
#
#
#      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
#      安装时把它放到/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 ("\").
#
#      在文件里面的每个逻辑行组成一个“resource group”,下简称资源组
#      一个资源组就是从一个节点切换到另一个节点时的资源顺序列表。
#      假定不同的资源组之间是没有关系的,资源组的启动时是从左到右的。关闭时是从右到左的。
#      过长的resources列表可以以反斜杠(“\”)结尾来续行。
#
#      These resources in this file are either IP addresses, or the name
#      of scripts to run to "start" or "stop" the given resource.
#      在这个文件里面的resources可以是IP地址,也可以是用于“start”或“stop”给定的resource的脚本名称
#
#      The format is like this:
#      样例
#
#node-name resource1 resource2 ... resourceN
#
#
#      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.
#      在IP地址的情况中,resource脚本名称IPaddr是隐含的。
#
#      For example, the IP address 135.9.8.7 could also be represented
#      as IPaddr::135.9.8.7
#      例如:IP地址135.9.8.7也可以被表示为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.
#      给定的IP地址会直接连到有路由到给定的地址的接口上,
#      这也就意味着你必须要在 High-Availability 外部配置一个网络路由。
#
#      The broadcast address for the IP alias that is created to support
#      an IP address defaults to the highest address on the subnet.
#      IP别名的广播地址将被缺省创建为支持IP地址的子网里的最高地址
#     
#      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.
#      IP别名的子网掩码将被缺省创建为与上一步骤选择的路由相同的子网掩码
#
#      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.
#      IP别名的基础接口将被缺省创建为与上面选择的路由相同的子网掩码
#
#      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
#      如果你希望指明要增加地址的接口是eth0,那么你需要像这样指定 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
#      同时指定广播地址和接口的方法为: 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.
#      这个文件中的IP地址列表,叫做服务地址,它们是客户端用于获取高可用服务的公共通告地址
#
#      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.
#      对于一个双机热备(非共享负载)单服务地址的系统,你可能只需要放置一个系统名称和一个IP地址在这里。
#      你指定的地址对应的名字就是缺省的"hot"系统的名字。
#
#      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.
#      节点名称就是正常情况下拥有resource的节点的名称。
#      如果此机器是up的,他将一直拥有显示的resource。
#
#      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.
#      节点名应当与uname -n查看的结果一致
#-------------------------------------------------------------------
#
#      Simple case: One service address, default subnet and netmask
#              No servers that go up and down with the IP address
#      单服务地址,缺省子网和掩码,没有服务与IP地址一起启动和关闭
#
#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...
#      假定管理地址在相同的子网...
#      稍微复杂一些的情况:一个服务地址,缺省子网和子网掩码,同时你想要获得IP地址的时候启动和停止http。
#
#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...
#      稍微复杂一些的情况:三个服务地址,缺省子网和掩码,同时你要在获得IP地址的时候启动和停止http。
#
#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.
#

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/72eed8338f177d4cfcf58d3b151046a9.html