4、新建分区:
[root@master ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 1958.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n #增加新分区
Command action
e extended
p primary partition (1-4)
p #增加主分区
Selected partition 4
First cylinder (328-1958, default 328): #默认柱面,直接回车
Using default value 328
Last cylinder or +size or +sizeM or +sizeK (328-1958, default 1958): +1G #大小为1G
Command (m for help): w #保存退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@master ~]#partprobe /dev/sda
查看分区:
[root@master ~]#cat /proc/partitions
5、安装drdb:
[root@master ~]# yum localinstall drbd83-8.3.8-1.el5.CentOS.i386.rpm kmod-drbd83-8.3.8-1.el5.centos.i686.rpm –nogpgcheck -y
加载DRBD 模块
[root@master ~]# modprobe drbd
查看模块加载
[root@master ~]# lsmod |grep drbd
drbd 228528 0
编辑配置文件
[root@master ~]# vim /etc/drbd.conf
在底行模式下输入“r /usr/share/doc/drbd83-8.3.8/drbd.conf”。
在从属服务器执行相同的操作;
[root@master ~]# cd /etc/drbd.d/
[root@master drbd.d]# cp global_common.conf global_common.conf.bak
[root@master drbd.d]# vim global_common.conf
内容为:
global {
usage-count no;
# minor-count dialog-refresh disable-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;
}
}
定义资源:
名字为web.res
编辑
[root@master drbd.d]# vim web.res
resource web {
on master {
device /dev/drbd0;
disk /dev/sda4;
address 192.168.1.2:7898;
meta-disk internal;
}
on slave {
device /dev/drbd0;
disk /dev/sda4;
address 192.168.1.3:7898;
meta-disk internal;
}
}
将此两个文件拷贝到从属服务器中(地址为192.168.1.3)
[root@master drbd.d]# scp global_common.conf 192.168.1.3:/etc/drbd.d/
[root@master drbd.d]# scp web.res 192.168.1.3:/etc/drbd.d/