从头开始搭建集群(一)

在Fedora上面创建主/主和主备集群
Andrew Beekhof从头开始搭建集群
Pacemaker 1.1 从头开始搭建集群
在Fedora上面创建主/主和主备集群
版 3
作者 Andrew Beekhof andrew@beekhof.net
译者 Raoul Scarazzini rasca@miamammausalinux.org
Copyright ? 2010 Andrew Beekhof.
The text of and illustrations in this document are licensed under a Creative Commons
Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is
available at http://creativecommons.org/licenses/by-sa/3.0/.
In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you
must provide the URL for the original version.
In addition to the requirements of this license, the following activities are looked upon
favorably:
1. If you are distributing Open Publication works on hardcopy or CD-ROM, you provide email
notification to the authors of your intent to redistribute at least thirty days before
your manuscript or media freeze, to give the authors time to provide updated documents.
This notification should describe modifications, if any, made to the document.
2. All substantive modifications (including deletions) be either clearly marked up in the
document or else described in an p_w_upload to the document.
3. Finally, while it is not mandatory under this license, it is considered good form to
offer a free copy of any hardcopy or CD-ROM expression of the author(s) work.
本文档的主要目的是提供一站式指南,教您如何使用Pacemaker创建一个主/备模式的集群并把它转换到
主/主模式。
示例集群会使用以下软件:
1. Fedora 13 作为基本操作系统
2. Corosync作为通信层和提供关系管理服务
3. Pacemaker来实现资源管理
4. DRBD 作为一个经济的共享存储方案
5. GFS2 作为集群文件系统(主/主模式中)
6. crm shell 来显示并修改配置文件
虽然给出了图形化安装Fedora的过程,并且有很多截图,但是本文的主要是靠命令来操作,包括为什么
要运行这个命令和这些操作产生的结果。(译者注:本文中基本是crm shell来操作的,这里应该是老版
本文档的遗留)iii
目录
前言  ?????????????????????????????????????????????????????????????????????????????????   ix
1. 文档约定  .....................................................................   ix
1.1. 排版约定  ..............................................................   ix
1.2. 抬升式引用约定  .........................................................   x
1.3. 备注及警告  ............................................................   xi
2. We Need Feedback!  ............................................................  xi
1. Read-Me-First  ??????????????????????????????????????????????????????????????????????   1
1.1. 本文范围  ....................................................................   1
1.2. 什么是Pacemaker?  ............................................................   1
1.3. Pacemaker 集群的种类  ........................................................   2
1.4. Pacemaker 架构  ..............................................................   3
1.4.1. 内部组件  .............................................................   4
2. 安装  ???????????????????????????????????????????????????????????????????????????????   7
2.1. 安装操作系统  ................................................................   7
2.2. 集群软件安装  ...............................................................   15
2.2.1. 安全提示  ............................................................   16
2.2.2. 安装集群软件  .........................................................  17
2.3. 写在开始之前  ...............................................................   20
2.4. 安装  .......................................................................   20
2.4.1. 设定网络  ............................................................   20
2.4.2. 配置SSH  .............................................................   21
2.4.3. 简化节点名称  .........................................................  22
2.4.4. 配置 Corosync  .......................................................   23
2.4.5. 传送配置文件  .........................................................  24
3. 检验集群的安装  ????????????????????????????????????????????????????????????????????   27
3.1. 检验Corosync的安装  .........................................................   27
3.2. 检查Pacemaker的安装  ........................................................   27
4. 使用Pacemaker工具  ?????????????????????????????????????????????????????????????????   31
5. 创建一个主/备集群  ?????????????????????????????????????????????????????????????????   33
5.1. 浏览现有配置  ...............................................................   33
5.2. 添加一个资源  ...............................................................   34
5.3. 做一次失效备援  .............................................................   36
5.3.1. 法定人数和双节点集群  .................................................  36
5.3.2. 防止资源在节点恢复后移动  .............................................  37
6. Apache - 添加更多的服务  ???????????????????????????????????????????????????????????  39
6.1. 安装Apache  .................................................................   39
6.2. 准备工作  ...................................................................   41
6.3. 开启 Apache status URL  ....................................................   41
6.4. 更新配置文件  ...............................................................   41
6.5. 确保资源在同一个节点运行  ...................................................   42
6.6. 控制资源的启动停止顺序  .....................................................   43
6.7. 指定优先的 Location  ........................................................   43
6.8. 在集群中手工地移动资源  .....................................................   44
6.8.1. 把控制权交还给集群  ...................................................  45
7. 用DRBD同步存储  ????????????????????????????????????????????????????????????????????   47
7.1. 安装DRBD软件包  .............................................................   47
7.2. 配置DRBD  ...................................................................   48
7.2.1. 为DRBD创建一个分区  ...................................................  48从头开始搭建集群
iv
7.2.2. 配置DRBD  ............................................................   48
7.2.3. 初始化并载入DRBD  .....................................................  49
7.2.4. 向DRBD中添加数据  .....................................................  50
7.3. 在集群中配置DRBD  ...........................................................   51
7.3.1. 迁移测试  ............................................................   54
8. 转变为Active/Active  ???????????????????????????????????????????????????????????????   57
8.1. 需求  .......................................................................   57
8.2. 安装一个集群文件系统 - GFS2  ................................................   57
8.3. 整合 Pacemaker-GFS2  ........................................................   58
8.3.1. 添加 DLM 服务  .......................................................   59
8.3.2. 添加 GFS2 服务  ......................................................   60
8.4. 创建一个 GFS2 文件系统  .....................................................   61
8.4.1. 准备工作  ............................................................   61
8.4.2. 创建并迁移数据到 GFS2 分区  ..........................................   62
8.5. 8.5. 重新为集群配置GFS2  ....................................................   63
8.6. 重新配置 Pacemaker 为 Active/Active ........................................  64
8.6.1. 恢复测试  ............................................................   67
9. 配置 STONITH  ??????????????????????????????????????????????????????????????????????  69
9.1. 为什么需要 STONITH  .........................................................   69
9.2. 你该用什么样的STONITH设备。  .................................................  69
9.3. 配置STONITH  ................................................................   69
9.3.1. 例子  ................................................................   70
A. 配置扼要重述  ??????????????????????????????????????????????????????????????????????   73
A.1. 最终的集群配置文件  .........................................................   73
A.2. 节点列表  ...................................................................   74
A.3. 集群选项  ...................................................................   74
A.4. 资源  .......................................................................   74
A.4.1. 默认选项  ............................................................   74
A.4.2. 隔离  ................................................................   75
A.4.3. 服务地址  ............................................................   75
A.4.4. 分布式锁控制器  .......................................................  75
A.4.5. GFS 控制守护进程  ....................................................   75
A.4.6. DRBD - 共享存储  .....................................................   76
A.4.7. 集群文件系统  .........................................................  76
A.4.8. Apache  ..............................................................   76
B. Sample Corosync Configuration  ?????????????????????????????????????????????????????  77
C. Using CMAN for Cluster Membership and Quorum ?????????????????????????????????????  79
C.1. Background  .................................................................   79
C.2. Adding CMAN Support  ........................................................  79
C.2.1. Adding CMAN Support - cluster.conf ..................................  79
C.2.2. Adding CMAN Support - corosync.conf .................................  80
D. 延伸阅读  ??????????????????????????????????????????????????????????????????????????   83
E. 修订历史  ??????????????????????????????????????????????????????????????????????????   85
索引  ?????????????????????????????????????????????????????????????????????????????????   87v
插图清单
1.1. Active/Passive 冗余  ..............................................................   2
1.2. 共享失效备援  .....................................................................   2
1.3. N to N 冗余  .....................................................................   3
1.4. 概念层次总览  .....................................................................   3
1.5. Pacemaker 层次  ...................................................................  4
1.6. 内部组件  .........................................................................   5
2.1. 安装Fedora - 欢迎    ..............................................................   7
2.2. 安装Fedora - 存储设备  ...........................................................   8
2.3. 安装Fedora -机器名  ...............................................................   8
2.4. 安装Fedora - 安装类型  ...........................................................   9
2.5. 安装Fedora - 默认分区  ...........................................................   9
2.6. 安装Fedora - 自定义分区  .........................................................  10
2.7. 安装Fedora - Bootloader  .........................................................  10
2.8. 安装Fedora - 软件  ..............................................................   11
2.9. 安装Fedora - 安装中  ............................................................   11
2.10. 安装Fedora - 安装完成  ..........................................................  12
2.11. 安装Fedora - 第一次启动  ........................................................  12
2.12. 安装Fedora - 创建非特权用户  ....................................................  13
2.13. 安装Fedora - 日期和时间  ........................................................  13
2.14. 安装Fedora -自定义网络  .........................................................   14
2.15. 安装Fedora - 指定网络参数  ......................................................  14
2.16. 安装Fedora - 激活网络  ..........................................................  15
2.17. 安装Fedora - 打开终端  ..........................................................  15
2.18. 通过IP地址来检查连接  ...........................................................   21
2.19. 否则,我们修改/etc/hosts文件来达到相同的效果: ................................... 21
2.20. 通过机器名检查连接  .............................................................   21
2.21. 创建并激活一个新的SSH密钥  ......................................................   22
2.22. 在另一个机器上面安装SSH密钥  ....................................................   22vivii
范例清单
B.1. Sample Corosync.conf for a two-node cluster ..................................... 77
C.1. Sample cluster.conf for a two-node cluster ...................................... 80
C.2. Sample corosync.conf extensions for a two-node cluster ..........................  80viiiix
前言
目录
1. 文档约定  ..........................................................................   ix
1.1. 排版约定  ...................................................................   ix
1.2. 抬升式引用约定  ..............................................................   x
1.3. 备注及警告  .................................................................   xi
2. We Need Feedback!  ................................................................   xi
前言
Read-Me-First
目录
1.1. 本文范围  .........................................................................   1
1.2. 什么是Pacemaker?  .................................................................   1
1.3. Pacemaker 集群的种类  .............................................................   2
1.4. Pacemaker 架构  ...................................................................  3
1.4.1. 内部组件  ..................................................................   4
1.1.?本文范围 本文的目的是透彻地解释用于配置Pacemaker的概念。为了达到最好的效果,本文会主要关注于用于配
置CIB的XML格式。
对于那些特别讨厌XML的人,Pacemaker有一个集群shell和基于Python的GUI,但是本文没有包含这些工
具的使用 1
 , 正是因为它们隐藏了XML细节。(译者注:本文中基本是crm shell来操作的,这里应该是
老版本文档的遗留)
此外,本文不是一个手把手地教你配置特定集群方案的how-to guide。尽管有很多这样的内容,但是本
文的主要目的是让大家理解配置Pacemaker所需要用到的各种组件。
1.2.?什么是Pacemaker?
Pacemaker是一个集群资源管理者。他用资源级别的监测和恢复来保证集群服务(aka. 资源)的最大可用
性。它可以用你所擅长的基础组件(Corosync或者是Heartbeat)来实现通信和关系管理。
Pacemaker包含以下的关键特性:
监测并恢复节点和服务级别的故障
存储无关,并不需要共享存储
资源无关,任何能用脚本控制的资源都可以作为服务
支持使用STONITH2
来保证数据一致性。
支持大型或者小型的集群
clusters 支持 quorate(法定人数)3
 或 resource(资源)4
 驱动的集群
