Centos5.8 x86_64下安装DRBD+Heartbeat+NFS

实验环境:vmware workstation

os:Centos5.8 x86_64

编辑两台虚拟机分别新增一块网卡作为心跳检测,新增一块4G的硬盘,大小保持一致

两台机器的基本情况如下所示:

centos1.mypharma.com 192.168.150.100,心跳线为:10.10.10.2(VM2网段)

centos2.mypharma.com 192.168.150.101,心跳线为:10.10.10.3(VM2网段)

heartbeat的vip为 192.168.150.128

一、实验前的准备工作

①drbd1的hosts文件内容如下所示:

[[email protected] ~]# cat /etc/hosts

# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1               localhost.localdomain localhost

::1             localhost6.localdomain6 localhost6

192.168.150.100 centos1.mypharma.com

192.168.150.101 centos2.mypharma.com

②drbd1的hostname:

[[email protected] ~]# cat /etc/sysconfig/network

NETWORKING=yes

NETWORKING_IPV6=yes

HOSTNAME=centos1.mypharma.com

③关闭iptables、SElinux

[[email protected] ~]# setenforce 0

setenforce: SELinux is disabled

[[email protected] ~]# service iptables stop

④检查磁盘

[[email protected] ~]# fdisk -l

Disk /dev/sda: 85.8 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          25      200781   83  Linux

/dev/sda2              26        1057     8289540   82  Linux swap / Solaris

/dev/sda3            1058       10443    75393045   83  Linux

Disk /dev/sdb: 4294 MB, 4294967296 bytes

255 heads, 63 sectors/track, 522 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn‘t contain a valid partition table

dbrd2做相同的操作。

二、DRBD的安装

dbrd1

yum -y install drbd83 kmod-drbd83

modprobe drbd

[[email protected] ~]# lsmod | grep drbd

drbd                  321608  0

dbrd2

yum -y install drbd83 kmod-drbd83

modprobe drbd

[[email protected]2 ~]# lsmod | grep drbd

drbd                  321608  0

如果能正确显示,表明DRBD已经安装成功

两台机器的drbd.conf配置文件内容如下所示(两台机器的配置是一样的):

[[email protected] ~]# cat /etc/drbd.conf

global {

usage-count no;

}

common {

syncer  { rate 30M; }

}

resource r0 {

protocol C;

handlers {

pri-on-incon-degr "/usr/lib/drbd/notify-pri-on-incon-degr.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f";

pri-lost-after-sb "/usr/lib/drbd/notify-pri-lost-after-sb.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f";

local-io-error "/usr/lib/drbd/notify-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o > /proc/sysrq-trigger ; halt -f";

# fence-peer "/usr/lib/drbd/crm-fence-peer.sh";

# split-brain "/usr/lib/drbd/notify-split-brain.sh root";

# out-of-sync "/usr/lib/drbd/notify-out-of-sync.sh root";

# before-resync-target "/usr/lib/drbd/snapshot-resync-target-lvm.sh -p 15 -- -c 16k";

# after-resync-target /usr/lib/drbd/unsnapshot-resync-target-lvm.sh;

}

startup {

# wfc-timeout degr-wfc-timeout outdated-wfc-timeout wait-after-sb

wfc-timeout 120;

degr-wfc-timeout 120;

}

disk {

# on-io-error fencing use-bmbv no-disk-barrier no-disk-flushes

# no-disk-drain no-md-flushes max-bio-bvecs

on-io-error detach;

}

net {

# sndbuf-size rcvbuf-size timeout connect-int ping-int ping-timeout max-buffers

# max-epoch-size ko-count allow-two-primaries cram-hmac-alg shared-secret

# after-sb-0pri after-sb-1pri after-sb-2pri data-integrity-alg no-tcp-cork

max-buffers 2048;

cram-hmac-alg "sha1";

shared-secret "123456";

#allow-two-primaries;

}

syncer {

rate 30M;

# rate after al-extents use-rle cpu-mask verify-alg csums-alg

}

on centos1.mypharma.com {

device  /dev/drbd0;

disk    /dev/sdb;

address 10.10.10.2:7788;

meta-disk       internal;

}

on centos2.mypharma.com {

device  /dev/drbd0;

disk    /dev/sdb;

address 10.10.10.3:7788;

meta-disk       internal;

}

}

