标签:
CentOS 6.5上部署drbd
下面开始在CentOS 6.5上安装并配置drbd,环境的话继续使用之前安装完heartbeat的两台主机,同时也是为后面实现heartbeat存储和数据库高可用做准备,所以如果需要单独操作,请按照之前安装heartbeat的准备工作进行配置,然后根据下面的步骤进行也可以。
1、环境准备
这里我以其中一台为例,介绍准备工作包括哪些点:
#检查防火墙是否关闭(或者开启7788端口)
[ ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
#检查SELinux是否禁用
[ ~]# getenforce
Disabled
#检查是否已经添加了时间同步定时任务
[ ~]# crontab -l
0 * * * * /usr/sbin/ntpdate 210.72.145.44 64.147.116.229 time.nist.gov
#检查hosts文件中是否有两个节点的记录
[ ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.49.133 heartbeat01.contoso.com heartbeat01
192.168.49.134 heartbeat02.contoso.com heartbeat02
#检查是否更换国内yum源
[ ~]# ll /etc/yum.repos.d/
total 32
-rw-r--r-- 1 root root 2006 Sep 18 2014 CentOS-Base.repo
-rw-r--r--. 1 root root 1926 Nov 27 2013 CentOS-Base.repo.bak_2016-07-28
-rw-r--r--. 1 root root 638 Nov 27 2013 CentOS-Debuginfo.repo.bak_2016-07-28
-rw-r--r--. 1 root root 630 Nov 27 2013 CentOS-Media.repo.bak_2016-07-28
-rw-r--r--. 1 root root 3664 Nov 27 2013 CentOS-Vault.repo.bak_2016-07-28
-rw-r--r--. 1 root root 120 Jul 25 18:24 cobbler-config.repo.bak_2016-07-28
另外,跟heartbeat不同的是,drbd需要两块硬盘,所以这里我们还需要添加一块硬盘,我是在虚拟机操作的,直接添加一块2G的硬盘。
[ ~]# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000693e3
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
2、安装drbd
drbd的安装有多种方式,可以源码编译安装,也可以使用rpm包进行安装,当然在centos上也可以使用yum安装,这里我采用yum安装的方式。
rpm -Uvhhttp://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm
yum update -y
yum -y install kernel*
yum -y install drbd83-utils kmod-drbd83
modprobe drbd
因为更新了内核,所以需要重启才能加载drbd模块,所以使用yum安装完kernel之后需要重启两台服务器,如果不重启则会出现以下问题:
[ ~]# uname -r
2.6.32-431.el6.x86_64
[ ~]# lsmod|grep drbd
[ ~]# modprobe drbd
FATAL: Module drbd not found.
[ ~]# echo $?
1
重启之后重试:
[ ~]# uname -r
2.6.32-642.4.2.el6.x86_64
[ ~]# lsmod |grep drbd
drbd 332493 0
[ ~]# /sbin/modprobe drbd
[ ~]# echo $?
0
3、准备drbd设备
先对新添加的磁盘进行分区操作,这里仍然以其中一台为例。
[ ~]# fdisk -cu /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x198bc436.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won‘t be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): p
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders, total 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x198bc436
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-4194303, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303):
Using default value 4194303
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
4、编辑drbd配置文件
根据drbd的官方文档,drbd的配置文件是/etc/drbd.conf,但是这个文件中只有简单的2行内容,它引用了/etc/drbd.d/下的global_common.conf和*.res文件,这点和nginx、apache的配置文件类似,我们可以把多个resource相同的定义放到global中去,然后添加不同的res文件,从而更有效和方便的管理drbd的配置文件。
稿源:勤快学QKXue.NET
扩展阅读:
CentOS 6.5上部署drbd
http://qkxue.net/info/30522/CentOS-drbd-6-5
标签:
原文地址:http://www.cnblogs.com/qkxue/p/5904876.html