drdb安装测试

.环境准备

系统环境

CentOS release 6.3 (Final)


内核信息

2.6.32-279.el6.x86_64


ip地址

vip 192.168.64.120  

master 192.168.64.132  心跳线:10.0.0.1    主机名:DBmaster.test

slave 192.168.64.135   心跳线:10.0.0.2    主机名:DBbak.test


镜像磁盘

master /dev/sdc

slave /dev/sdc


fdisk -l

安装依赖环境

yum -y install gcc gcc-c++ make glibcflex   kernel kernel-devel kernel-headers

下载安装包

wget http://oss.linbit.com/drbd/8.4/drbd-8.4.3.tar.gz


.安装配置

安装:

ls

tar zxfdrbd-8.4.3.tar.gz

ls

cd drbd-8.4.3

./configure--prefix=/usr/local/drbd --with-km

ls/usr/src/kernels/2.6.32-431.5.1.el6.x86_64

ls/usr/src/kernels/

uname -r

makeKDIR=/usr/src/kernels/2.6.32-431.5.1.el6.x86_64

echo $?

make install

echo $?




添加开机启动

cp/usr/local/drbd/etc/rc.d/init.d/drbd /etc/rc.d/init.d  

chkconfig --adddrbd

chkconfig drbdon


加载DRBD模块

depmod

modprobe drbd

modprobe drbd


加载DRBD模块报错

[root@mantisdrbd-8.4.3]# depmod

[root@mantisdrbd-8.4.3]# modprobe drbd

FATAL: Moduledrbd not found.

报错:FATAL: Module drbd not found. 内核不支持,更新内核,然后重启



查看模块是否加载到内核

[root@mantis ~]#lsmod |grep drbd

drbd                  325658  0

libcrc32c               1246  1 drbd



安装成功后系统会有drbd的命令

/sbin/dr

dracut     drbdadm   drbdmeta   drbdsetup





主配置文件


cat>>/usr/local/drbd/etc/drbd.conf <<EOF

# You can findan example in /usr/share/doc/drbd.../drbd.conf.example

include"drbd.d/global_common.conf";

include"drbd.d/*.res";

EOF




全局配置文件


cp/usr/local/drbd/etc/drbd.d/global_common.conf/usr/local/drbd/etc/drbd.d/global_common.conf.bk

>/usr/local/drbd/etc/drbd.d/global_common.conf

cat>>/usr/local/drbd/etc/drbd.d/global_common.conf <<EOF

global {

       usage-count no;

       # minor-count dialog-refreshdisable-ip-verification

}

common {

       protocol C;

       startup {

               wfc-timeout  120;

               degr-wfc-timeout 120;

       }

       disk {

               on-io-error detach;

               fencing resource-only;

       }

       net {

               cram-hmac-alg "sha1";

               shared-secret  "mydrbdlab";

       }

       syncer {

               rate  100M;

       }

}

EOF


资源配置文件


cat>>/usr/local/drbd/etc/drbd.d/mysql.res <<EOF

resource  mysql {

       on DBmaster.test {

       device  /dev/drbd0;

       disk   /dev/sdc1;

       address 10.0.0.1:7789;

       meta-disk       internal;

       }

       on DBbak.test {

       device  /dev/drbd0;

       disk   /dev/sdc1;

       address 10.0.0.2:7789;

       meta-disk       internal;

       }

}

EOF


drbd设备创建

[root@DBmasterdrbd.d]# mknod /dev/drbd0 b 147 0

[root@DBmasterdrbd.d]# drbdadm create-md mysql


报错:

        ‘mysql‘ not defined in your config (forthis host).

网上说报错4‘drbd‘ notdefined in your config (for this host). 这个因为没有加载到drbd模块

解决:需要指定/etc/hosts里面主机


正常:

        [root@DBmaster drbd.d]# drbdadmcreate-md my1

        Writing meta data...

        initializing activity log

        NOT initializing bitmap

        New drbd meta data block successfullycreated.


        [root@DBbak drbd.d]# drbdadm create-mdmy1

        Writing meta data...

        initializing activity log

        NOT initializing bitmap

        New drbd meta data block successfullycreated.


启动drbd

/usr/local/drbd/etc/rc.d/init.d/drbdstart