创建DRBD元数据信息

[[email protected] ~]# drbdadm create-md r0

Writing meta data...

initializing activity log

NOT initialized bitmap

New drbd meta data block successfully created.

将centos1的机器作为DRBD的Primary机器,命令如下所示:

[[email protected] ~]# drbdsetup /dev/drbd0primary -o

[[email protected] ~]# drbdadm primary r0

[[email protected] ~]# mkfs.ext3 /dev/drbd0

[[email protected] ~]# mkdir -p /drbd

[[email protected] ~]# mount /dev/drbd0 /drbd

[[email protected] ~]# chkconfig drbd on

centos2机器

[[email protected] ~]# mkdir -p /drbd

[[email protected] ~]# chkconfig drbd on

三、Heartbeat的安装和部署。

两台机器上分别用yum来安装heartbeat,如下命令操作二次:

yum -y install heartbeat

①编辑/etc/ha.d/ha.cf

drbd1

[[email protected] ~]# cat /etc/ha.d/ha.cf

logfile /var/log/ha-log

logfacility local0

keepalive 2

deadtime 15

ucast eth1 10.10.10.3

auto_failback off

node centos1.mypharma.com centos2.mypharma.com

drbd2

[[email protected] ~]# cat /etc/ha.d/ha.cf

logfile /var/log/ha-log

logfacility local0

keepalive 2

deadtime 15

ucast eth1 10.10.10.2

auto_failback off

node centos1.mypharma.com centos2.mypharma.com

②编辑双机互连验证文件authkeys

drbd1

[[email protected] ~]# cat /etc/ha.d/authkeys

auth 1

1 crc

[r[email protected] ~]# chmod 600 /etc/ha.d/authkeys

drbd2

[[email protected] ~]# cat /etc/ha.d/authkeys

auth 1

1 crc

[[email protected] ~]# chmod 600 /etc/ha.d/authkeys

③编辑集群资源文件/etc/ha.d/haresources

drbd1

[[email protected] ~]# cat /etc/ha.d/haresources

centos1.mypharma.com IPaddr::192.168.150.128/24/eth0 drbddisk::r0 Filesystem::/dev/drbd0::/drbd::ext3  killnfsd

drbd2

[[email protected] ~]# cat /etc/ha.d/haresources

centos1.mypharma.com IPaddr::192.168.150.128/24/eth0 drbddisk::r0 Filesystem::/dev/drbd0::/drbd::ext3  killnfsd

④编辑/etc/ha.d/resource.d/killnfsd

drbd1

[[email protected] ~]# cat /etc/ha.d/resource.d/killnfsd

killall -9 nfsd;/etc/init.d/nfs restart;exit 0

[[email protected] ~]# chmod +x /etc/ha.d/resource.d/killnfsd

drbd2

[[email protected] ~]# cat /etc/ha.d/resource.d/killnfsd

killall -9 nfsd;/etc/init.d/nfs restart;exit 0

[[email protected] ~]# chmod +x /etc/ha.d/resource.d/killnfsd

⑤主从机器上面配置下nfs服务的/etc/exports,其文件内容如下:

/drbd 192.168.150.0/255.255.255.0(rw,sync,no_root_squash,no_all_squash)

service portmap start

chkconfig portmap on

在两台机器上将DRBD和Heartbeat都设成自启动方式。

service drbd start

chkcfonig drbd on

service heartbeat start

chkconfig heartbeat on

时间: 2024-10-25 02:16:52

Centos5.8 x86_64下安装DRBD+Heartbeat+NFS的相关文章

drbd+heartbeat+nfs高可用架构搭建

一.客户需求 1.需求描述 有些客户有自己的存储设备,但是并没有集群文件系统服务,所以如果我们多个节点(计算节点)如果想同时使用其中的一个块且要保证高可用的话,就需要我们自己来完成类似集群文件系统的服务组合,在此我们使用的服务组合是:iscsi共享+drbd+heartbeat+nfs. 2.服务说明 Iscsi共享:这里通过iscsi共享服务将存储设备上的存储块共享出去,提供节点(NC1+NC2)使用,此处我们将在iscsi服务短创建两个镜像充当块设备. Drbd   :服务器之间镜像块设备内