支持任何的 冗余配置5
自动同步各个节点的配置文件
可以设定集群范围内的ordering, colocation and anti-colocation
支持高级的服务模式
Clones:为那些要在多个节点运行的服务所准备的
1
 明白了本文的内容以后,会更容易理解那些工具的功能,当然这只是希望。第?1?章?Read-Me-First
2
?Multi-state:为那些有多种模式的服务准备的。(比如.主从, 主备)
?统一的,可脚本控制的cluster shell
1.3.?Pacemaker 集群的种类 Pacemaker对你的环境没有特定的要求,这使得它支持任何的冗余配置,包括 Active/Active, Active/
Passive, N+1, N+M, N-to-1 and N-to-N。
使用Pacemaker和DRBD的双节点主备方案作为一种经济的解决方案被很多高可用环境所采用。
图?1.1.?Active/Passive 冗余
正是因为支持很多节点,Pacemaker可以让多个主备模式的集
群集成起来并共享一个备用节点,从而大幅度的减少硬件成本
图?1.2.?共享失效备援Pacemaker 架构
3
当有共享存储设备是,每个节点都成为潜在的备援节点。
Pacemaker甚至可以在不同的节点上跑相同的服务来负载均衡。
图?1.3.?N to N 冗余
1.4.?Pacemaker 架构 在最高一个层次,集群由三个部分组成:
?提供消息和集群关系功能的集群核心基础组件(标红的部分)
?集群无关的组件(蓝色的部分)。在Pacemaker架构中,这部分不仅包含有怎么样启动,关闭,监控资
源的脚本,而且还有一个本地的守护进程来消除这些脚本实现的(采用的)不同标准之间的差异
?大脑(绿色部分)处理并响应来自集群和资源的事件(比如节点的离开和加入,资源的失效) ,以及管
理员对配置文件的修改。在对所有这些事件的响应中,Pacemaker会计算集群理想的状态,并规划一
个途径来实现它。这个操作可能会包含移动资源,停止节点,甚至使用远程电源管理来强制使他们下
线。
集群概念层次总览
图?1.4.?概念层次总览第?1?章?Read-Me-First
4
当与Corosync集成时,Pacemaker也支持常见的开源集群文件系统 6
,根据来着集群文件系统社区的最新
标准,他们用一个通用的分布式锁控制器,它靠Corosync通信并且用Pacemaker管理成员关系(哪些节点
是开启或关闭的)和隔离服务。
Pacemaker采用Corosync时的层次
图?1.5.?Pacemaker 层次
1.4.1.?内部组件
Pacemaker本身由四个关键组件组成:
?CIB (aka. 集群信息基础)
?CRMd (aka. 集群资源管理守护进程)
?PEngine (aka. PE or 策略引擎)
?STONITHd
6
 尽管Pacemaker也支持Heartbeat,但是文件系统也要用基层软件来通信和维护节点关系,Corosync看来是他们的标准,技术上