cp/usr/local/drbd/etc/rc.d/init.d/drbd /etc/init.d/

chkconfig adddrbd


[root@DBmasterdrbd.d]# ps -ef|grep drbd

root     13262    2  0 13:46 ?        00:00:00 [drbd-reissue]

root     13600    2  0 15:42 ?        00:00:00 [drbd_submit]

root     13604    2  0 15:42 ?        00:00:00 [drbd_w_my1]

root     13614    2  0 15:42 ?        00:00:00 [drbd_r_my1]

root     13621    2  0 15:42 ?        00:00:00 [drbd_a_my1]

root     13625 2384  0 15:43 pts/1    00:00:00 grep drbd


查看状态

[root@DBmasterdrbd.d]# /usr/local/drbd/etc/rc.d/init.d/drbd status

drbd driverloaded OK; device status:

version: 8.4.3(api:1/proto:86-101)

GIT-hash:89a294209144b68adb3ee85a73221f964d3ee515 build by root@DBmaster.test,2014-05-09 13:43:20

m:res  cs        ro                   ds                         p  mounted fstype

0:my1  Connected Secondary/Secondary Inconsistent/Inconsistent  C


[root@DBmasterdrbd.d]# cat /proc/drbd

version: 8.4.3(api:1/proto:86-101)

GIT-hash:89a294209144b68adb3ee85a73221f964d3ee515 build by root@DBmaster.test,2014-05-09 13:43:20

0: cs:Connected ro:Secondary/Secondaryds:Inconsistent/Inconsistent C r-----

   ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0ua:0 ap:0 ep:1 wo:f oos:5236960

[root@DBmasterdrbd.d]#



主节点的设置(primary

drbdsetupprimary /dev/drbd0 --force  配置为主节点


挂载设备(primary

说明:挂载DRBD分区之前,首先确认当前主机的DRBD分区是primary状态,可以通过cat /proc/drdb命令中查询状态。


创建文件系统(primary


mkfs.ext4/dev/drbd0

挂载设备(primary


mount/dev/drbd0  /data --->DBdata



测试

[root@DBmasterdata]# touch {1..9}

卸载降级

[root@DBmaster~]# umount /data

[root@DBmaster~]# drbdsetup /dev/drbd0 secondary


升级,然后挂载,查看

[root@DBbakdata]#  drbdsetup /dev/drbd0 primary

[root@DBbakdata]#  mount /dev/drbd0 /data

[root@DBbakdata]# ls

[root@DBbakdata]# cd /data/

[root@DBbakdata]# ls

1    2 3  4  5 6  7  8 9  abc  lost+found rzsz-3.48.tar.gz



.配置文件说明

以上相关配置文件说明:

cat /etc/drbd.d/global_common.conf

global {

      usage-count no; #?取消drbd使用者统计

      # minor-count dialog-refresh disable-ip-verification

}

common {

      protocol C; #?选择drbdC协议

      startup {  #?启动延时配置

               wfc-timeout  120;

               degr-wfc-timeout 120;

      }

      disk {    #?fence防脑裂

               on-io-error detach;

               fencing resource-only;

      }

      net {

               cram-hmac-alg "sha1";#?主备节点使用的通信算法

               shared-secret  "mydrbdlab";

      }

      syncer {

               rate  100M; #?同步速率,视带宽而定

      }

}



cat /etc/drbd.d/web.res

resource web {                                           #?web为资源名

      on master-nfs {                                     #?master-nfs为节点名称

      device   /dev/drbd0;               #?定义虚拟设备

      disk    /dev/sdb1;                            #?指定真实设备

      address  192.168.2.1:7789;          #?监听自身IP端口

      meta-disk       internal;

      }

      on slave-nfs {

      device   /dev/drbd0;

      disk    /dev/sdb1;

      address  192.168.2.2:7789;

      meta-disk       internal;

      }

}

EOF


本文出自 “小盒” 博客,请务必保留此出处http://zhangxiaohe.blog.51cto.com/7821029/1409978

drdb安装测试,布布扣,bubuko.com

drdb安装测试

上一篇:mysql主从检测脚本


下一篇:Oracle 10g RAC 升级(CPU Update)之--升级CRS