DRBD+HeartBeat+NFS:配置NFS的高可用

说明: 上周研究了DRBD的安装和配置,今天研究下DRBD的第一个应用,利用DRBD+HeartBeat+NFS:配置NFS的高可用,作为集群中的底端共享存储 NFS主要存储WEB服务器上的程序代码和一些图片文件 参考: http://network.51cto.com/art/201010/230237_all.htm http://showerlee.blog.51cto.com/2047005/1212185 环境: [[email protected] ~]# cat /etc/issu

drbd+heartbeat+nfs

Drbd+heartbeat+nfs 设备信息: master:ip 192.168.8.220/24  eth0   增加sdb磁盘无需挂载 backup: ip 192.168.8.221/24   eth0  增加sdb磁盘无需挂载 拓扑: 编辑 /etc/hosts     (master+backup) 下载drbd源码包:drbd8.4.3.tar.bz2 一:编译安装drbd  (master+backup) 1.1安装依赖 Yum install gcc gcc-c++ make

DRBD+Heartbeat+NFS高可用实战

实验环境:Centos 6.7_64位 服务器: Master节点:dm1 IP地址:10.0.0.61(eth0) 192.168.3.150(eth1,心跳) Slave节点:dm2 IP地址:10.0.0.62(eth0) 192.168.3.160(eth1,心跳) VIP地址:192.168.0.180 一.DRBD环境搭建 1. host映射 # vi  /etc/hosts 127.0.0.1   localhostlocalhost.localdomain localhost4

项目:一次测试环境下的高可用NFS文件服务器(DRBD+heartbeat+NFS)

什么是DRBD? 分布式复制块设备.当你将数据写入本地的DRBD设备上的文件系统时,数据同时会被发送到远程端的另一边的DRBD设备文件系统里,保障数据实时同步,当本地的DRBD设备突然故障,远程节点还保留一份一模一样的数据,根据这个特性,可以结合heatbeat的ha开源软件,实现高可用! 我们都把DRBD理解是网络raid1磁盘阵列. DRBD底层设备可以是 1)一块磁盘,或者一个分区. 2)raid设备. 3)逻辑卷lvm. 4)任何块设备. DRBD支持三种不同的复制协议.协议A,协议B,

DRBD+HEARTBEAT+NFS高可用架构笔记

参考1:http://os.51cto.com/art/201412/461533.htm 参考2:http://732233048.blog.51cto.com/9323668/1669417 参考3:http://network.51cto.com/art/201010/230237_all.htm 网络拓扑: 简要说明: 两台 NFS 服务器,通过 eth0 网卡与内网的其他业务服务器进行通信,eth1网卡主要负责两台 NFS 服务器之间心跳通信,eth2网卡主要负责drbd数据同步的传输

DRBD+HEARTBEAT+NFS简要命令记录

前期准备:2个机器分别加磁盘,网络调通1个心跳线同步线 由fdisk -l可以看出有一块大小为10.7G的设备/dev/sdb,对/dev/sdb来创建逻辑卷: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [[email protected] ~]# pvcreate /dev/sdb             #创建pv   Physical volume "/dev/sdb" successfully created [

linux下安装drbd详解

关于drbd理论方面的知识本文中不做介绍,本文章主要讲述如何搭建drbd. 一.系统环境   系统平台: Centos6.3(内核2.6.32-431.29.2.el6.x86_64) 节点一主机名: Cenos-HA1     IP:192.168.1.202 节点一主机名: Cenos-HA2     IP:192.168.1.202  DRBD版本:DRBD-8.4.3 二.安装   1.准备 (1).关闭iptables和SELINUX,避免安装过程中报错. 节点1和节点2 #/etc/

某电商网站线上drbd+heartbeat+nfs配置

1.环境 nfs1.test.com 10.1.1.1 nfs2.test.com 10.1.1.2 2.drbd配置 安装drbd yum -y install gcc gcc-c++ make glibc flex yum -y install drbd kmod-drbd 加载drbd模块 modprobe drbd lsmod | grep drbd /etc/drbd.conf配置 resource r0 { protocol C; startup { wfc-timeout 0; d