DRBD+Heartbeat实现自动认主与挂载
一,需求说明
由于drbd需要选主、再对主节点上的drbd盘进行挂载操作。现采用heartbeat进行选主与挂载的自动化。
二,环境
centos7服务器两台 双节点
gitlab-service-01 192.168.41.253
gitlab-service-02 192.168.41.252
1.两台都需要设置同一个vip地址 用于维持heartbeat心跳
vip:192.168.41.153。查看自身网卡设备,我使用的是eth0.则复制eth0网卡进行配置
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:1
vim /etc/sysconfig/network-scripts/ifcfg-eth0:1
修改下图两个参数
systemctl restart network
重启网卡使得配置生效
2.关闭firewalld、iptable、selinux
3.确保时间同步
4.配置主机名
5.配置主机间ssh互相、免密钥认证
#01上的配置
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i s#SELINUX=enforcing#SELINUX=disabled# /etc/selinux/config 永久关闭
hostname gitlab-service-01
echo "gitlab-service-01" >> /etc/hostname
ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa
ssh-copy-id root@192.168.41.252
echo -e "192.168.41.253 gitlab-service-01 \n192.168.41.252 gitlab-service-02" >> /etc/hosts
#02上的配置
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i s#SELINUX=enforcing#SELINUX=disabled# /etc/selinux/config 永久关闭
hostname gitlab-service-02
echo "gitlab-service-02" >> /etc/hostname
ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa
ssh-copy-id root@192.168.41.253
echo -e "192.168.41.253 gitlab-service-01 \n192.168.41.252 gitlab-service-02" >> /etc/hosts
三,安装
1.安装基础环境编译包
yum install -y gcc gcc-c++ autoconf automake libtool glib2-devel libxml2-devel bzip2 bzip2-devel e2fsprogs-devel libxslt-devel libtool-ltdl-devel asciidoc
2.创建heartbeat 用户和组
groupadd haclient
useradd -g haclient hacluster
3.下载软件包 Reusable-Components-glue、resource-agents、heartbeat
wget http://hg.linux-ha.org/heartbeat-STABLE_3_0/archive/958e11be8686.tar.bz2
wget http://hg.linux-ha.org/glue/archive/0a7add1d9996.tar.bz2
wget https://github.com/ClusterLabs/resource-agents/archive/v3.9.6.tar.gz
4.安装Reusable-Components-glue
tar xf 0a7add1d9996.tar.bz2
cd Reusable-Cluster-Components-glue--0a7add1d9996/
./autogen.sh
./configure --prefix=/usr/local/heartbeat --with-daemon-user=hacluster --with-daemon-group=haclient --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1'
make && make install
echo $?
cd ..