linux-ha heartbeat 搭建
我們提到了linux-ha 專案。
這裡,我們就嘗試搭建一套linux-ha 系統。
之前的在redhat AS 6.2 系統上沒有安裝成功,轉而求Centos 5.5 , Centos 6.2
目前在Centos 上的這兩個版本上都安裝成功。
1.安裝:
配置yum
將附件 新增到yum.repos.d 下面
然後執行 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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- DB2 HADR的heartbeat檢測DB2
- Elastic 使用Heartbeat監測服務執行狀態AST
- Haproxy+Heartbeat 高可用叢集方案操作記錄
- LVS+Heartbeat 高可用叢集方案操作記錄
- websocket-heartbeat-js心跳檢測庫正式釋出WebJS
- PING[ARC5]: Heartbeat failed to connect to standby 'dghq'. Error is 12154.AIError
- Mysql 主從延時監控(pt-heartbeat)詳解MySql
- 原始碼解讀etcd heartbeat,election timeout之間的拉鋸原始碼
- [原始碼分析] 並行分散式任務佇列 Celery 之 Timer & Heartbeat原始碼並行分散式佇列
- CM agent 傳送heartbeat給CM server 不斷髮生 connection refused:timed outServer
- 【環境搭建】RocketMQ叢集搭建MQ
- MySQL叢集搭建(1)-主備搭建MySql
- MVVM框架的搭建(二)——專案搭建MVVM框架
- Harbor 搭建
- Sentry 搭建
- 搭建HadoopHadoop
- elk 搭建
- Inception 搭建
- MYSQL搭建MySql
- ELK搭建
- 搭建genieacs
- RustDesk 搭建Rust
- Gitlab搭建Gitlab
- OJ搭建
- 從零搭建一個IdentityServer——專案搭建IDEServer
- Windows下搭建ESP-IDF環境搭建Windows
- 【Azkaban搭建】---Azkaban 3.25.0搭建細則 超實用
- 精讀《視覺化搭建思考 - 富文字搭建》視覺化
- docker 搭建 MySQLDockerMySql
- OpenVpn的搭建
- Nexus的搭建
- docker rancher搭建Docker
- JDK的搭建JDK
- 搭建Eureka Clientclient
- 環境搭建
- CentOS 搭建 GitLabCentOSGitlab
- Docker 搭建 MongoDBDockerMongoDB
- linux搭建FabricLinux
- vue 快速搭建Vue