HA heartbeat + drbd 配置学习笔记
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HA heartbeat + drbd 配置学习笔记相关的知识,希望对你有一定的参考价值。
heartbeat安装软件
heartbeat-3.0.4-2.el6.x86_64.rpm
heartbeat-devel-3.0.4-2.el6.x86_64.rpm
heartbeat-libs-3.0.4-2.el6.x86_64.rpm
ldirectord-3.9.5-3.1.x86_64.rpm
/usr/share/doc/
ha.cf Main configuration file
haresources Resource configuration file
authkeys Authentication information
cp ha.cf harsources authkeys /etc/ha.d
配置 /etc/ha.d/ha.cf
29 logfile /var/log/ha-log
48 keepalive 2
61 warntime 10
71 initdead 60
76 udpport 6970
91 bcast eth0 # Linux
157 auto_failback on
211 node server26.example.com
212 node server27.example.com
220 ping 172.25.28.250
253 respawn hacluster /usr/lib64/heartbeat/ipfail
259 apiauth ipfail gid=haclient uid=hacluster
配置/etc/ha.d/haresources
server26.example.com IPaddr::172.25.28.70/24/eth0 drbddisk::test Filesystem::/dev/drbd1::/var/lib/mysql mysqld 虚拟ip# 172.25.28.70
配置 /etc/ha.d/authkeys
23 auth 1
24 1 crc
chmod 600 authkeys
/etc/init.d/heatbeat start
---------------------------------------------------------------分割线----------------------------------------------------
drbd 同步存储
安装包
yum install -y drbd-pacemaker drbd-udev
编辑 *.res
vim /etc/drbd.d/bddata.res
1 resource test {
2 meta-disk internal;
3 device /dev/drbd1;
4 syncer {
5 verify-alg sha1;
6 }
7 on server26.example.com { #主机名
8 disk /dev/vdb; #同步所需的主机磁盘
9 address 172.25.28.26:7789; #主机ip
10 }
11 on server27.example.com {
12 disk /dev/vdb;
13 address 172.25.28.27:7789;
14 }
15 }
两台主机 同步磁盘
drbdadm create-md test
开启服务
/etc/init.d/drbd start
设置主磁盘
drbdadm primary test --force
之后相互开始同步磁盘
version: 8.4.3 (api:1/proto:86-101)
GIT-hash: 89a294209144b68adb3ee85a73221f964d3ee515 build by [email protected], 2016-09-21 16:46:03
1: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r-----
ns:132096 nr:0 dw:0 dr:132760 al:0 bm:8 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:4062044
[>....................] sync‘ed: 3.3% (4062044/4194140)K
finish: 0:01:01 speed: 66,048 (66,048) K/sec
配置 /etc/ha.d/haresources
server26.example.com IPaddr::172.25.28.70/24/eth0 drbddisk::test Filesystem::/dev/drbd1::/var/lib/mysql mysqld 调用脚本挂载/dev/drbd1 到/var/lib/mysql 启动 mysql 服务
mysql 启动时
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2)
原因是,/var/lib/mysql 的访问权限问题
chown -R mysql:mysql /var/lib/mysql
以上是关于HA heartbeat + drbd 配置学习笔记的主要内容,如果未能解决你的问题,请参考以下文章