我们提到了linux-ha 项目。
这里,我们就尝试搭建一套linux-ha 系统。
之前的在redhat AS 6.2 系统上没有安装成功,转而求Centos 5.5 , Centos 6.2
目前在Centos 上的这两个版本上都安装成功。
1.安装:
配置yum
将附件 添加到yum.repos.d 下面
abc
然后执行 yum install pacemaker corosync heartbeat
正常情况下就安装成功了。
2.系统配置:
1) 修改 /etc/hosts 添加双机的主机名,ip。
/etc/sysconfig/network 可以考虑修改主机名为短名字,便于管理。
2) 配置双机的root 用户可以相互免密码ssh登录。
3. 修改 /etc/ha.d 下面的配置文件:
ha.cf
haresources
authkeys
ha.cf ,haresources 可以从/usr/share/doc/heartbeat/下面的example 中修改过来。
authkeys 可以用下面的方式生产:
[code]
( echo -ne "auth 1\n1 sha1 "; dd if=/dev/urandom bs=512 count=1 | openssl md5 ) > /etc/ha.d/authkeys
[/code]
4.配置corosync
1) 修改 /etc/corosync/corosync.conf
[code]
[root@dba-test-11-97 corosync]# vi corosync.conf
# Please read the corosync.conf.5 manual page
compatibility: whitetank
totem {
version: 2
secauth: off
threads: 0
interface {
ringnumber: 0
bindnetaddr: 192.168.11.100
mcastaddr: 226.94.1.1
mcastport: 5405
}
}
logging {
fileline: off
to_stderr: no
to_logfile: yes
to_syslog: yes
logfile: /var/log/cluster/corosync.log
debug: off
timestamp: on
logger_subsys {
subsys: AMF
debug: off
}
}
amf {
mode: disabled
}
aisexec {
user: root
group: root
}
[/code]
2) 修改/etc/corosync/services.d 下面的pcmk
[code]
[root@dba-test-11-97 service.d]# more pcmk
#instruct CoroSync to load the quorum and messaging interfaces needed by pacemaker
service {
# Load the Pacemaker Cluster Resource Manager
name: pacemaker
ver: 1
}
[/code]
注意如果安装的pacemake 版本是1.0.x 版本以前的 这里的ver: 要设为0
因为 pacemaker 在1.0.x 以前版本是没有启动脚本的,需要corosync 通过这个pcmk的配置文件来启动。
如果设为1 ,corosync 就不会启动pacemaker了,在pacemaker 1.1.x 版本 之后,有独立的启动脚本。
5. 注意:
把上面的配置文件copy 到另一台机器上
heartbeat ,corosync 的配置脚本里,如果引用到目录 ,需要创建这里目录,或者修改为已经存在的目录。
6.启动:
[code]
/etc/init.d/heartbeat start
/etc/init.d/corosync start
/etc/init.d/pacemaker start
[/code]
7.查看状态:
[code]
[root@dba-test-11-97 crm]# crm status
============
Last updated: Wed Jun 6 03:34:16 2012
Stack: openais
Current DC: dba-test-11-97.pconline.gz - partition with quorum
Version: 1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Online: [ dba-test-11-97.pconline.gz dba-test-11-98.pconline.gz ]
ClusterIp (ocf::heartbeat:IPaddr2): Started dba-test-11-97.pconline.gz
postgres_res (ocf::heartbeat:pgsql): Started dba-test-11-97.pconline.gz
[/code]
8.整个ha的配置信息是放在pacemaker里的。是一个xml文档。
下面使我们的一个配置:
[code]
[root@dba-test-11-98 ~]# crm configure show
node dba-test-11-97.pconline.gz
node dba-test-11-98.pconline.gz
primitive ClusterIp ocf:heartbeat:IPaddr2 \
params ip="192.168.11.100" cidr_netmask="32" \
op monitor interval="30s"
primitive postgres_res ocf:heartbeat:pgsql \
params pgctl="/usr/local/pgsql/bin/pg_ctl" psql="/usr/local/pgsql/bin/psql" start_opt="" pgdata="/usr/local/pgsql/data" config="/usr/local/pgsql/data/postgresql.conf" pgdba="postgres" \
op start interval="0" timeout="120s" \
op stop interval="0" timeout="120s" \
op monitor interval="30s" timeout="30s" depth="0" master-max="2"
location ClusterIp-prefer-to-master ClusterIp 50: dba-test-11-97.pconline.gz
location Pg-prefer-to-master postgres_res 50: dba-test-11-97.pconline.gz
colocation Pg-with-ClusterIp inf: postgres_res ClusterIp
order Pg-after-ClusterIp inf: ClusterIp postgres_res
property $id="cib-bootstrap-options" \
dc-version="1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f" \
cluster-infrastructure="openais" \
expected-quorum-votes="2" \
stonith-enabled="false"
[/code]
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/133735/viewspace-731951/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/133735/viewspace-731951/