首页 > 代码库 > heartbeat+drbd

heartbeat+drbd

集群的常见问题
1.tgt首先在管理机上启动
50pxan 即是 “心跳传递(heartbest)集群管理软件”,这样集群的iscsi (iscsi是他的后台系统)才能起来
3.corosync heartbeat v1 v2 v3 keepalived vrrp(协议)["心跳版本"]


安全关闭集群 Leave Cluster (离开集群)

RHCS:

技术分享
conga:luci ricci (web)
corysync(
可以用来同步节点信息同步 日志)=camn(集群管理器)
rgmanager (集群资源管理器)
faildomian(故障切换域)
ccsd(集群配置服务)--cluster.conf  (保证集群文件同步)
1——corysync——2      3——iscsi——1     3——iscsi——2


heartbeat:(底层 对资源不能管理)

1.安装软件包:
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

技术分享
2.
更改配置文件
cd /etc/ha.d
rpm -q herabeat –d

技术分享
/usr/share/doc/heartbeat-3.0.4/AUTHORS
/usr/share/doc/heartbeat-3.0.4/COPYING
/usr/share/doc/heartbeat-3.0.4/COPYING.LGPL
/usr/share/doc/heartbeat-3.0.4/ChangeLog
/usr/share/doc/heartbeat-3.0.4/README
/usr/share/doc/heartbeat-3.0.4/apphbd.cf
/usr/share/doc/heartbeat-3.0.4/authkeys
/usr/share/doc/heartbeat-3.0.4/ha.cf
/usr/share/doc/heartbeat-3.0.4/haresources
/usr/share/man/man1/cl_status.1.gz
/usr/share/man/man1/hb_addnode.1.gz
/usr/share/man/man1/hb_delnode.1.gz
/usr/share/man/man1/hb_standby.1.gz
/usr/share/man/man1/hb_takeover.1.gz
/usr/share/man/man5/authkeys.5.gz
/usr/share/man/man5/ha.cf.5.gz
/usr/share/man/man8/apphbd.8.gz
/usr/share/man/man8/heartbeat.8.gz
cp /usr/share/doc/heartbeat-3.0.4/{authkeys,ha.cf,haresources}.
技术分享
vim/etc/ha.cf
keepalive 2  (
每隔两秒发送心跳频率)
deadtime 30 (超过30s没收到心跳频率 默认对方死亡)
warntime 10 (超过10s没收到 警告)
initdead 60 (资源初始化)
udpport 1042 (端口)
bcast   eth0 (广播)
auto_failback on (主集群机恢复后 服务切回)
node    dd5.example.com
node    dd6.example.com (写在前面的是主节点)
ping 172.25.42.250 测试网络
(一个可以ping 通的ip 最好是网关 注意:不能是自己也不能是对方
respawn hacluster /usr/lib64/heartbeat/ipfail (插件断网)
apiauth ipfail gid=haclient uid=hacluster

vim authkeys
 auth 1 (明文)
1 crc

vim haresources
dd5.example.com IPaddr::172.25.42.200/24/eth0 httpd (vip)
chmod 600 /etc/ha.d/authkeys


另一台同样

测试:
curl 172.25.254.200
技术分享
服务故障 不具备切换 (eg:httpd stop )

技术分享

技术分享

技术分享

技术分享


drbd(分布式复制块设备)

添加存储:
dd5:
tar -zxf drbd-8.4.2.tar.gz
yum install gcc -y
yum install flex
yum install -y rpm-build –y

./configure--enable-spec

技术分享
./configure --enable-spec --with-km
rpmbuild -bb drbd.spec
rpmbuild -bb drbd-km.spec
yum install kernel-devl -y



 

技术分享

技术分享


cd /etc/drbd.d
vim example.res

resource example {
meta-disk internal;
device /dev/drbd1;
syncer {
verify-alg sha1;
}

on dd5.example.com {
disk /dev/vda;
address 172.25.42.14:7789;
}
on dd6.example.com {
disk /dev/vda;
address 172.25.42.15:7789;
}
}

drbdadm create-md example
初始化 (服务还没启动 两边都做 让服务读取硬盘)
/etc/init.d/drbd start (两边都做)
drbdadm primary example--force (强制让从second同步primary的信息)

技术分享
mkfs.ext4 /dev/drbd1
技术分享
drbdadm primary example
(主的才能挂载)
drbdadm secondary example


drbd+heartbeat:
/etc/init.d/heartbeat stop (两边都做)
dd5:yum install mysql-server -y
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
cd /var/lib/mysql/
cp -r * /mnt (前提: mount/dev/drbd1 /mnt)
umount /mnt
mount /dev/drdb1/var/lib/mysql

dd6:yum install mysql-server -y
drbdadm primary exmaple
mount /dev/drdb1 /var/lib/mysql
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
drbdadm secondary example
umount /var/lib/mysql



vim /etc/ha.d/haresources
dd5.example.com IPaddr::172.25.42.200/24/eth0 drbddisk::exampleFilesystem::/dev/drbd1::/var/lib/mysql::ext4 mysqld


 
技术分享
/etc/init.d/heartbeat start(
两边都做)

测试:


技术分享

技术分享






 


heartbeat+drbd