来说,让它们支持Heartbeat也是可能的,但是看起来他们没多大兴趣内部组件
5
基于Corosync的Pacemaker的子系统
图?1.6.?内部组件
CIB用XML来展示集群的配置和资源的当前状态。 CIB的内容会自动地在集群之间同步,并被PEngine用
来来计算集群的理想状态和如何达到这个理想状态。
这个指令列表然后会被交给DC(指定协调者)。 Pacemaker会推举一个CRMd实例作为master来集中做出所
有决策。如果推举的CRMd繁忙中,或者这个节点不够稳定... 一个新的master会马上被推举出来。
DC会按顺序处理PEngine的指令,然后把他们发送给LRMd(本地资源管理守护进程) 或者通过集群消息层
发送给其他CRMd成员(就是把这些指令依次传给LRMd)。
节点会把他们所有操作的日志发给DC,然后根据预期的结果和实际的结果(之间的差异), 执行下一个
等待中的命令,或者取消操作,并让PEngine根据非预期的结果重新计算集群的理想状态。
在某些情况下,可能会需要关闭节点的电源来保证共享数据的完整性或是完全地恢复资源。为此
Pacemaker引入了STONITHd。STONITH是 Shoot-The-Other-Node-In-The-Head(爆其他节点的头)的缩写
,并且通常是靠远程电源开关来实现的。在Pacemaker中,STONITH设备被当成资源(并且是在CIB中配置
)从而轻松地监控,然而STONITHd会注意理解STONITH拓扑,比如它的客户端请求隔离一个节点,它会重
启那个机器。(译者注:就是说不同的爆头设备驱动会对相同的请求有不同的理解,这些都是在驱动中定
义的。)6第?2
7
安装
目录
2.1. 安装操作系统  .....................................................................   7
2.2. 集群软件安装  ....................................................................   15
2.2.1. 安全提示  .................................................................   16
2.2.2. 安装集群软件  .............................................................   17
2.3. 写在开始之前  ....................................................................   20
2.4. 安装  ............................................................................   20
2.4.1. 设定网络  .................................................................   20
2.4.2. 配置SSH  ..................................................................   21
2.4.3. 简化节点名称  .............................................................   22
2.4.4. 配置 Corosync  ............................................................   23
2.4.5. 传送配置文件  .............................................................   24
2.1.?安装操作系统 详细的安装手册在http://docs.fedoraproject.org/install-guide/f13/。下文是一个简短的版本...
在你的浏览器中打开 http://fedoraproject.org/en/get-fedora-all,找到Install Media部分并下载
适合你硬件的安装DVD文件。
烧录一个DVD光盘 1
 并从它启动。或者就像我一样启动一个虚拟机。 在点击欢迎界面的NETX后 ,我们
要开始选择语言和键盘类型 2
安装Fedora: 好的选择!
图?2.1.?安装Fedora - 欢迎
1
  http://docs.fedoraproject.org/readme-burning-isos/en-US.html  [http://docs.fedoraproject.org/readme-burning-
isos/en-US.html]
2
  http://docs.fedoraproject.org/install-guide/f13/en-US/html/s1-langselection-x86.html  [http://
docs.fedoraproject.org/install-guide/f13/en-US/html/s1-langselection-x86.html]第?2?章?安装
8
安装Fedora: 存储设备
图?2.2.?安装Fedora - 存储设备
给你的机器取个名字。3
 我可以使用clusterlabs.org这个域名,所以在这里我用这个域名。
安装Fedora: 选择一个机器名
图?2.3.?安装Fedora -机器名
然后你会被提示选择机器所在地并设定root密码。4
3
  http://docs.fedoraproject.org/install-guide/f13/en-US/html/sn-networkconfig-fedora.html  [http://
docs.fedoraproject.org/install-guide/f13/en-US/html/sn-networkconfig-fedora.html]
4
  http://docs.fedoraproject.org/install-guide/f13/en-US/html/sn-account_configuration.html  [http://
docs.fedoraproject.org/install-guide/f13/en-US/html/sn-account_configuration.html]安装操作系统
9
如然后你选择想在哪安装Fedora 5
。 如果你像我一样不在意已存在的数据,就选择默认让Fedora来
使用完整的驱动器。然而我想为DRBD保留一些空间,所以我勾选了Review and modify partitioning
layout。
安装Fedora: 选择安装类型
图?2.4.?安装Fedora - 安装类型
默认的话,Fedora会将所有的空间都分配给/ (aka. 根)分区。我们要保留一点给DRBD。
图?2.5.?安装Fedora - 默认分区
5
 http://docs.fedoraproject.org/install-guide/f13/en-US/html/s1-diskpartsetup-x86.html第?2?章?安装
10
完整的分区应该像下面一样。
重要
如果你想试验本文档中关于DRBD或者GFS2的部分,你要为每个节点保留至少1Gb的空间。
安装Fedora: 创建一个网站存放数据用的分区
图?2.6.?安装Fedora - 自定义分区
安装Fedora: 除非有非常强力的理由,不然选择默认的bootloader安装位置
图?2.7.?安装Fedora - Bootloader安装操作系统
11
然后我们选择应该安装什么软件。因为我们想用Apache,所以选择Web Server。现在不要开启Update源
,我们一会操作它。点击下一步,开始安装Fedora。
安装Fedora: 软件选择
图?2.8.?安装Fedora - 软件
安装Fedora: 去搞点东西喝喝 这要一会儿
图?2.9.?安装Fedora - 安装中第?2?章?安装
12
安装Fedora: Stage 1, 完成
图?2.10.?安装Fedora - 安装完成
一旦系统重启完毕你可以看到以下界面 6
 ,然后配置用户和设定时间。
图?2.11.?安装Fedora - 第一次启动
6
  http://docs.fedoraproject.org/install-guide/f13/en-US/html/ch-firstboot.html  [http://docs.fedoraproject.org/
install-guide/f13/en-US/html/ch-firstboot.html]安装操作系统
13
安装Fedora: 创建非特权用户,请注意密码,一会你要用到它的。
图?2.12.?安装Fedora - 创建非特权用户
注意
强烈建议开启NTP时间同步,这样可以使集群更好的同步配置文件以及使日志文件有更好的可读性

安装Fedora : 启用NTP来保证所有节点时间同步
图?2.13.?安装Fedora - 日期和时间
点击next会进入登入界面,点击你创建的用户并输入之前设定的密码。第?2?章?安装
14
安装Fedora: 点击这里来配置网络
图?2.14.?安装Fedora -自定义网络
重要
不要使用默认的网络设置,集群永远不会靠DHCP来管理IP,这里我使用clusterslab的内部IP。
安装Fedora: 设定你的网络,永远不要选择DHCP
图?2.15.?安装Fedora - 指定网络参数集群软件安装
15
安装Fedora:点击绿色按钮来应用你的更改
图?2.16.?安装Fedora - 激活网络
安装Fedora:开始干活,打开终端
图?2.17.?安装Fedora - 打开终端
注意
这是最后一个截屏了,剩下的我们都用命令行来操作。
2.2.?集群软件安装 打开一个终端,然后使用su命令切换到超级用户(root)。输入之前安装时候设定的密码:第?2?章?安装
16
[beekhof@pcmk-1 ~]$ su -
Password:
[root@pcmk-1 ~]#
注意
注意用户名 (@符号左边的字符串) 显示我们现在使用的是root用户.
[root@pcmk-1 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:0c:29:6f:e1:58 brd ff:ff:ff:ff:ff:ff
    inet 192.168.9.41/24 brd 192.168.9.255 scope global eth0
    inet6 ::20c:29ff:fe6f:e158/64 scope global dynamic
       valid_lft 2591667sec preferred_lft 604467sec
    inet6 2002:57ae:43fc:0:20c:29ff:fe6f:e158/64 scope global dynamic
       valid_lft 2591990sec preferred_lft 604790sec
    inet6 fe80::20c:29ff:fe6f:e158/64 scope link
       valid_lft forever preferred_lft forever
[root@pcmk-1 ~]# ping -c 1 www.google.com
PING www.l.google.com (74.125.39.99) 56(84) bytes of data.
64 bytes from fx-in-f99.1e100.net (74.125.39.99): icmp_seq=1 ttl=56 time=16.7 ms
--- www.l.google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 20ms
rtt min/avg/max/mdev = 16.713/16.713/16.713/0.000 ms
[root@pcmk-1 ~]# /sbin/chkconfig network on
[root@pcmk-1 ~]#
2.2.1.?安全提示
为了简化本文档并更好的关注集群方面的问题,我们现在在先禁用防火墙和SELinux。这些操作都会导
致重大的安全问题,并不推荐对公网上的集群这样做。
重要
TODO: Create an Appendix that deals with (at least) re-enabling the firewall.
[root@pcmk-1 ~]# sed -i.bak "s/SELINUX=enforcing/SELINUX=permissive/g" /etc/selinux/config
[root@pcmk-1 ~]# /sbin/chkconfig --del iptables
[root@pcmk-1 ~]# service iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]安装集群软件
17
重要
你需要重启来保证SELinux正确关闭。不然你启动corosync的时候将看到以下提示:
May  4 19:30:54 pcmk-1 setroubleshoot: SELinux is preventing /usr/sbin/corosync "getattr" access on /. For
 complete SELinux messages. run sealert -l 6e0d4384-638e-4d55-9aaf-7dac011f29c1
May  4 19:30:54 pcmk-1 setroubleshoot: SELinux is preventing /usr/sbin/corosync "getattr" access on /. For
 complete SELinux messages. run sealert -l 6e0d4384-638e-4d55-9aaf-7dac011f29c1
2.2.2.?安装集群软件
从Fedora 12开始,你需要的东西都已经准备好了,只需在终端命令行运行以下命令:
[root@pcmk-1 ~]# sed -i.bak "s/enabled=0/enabled=1/g" /etc/yum.repos.d/fedora.repo
[root@pcmk-1 ~]# sed -i.bak "s/enabled=0/enabled=1/g" /etc/yum.repos.d/fedora-updates.repo
[root@pcmk-1 ~]# yum install -y pacemaker corosync
Loaded plugins: presto, refresh-packagekit
fedora/metalink                                               |  22 kB     00:00    
fedora-debuginfo/metalink                                     |  16 kB     00:00    
fedora-debuginfo                                              | 3.2 kB     00:00    
fedora-debuginfo/primary_db                                   | 1.4 MB     00:04    
fedora-source/metalink                                        |  22 kB     00:00    
fedora-source                                                 | 3.2 kB     00:00    
fedora-source/primary_db                                      | 3.0 MB     00:05    
updates/metalink                                              |  26 kB     00:00    
updates                                                       | 2.6 kB     00:00    
updates/primary_db                                            | 1.1 kB     00:00    
updates-debuginfo/metalink                                    |  18 kB     00:00    
updates-debuginfo                                             | 2.6 kB     00:00    
updates-debuginfo/primary_db                                  | 1.1 kB     00:00    
updates-source/metalink                                       |  25 kB     00:00    
updates-source                                                | 2.6 kB     00:00    
updates-source/primary_db                                     | 1.1 kB     00:00    
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package corosync.x86_64 0:1.2.1-1.fc13 set to be updated
--> Processing Dependency: corosynclib = 1.2.1-1.fc13 for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libquorum.so.4(COROSYNC_QUORUM_1.0)(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libvotequorum.so.4(COROSYNC_VOTEQUORUM_1.0)(64bit) for package:
 corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libcpg.so.4(COROSYNC_CPG_1.0)(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libconfdb.so.4(COROSYNC_CONFDB_1.0)(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libcfg.so.4(COROSYNC_CFG_0.82)(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libpload.so.4(COROSYNC_PLOAD_1.0)(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: liblogsys.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libconfdb.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libcoroipcc.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libcpg.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libquorum.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libcoroipcs.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libvotequorum.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libcfg.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libtotem_pg.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libpload.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
---> Package pacemaker.x86_64 0:1.1.5-1.fc13 set to be updated
--> Processing Dependency: heartbeat >= 3.0.0 for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: net-snmp >= 5.4 for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: resource-agents for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: cluster-glue for package: pacemaker-1.1.5-1.fc13.x86_64第?2?章?安装
18
--> Processing Dependency: libnetsnmp.so.20()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libcrmcluster.so.1()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libpengine.so.3()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libnetsnmpagent.so.20()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libesmtp.so.5()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libstonithd.so.1()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libhbclient.so.1()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libpils.so.2()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libpe_status.so.2()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libnetsnmpmibs.so.20()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libnetsnmphelpers.so.20()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libcib.so.1()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libccmclient.so.1()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libstonith.so.1()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: liblrm.so.2()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libtransitioner.so.1()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libpe_rules.so.2()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libcrmcommon.so.2()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libplumb.so.2()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Running transaction check
---> Package cluster-glue.x86_64 0:1.0.2-1.fc13 set to be updated
--> Processing Dependency: perl-TimeDate for package: cluster-glue-1.0.2-1.fc13.x86_64
--> Processing Dependency: libOpenIPMIutils.so.0()(64bit) for package: cluster-glue-1.0.2-1.fc13.x86_64
--> Processing Dependency: libOpenIPMIposix.so.0()(64bit) for package: cluster-glue-1.0.2-1.fc13.x86_64
--> Processing Dependency: libopenhpi.so.2()(64bit) for package: cluster-glue-1.0.2-1.fc13.x86_64
--> Processing Dependency: libOpenIPMI.so.0()(64bit) for package: cluster-glue-1.0.2-1.fc13.x86_64
---> Package cluster-glue-libs.x86_64 0:1.0.2-1.fc13 set to be updated
---> Package corosynclib.x86_64 0:1.2.1-1.fc13 set to be updated
--> Processing Dependency: librdmacm.so.1(RDMACM_1.0)(64bit) for package: corosynclib-1.2.1-1.fc13.x86_64
--> Processing Dependency: libibverbs.so.1(IBVERBS_1.0)(64bit) for package: corosynclib-1.2.1-1.fc13.x86_64
--> Processing Dependency: libibverbs.so.1(IBVERBS_1.1)(64bit) for package: corosynclib-1.2.1-1.fc13.x86_64
--> Processing Dependency: libibverbs.so.1()(64bit) for package: corosynclib-1.2.1-1.fc13.x86_64
--> Processing Dependency: librdmacm.so.1()(64bit) for package: corosynclib-1.2.1-1.fc13.x86_64
---> Package heartbeat.x86_64 0:3.0.0-0.7.0daab7da36a8.hg.fc13 set to be updated
--> Processing Dependency: PyXML for package: heartbeat-3.0.0-0.7.0daab7da36a8.hg.fc13.x86_64
---> Package heartbeat-libs.x86_64 0:3.0.0-0.7.0daab7da36a8.hg.fc13 set to be updated
---> Package libesmtp.x86_64 0:1.0.4-12.fc12 set to be updated
---> Package net-snmp.x86_64 1:5.5-12.fc13 set to be updated
--> Processing Dependency: libsensors.so.4()(64bit) for package: 1:net-snmp-5.5-12.fc13.x86_64
---> Package net-snmp-libs.x86_64 1:5.5-12.fc13 set to be updated
---> Package pacemaker-libs.x86_64 0:1.1.5-1.fc13 set to be updated
---> Package resource-agents.x86_64 0:3.0.10-1.fc13 set to be updated
--> Processing Dependency: libnet.so.1()(64bit) for package: resource-agents-3.0.10-1.fc13.x86_64
--> Running transaction check
---> Package OpenIPMI-libs.x86_64 0:2.0.16-8.fc13 set to be updated
---> Package PyXML.x86_64 0:0.8.4-17.fc13 set to be updated
---> Package libibverbs.x86_64 0:1.1.3-4.fc13 set to be updated
--> Processing Dependency: libibverbs-driver for package: libibverbs-1.1.3-4.fc13.x86_64
---> Package libnet.x86_64 0:1.1.4-3.fc12 set to be updated
---> Package librdmacm.x86_64 0:1.0.10-2.fc13 set to be updated
---> Package lm_sensors-libs.x86_64 0:3.1.2-2.fc13 set to be updated
---> Package openhpi-libs.x86_64 0:2.14.1-3.fc13 set to be updated
---> Package perl-TimeDate.noarch 1:1.20-1.fc13 set to be updated
--> Running transaction check
---> Package libmlx4.x86_64 0:1.0.1-5.fc13 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================
 Package                Arch     Version                             Repository      Size
==========================================================================================
Installing:
 corosync               x86_64   1.2.1-1.fc13                        fedora         136 k安装集群软件
19
 pacemaker              x86_64   1.1.5-1.fc13                        fedora         543 k
Installing for dependencies:
 OpenIPMI-libs          x86_64   2.0.16-8.fc13                       fedora         474 k
 PyXML                  x86_64   0.8.4-17.fc13                       fedora         906 k
 cluster-glue           x86_64   1.0.2-1.fc13                        fedora         230 k
 cluster-glue-libs      x86_64   1.0.2-1.fc13                        fedora         116 k
 corosynclib            x86_64   1.2.1-1.fc13                        fedora         145 k
 heartbeat              x86_64   3.0.0-0.7.0daab7da36a8.hg.fc13      updates        172 k
 heartbeat-libs         x86_64   3.0.0-0.7.0daab7da36a8.hg.fc13      updates        265 k
 libesmtp               x86_64   1.0.4-12.fc12                       fedora          54 k
 libibverbs             x86_64   1.1.3-4.fc13                        fedora          42 k
 libmlx4                x86_64   1.0.1-5.fc13                        fedora          27 k
 libnet                 x86_64   1.1.4-3.fc12                        fedora          49 k
 librdmacm              x86_64   1.0.10-2.fc13                       fedora          22 k
 lm_sensors-libs        x86_64   3.1.2-2.fc13                        fedora          37 k
 net-snmp               x86_64   1:5.5-12.fc13                       fedora         295 k
 net-snmp-libs          x86_64   1:5.5-12.fc13                       fedora         1.5 M
 openhpi-libs           x86_64   2.14.1-3.fc13                       fedora         135 k
 pacemaker-libs         x86_64   1.1.5-1.fc13                        fedora         264 k
 perl-TimeDate          noarch   1:1.20-1.fc13                       fedora          42 k
 resource-agents        x86_64   3.0.10-1.fc13                       fedora         357 k
Transaction Summary
=========================================================================================
Install      21 Package(s)
Upgrade       0 Package(s)
Total download size: 5.7 M
Installed size: 20 M
Downloading Packages:
Setting up and reading Presto delta metadata
updates-testing/prestodelta                                           | 164 kB     00:00    
fedora/prestodelta                                                    |  150 B     00:00    
Processing delta metadata
Package(s) data still to download: 5.7 M
(1/21): OpenIPMI-libs-2.0.16-8.fc13.x86_64.rpm                        | 474 kB     00:00    
(2/21): PyXML-0.8.4-17.fc13.x86_64.rpm                                | 906 kB     00:01    
(3/21): cluster-glue-1.0.2-1.fc13.x86_64.rpm                          | 230 kB     00:00    
(4/21): cluster-glue-libs-1.0.2-1.fc13.x86_64.rpm                     | 116 kB     00:00    
(5/21): corosync-1.2.1-1.fc13.x86_64.rpm                              | 136 kB     00:00    
(6/21): corosynclib-1.2.1-1.fc13.x86_64.rpm                           | 145 kB     00:00    
(7/21): heartbeat-3.0.0-0.7.0daab7da36a8.hg.fc13.x86_64.rpm           | 172 kB     00:00    
(8/21): heartbeat-libs-3.0.0-0.7.0daab7da36a8.hg.fc13.x86_64.rpm      | 265 kB     00:00    
(9/21): libesmtp-1.0.4-12.fc12.x86_64.rpm                             |  54 kB     00:00    
(10/21): libibverbs-1.1.3-4.fc13.x86_64.rpm                           |  42 kB     00:00    
(11/21): libmlx4-1.0.1-5.fc13.x86_64.rpm                              |  27 kB     00:00    
(12/21): libnet-1.1.4-3.fc12.x86_64.rpm                               |  49 kB     00:00    
(13/21): librdmacm-1.0.10-2.fc13.x86_64.rpm                           |  22 kB     00:00    
(14/21): lm_sensors-libs-3.1.2-2.fc13.x86_64.rpm                      |  37 kB     00:00    
(15/21): net-snmp-5.5-12.fc13.x86_64.rpm                              | 295 kB     00:00    
(16/21): net-snmp-libs-5.5-12.fc13.x86_64.rpm                         | 1.5 MB     00:01    
(17/21): openhpi-libs-2.14.1-3.fc13.x86_64.rpm                        | 135 kB     00:00    
(18/21): pacemaker-1.1.5-1.fc13.x86_64.rpm                            | 543 kB     00:00    
(19/21): pacemaker-libs-1.1.5-1.fc13.x86_64.rpm                       | 264 kB     00:00    
(20/21): perl-TimeDate-1.20-1.fc13.noarch.rpm                         |  42 kB     00:00    
(21/21): resource-agents-3.0.10-1.fc13.x86_64.rpm                     | 357 kB     00:00    
----------------------------------------------------------------------------------------
Total                                                        539 kB/s | 5.7 MB     00:10    
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID e8e40fde: NOKEY
fedora/gpgkey                                                         | 3.2 kB     00:00 ...
Importing GPG key 0xE8E40FDE "Fedora (13) <fedora@fedoraproject.org%gt;" from /etc/pki/rpm-gpg/RPM-GPG-KEY-
fedora-x86_64
Running rpm_check_debug
Running Transaction Test第?2?章?安装
20
Transaction Test Succeeded
Running Transaction
  Installing     : lm_sensors-libs-3.1.2-2.fc13.x86_64                            1/21
  Installing     : 1:net-snmp-libs-5.5-12.fc13.x86_64                             2/21
  Installing     : 1:net-snmp-5.5-12.fc13.x86_64                                  3/21
  Installing     : openhpi-libs-2.14.1-3.fc13.x86_64                              4/21
  Installing     : libibverbs-1.1.3-4.fc13.x86_64                                 5/21
  Installing     : libmlx4-1.0.1-5.fc13.x86_64                                    6/21
  Installing     : librdmacm-1.0.10-2.fc13.x86_64                                 7/21
  Installing     : corosync-1.2.1-1.fc13.x86_64                                   8/21
  Installing     : corosynclib-1.2.1-1.fc13.x86_64                                9/21
  Installing     : libesmtp-1.0.4-12.fc12.x86_64                                 10/21
  Installing     : OpenIPMI-libs-2.0.16-8.fc13.x86_64                            11/21
  Installing     : PyXML-0.8.4-17.fc13.x86_64                                    12/21
  Installing     : libnet-1.1.4-3.fc12.x86_64                                    13/21
  Installing     : 1:perl-TimeDate-1.20-1.fc13.noarch                            14/21
  Installing     : cluster-glue-1.0.2-1.fc13.x86_64                              15/21
  Installing     : cluster-glue-libs-1.0.2-1.fc13.x86_64                         16/21
  Installing     : resource-agents-3.0.10-1.fc13.x86_64                          17/21
  Installing     : heartbeat-libs-3.0.0-0.7.0daab7da36a8.hg.fc13.x86_64          18/21
  Installing     : heartbeat-3.0.0-0.7.0daab7da36a8.hg.fc13.x86_64               19/21
  Installing     : pacemaker-1.1.5-1.fc13.x86_64                                 20/21
  Installing     : pacemaker-libs-1.1.5-1.fc13.x86_64                            21/21
Installed:
  corosync.x86_64 0:1.2.1-1.fc13                    pacemaker.x86_64 0:1.1.5-1.fc13                  
Dependency Installed:
  OpenIPMI-libs.x86_64 0:2.0.16-8.fc13                         
  PyXML.x86_64 0:0.8.4-17.fc13                                 
  cluster-glue.x86_64 0:1.0.2-1.fc13                           
  cluster-glue-libs.x86_64 0:1.0.2-1.fc13                      
  corosynclib.x86_64 0:1.2.1-1.fc13                            
  heartbeat.x86_64 0:3.0.0-0.7.0daab7da36a8.hg.fc13            
  heartbeat-libs.x86_64 0:3.0.0-0.7.0daab7da36a8.hg.fc13       
  libesmtp.x86_64 0:1.0.4-12.fc12                              
  libibverbs.x86_64 0:1.1.3-4.fc13                             
  libmlx4.x86_64 0:1.0.1-5.fc13                                
  libnet.x86_64 0:1.1.4-3.fc12                                 
  librdmacm.x86_64 0:1.0.10-2.fc13                             
  lm_sensors-libs.x86_64 0:3.1.2-2.fc13                        
  net-snmp.x86_64 1:5.5-12.fc13                                
  net-snmp-libs.x86_64 1:5.5-12.fc13                           
  openhpi-libs.x86_64 0:2.14.1-3.fc13                          
  pacemaker-libs.x86_64 0:1.1.5-1.fc13                         
  perl-TimeDate.noarch 1:1.20-1.fc13                           
  resource-agents.x86_64 0:3.0.10-1.fc13                       
Complete!
[root@pcmk-1 ~]#
2.3.?写在开始之前 在另一台Fedora 12机器上面重复以上操作步骤,这样你就有2台安装了集群软件的节点了。
在这篇文档中, 另外一个节点叫 pcmk-2 并且IP地址为 192.168.122.42。
2.4.?安装
2.4.1.?设定网络
确认这两个新节点能够通讯:配置SSH
21
   ping -c 3 192.168.122.102
[root@pcmk-1 ~]# ping -c 3 192.168.122.102
PING 192.168.122.102 (192.168.122.102) 56(84) bytes of data.
64 bytes from 192.168.122.102: icmp_seq=1 ttl=64 time=0.343 ms
64 bytes from 192.168.122.102: icmp_seq=2 ttl=64 time=0.402 ms
64 bytes from 192.168.122.102: icmp_seq=3 ttl=64 time=0.558 ms
--- 192.168.122.102 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.343/0.434/0.558/0.092 ms
图?2.18.?通过IP地址来检查连接
Now we need to make sure we can communicate with the machines by their name. If you have
a DNS server, add additional entries for the two machines. Otherwise, you’ll need to add
the machines to /etc/hosts . Below are the entries for my cluster nodes:
   grep pcmk /etc/hosts
[root@pcmk-1 ~]# grep pcmk /etc/hosts
192.168.122.101 pcmk-1.clusterlabs.org pcmk-1
192.168.122.102 pcmk-2.clusterlabs.org pcmk-2
图?2.19.?否则,我们修改/etc/hosts文件来达到相同的效果:
现在让我们ping一下:
   ping -c 3 pcmk-2
[root@pcmk-1 ~]# ping -c 3 pcmk-2
PING pcmk-2.clusterlabs.org (192.168.122.101) 56(84) bytes of data.
64 bytes from pcmk-1.clusterlabs.org (192.168.122.101): icmp_seq=1 ttl=64 time=0.164 ms
64 bytes from pcmk-1.clusterlabs.org (192.168.122.101): icmp_seq=2 ttl=64 time=0.475 ms
64 bytes from pcmk-1.clusterlabs.org (192.168.122.101): icmp_seq=3 ttl=64 time=0.186 ms
--- pcmk-2.clusterlabs.org ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.164/0.275/0.475/0.141 ms
图?2.20.?通过机器名检查连接
2.4.2.?配置SSH
SSH 是一个方便又安全来的用来远程传输文件或运行命令 的工具. 在这个文档中, 我们创建ssh
key(用 -N “” 选项)来免去登入要输入密码的麻烦。
警告
不推荐在公网的机器上采用未用密码保护的ssh-key
创建一个密钥并允许所有有这个密钥的用户登入第?2?章?安装
22
[root@pcmk-1 ~]# ssh-keygen -t dsa -f ~/.ssh/id_dsa -N ""
Generating public/private dsa key pair.
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
91:09:5c:82:5a:6a:50:08:4e:b2:0c:62:de:cc:74:44 root@pcmk-1.clusterlabs.org
The key's randomart p_w_picpath is:
+--[ DSA 1024]----+
|==.ooEo..        |
|X O + .o o       |
| * A    +        |
|  +      .       |
| .      S        |
|                 |
|                 |
|                 |
|                 |
+-----------------+
[root@pcmk-1 ~]# cp .ssh/id_dsa.pub .ssh/authorized_keys
[root@pcmk-1 ~]#
图?2.21.?创建并激活一个新的SSH密钥
在其他节点安装这个密钥并测试你是否可以执行命令而不用输入密码
[root@pcmk-1 ~]# scp -r .ssh pcmk-2:
The authenticity of host 'pcmk-2 (192.168.122.102)' can't be established.
RSA key fingerprint is b1:2b:55:93:f1:d9:52:2b:0f:f2:8a:4e:ae:c6:7c:9a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'pcmk-2,192.168.122.102' (RSA) to the list of known hosts.
root@pcmk-2's password:
id_dsa.pub                           100%  616     0.6KB/s   00:00   
id_dsa                               100%  672     0.7KB/s   00:00   
known_hosts                          100%  400     0.4KB/s   00:00   
authorized_keys                      100%  616     0.6KB/s   00:00   
[root@pcmk-1 ~]# ssh pcmk-2 -- uname -n
pcmk-2
[root@pcmk-1 ~]#
图?2.22.?在另一个机器上面安装SSH密钥
2.4.3.?简化节点名称
在安装过程中,我们发现FQDN域名太长了,不利于在日志或状态界面中查看,我们用以下操作来简化机
器名:
[root@pcmk-1 ~]# uname -n
pcmk-1.clusterlabs.org
[root@pcmk-1 ~]# dnsdomainname
clusterlabs.org
第二个命令的输出是正常的,但是我们真的不需要这么详细的输出,我们更改/etc/sysconfig/network
文件来达到简化的目的。
[root@pcmk-1 ~]# cat /etc/sysconfig/network
NETWORKING=yes配置 Corosync
23
HOSTNAME=pcmk-1.clusterlabs.org
GATEWAY=192.168.122.1
我们要做的只是要把域名后面的部分去掉。
[root@pcmk-1 ~]# sed -i.bak 's/\.[a-z].*//g' /etc/sysconfig/network
现在cat一下看看更改是否成功了。
[root@pcmk-1 ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=pcmk-1
GATEWAY=192.168.122.1
然而到这里还没结束,机器还没接受新的配置文件,我们强制它生效。
[root@pcmk-1 ~]# source /etc/sysconfig/network
[root@pcmk-1 ~]# hostname $HOSTNAME
现在我们看看是否按达到我们预期的效果:
[root@pcmk-1 ~]# uname -n
pcmk-1
[root@pcmk-1 ~]# dnsdomainname
clusterlabs.org
现在在pcmk-2上面重复以上操作.
2.4.4.?配置 Corosync
选择一个组播7
端口和地址。8
请注意你选择的端口和地址不能跟已存在的集群冲突,关于组播地址的选择,可以参考  http://
www.29west.com/docs/THPM/multicast-address-assignment.html 9
在这个文档中,我选择端口4000并且用226.94.1.1作为组播地址:
重要
The instructions below only apply for a machine with a single NIC. If you have a more
complicated setup, you should edit the configuration manually.
[root@pcmk-1 ~]# export ais_port=4000
[root@pcmk-1 ~]# export ais_mcast=226.94.1.1
7
 http://en.wikipedia.org/wiki/Multicast
8
 http://en.wikipedia.org/wiki/Multicast_address
9
 http://www.29west.com/docs/THPM/multicast-address-assignment.html第?2?章?安装
24
然后我们用下面的命令自动获得机器的地址。为了让配置文件能够在机器上面的各个机器通用,我们不
使用完整的IP地址而使用网络地址。(译者注:corosync配置文件中的监听地址一项可以填写网络地址
,corosync会自动匹配应该监听在哪个地址而不是0.0.0.0)
[root@pcmk-1 ~]# export ais_addr=`ip addr | grep "inet " | tail -n 1 | awk '{print $4}' | sed s/255/0/`
显示并检查配置的环境变量是否正确
[root@pcmk-1 ~]# env | grep ais_
ais_mcast=226.94.1.1
ais_port=4000
ais_addr=192.168.122.0
Once you're happy with the chosen values, update the Corosync configuration
[root@pcmk-1 ~]# cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf
[root@pcmk-1 ~]# sed -i.bak "s/.*mcastaddr:.*/mcastaddr:\ $ais_mcast/g" /etc/corosync/corosync.conf
[root@pcmk-1 ~]# sed -i.bak "s/.*mcastport:.*/mcastport:\ $ais_port/g" /etc/corosync/corosync.conf
[root@pcmk-1 ~]# sed -i.bak "s/.*bindnetaddr:.*/bindnetaddr:\ $ais_addr/g" /etc/corosync/corosync.conf
Finally, tell Corosync to load the Pacemaker plugin.
[root@pcmk-1 ~]# cat <<-END >>/etc/corosync/service.d/pcmk
service {
        # Load the Pacemaker Cluster Resource Manager
        name: pacemaker
        ver:  1
}
END
The final configuration should look something like the sample in 附录?B, Sample Corosync
Configuration.
重要
When run in version 1 mode, the plugin does not start the Pacemaker daemons. Instead
it just sets up the quorum and messaging interfaces needed by the rest of the stack.
Starting the dameons occurs when the Pacemaker init script is invoked. This resolves
two long standing issues:
1. Forking inside a multi-threaded process like Corosync causes all sorts of pain.
This has been problematic for Pacemaker as it needs a number of daemons to be
spawned.
2. Corosync was never designed for staggered shutdown - something previously needed
in order to prevent the cluster from leaving before Pacemaker could stop all
active resources.
2.4.5.?传送配置文件
然后我们把配置文件拷贝到其他节点:传送配置文件
25
[root@pcmk-1 ~]# for f in /etc/corosync/corosync.conf /etc/corosync/service.d/pcmk /etc/hosts; do scp $f
 pcmk-2:$f ; done
corosync.conf                            100% 1528     1.5KB/s   00:00
hosts                                    100%  281     0.3KB/s   00:00
[root@pcmk-1 ~]#