kinght2008 发表于 2019-1-7 09:49:31

DRBD+heartbeat+NFS组合应用

Ip配置
Bj1.com

http://blog.运维网.com/attachment/201205/001354652.png

Bj2.com

http://blog.运维网.com/attachment/201205/001420608.png
  未说明的 两个节点一样
配置 hosts文件

# 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.10.101 bj1.com
192.168.10.102 bj2.com
#


配置 yum
# cat /etc/yum.repos.d/rhel-debuginfo.repo

name=Red Hat Enterprise Linux server
baseurl=file:///mnt/cdrom/Server
enabled=1
gpgcheck=1
gpgkey=file:///mnt/cdrom/rpm-gpg/RPM-GPG-KEY-redhat-release

name=Red Hat Enterprise Linux cluster
baseurl=file:///mnt/cdrom/Cluster
enabled=1
gpgcheck=1
gpgkey=file:///mnt/cdrom/rpm-gpg/RPM-GPG-KEY-redhat-release

name=Red Hat Enterprise Linux clusterstorage
baseurl=file:///mnt/cdrom/ClusterStorage
enabled=1
gpgcheck=1
gpgkey=file:///mnt/cdrom/rpm-gpg/RPM-GPG-KEY-redhat-release





划分磁盘
# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id System
/dev/sda1   *         1          13      104391   83 Linux
/dev/sda2            14      1318    10482412+ 83 Linux
/dev/sda3            1319      1383      522112+ 82 Linux swap / Solaris
# fdisk /dev/sda

The number of cylinders for this disk is set to 2610.
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 (1384-2610, default 1384):
Using default value 1384
Last cylinder or +size or +sizeM or +sizeK (1384-2610, default 2610): +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:
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
# partprobe /dev/sda
# cat /proc/partitions
major minor #blocks name

   8   0   20971520 sda
   8   1   104391 sda1
   8   2   10482412 sda2
   8   3   522112 sda3
   8   4   987997 sda4
#
安装DBRD服务包
# ll

-rw------- 1 root root   1296 03-06 01:14 anaconda-ks.cfg
drwxr-xr-x 2 root root   4096 03-06 17:29 Desktop
-rw-r--r-- 1 root root 221868 2012-05-08 drbd83-8.3.8-1.el5.centos.i386.rpm
-rw-r--r-- 1 root root 35768 03-06 01:13 install.log
-rw-r--r-- 1 root root   4713 03-06 01:10 install.log.syslog
-rw-r--r-- 1 root root 125974 2012-05-08 kmod-drbd83-8.3.8-1.el5.centos.i686.rpm
# yum localinstall *.rpm --nogpgcheck -y
# cp /usr/share/doc/drbd83-8.3.8/drbd.conf /etc/
编辑相关文件
# cd /etc/drbd.d/
# ll

-rw-r--r-- 1 root root 315 2012-05-09 global_common.conf
-rw-r--r-- 1 root root 1418 2012-05-09 global_common.conf.bak
-rw-r--r-- 1 root root 232 2012-05-09 web.res
# cat 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;
      }
}
# cat web.res
resource web {
      on bj1.com {
      device /dev/drbd0;
      disk    /dev/sda4;
      address 192.168.10.101:7789;
      meta-disk       internal;
                }
      on bj2.com {
      device /dev/drbd0;
      disk    /dev/sda4;
      address 192.168.10.102:7789;
      meta-disk       internal;
                }


}
创建资源web

http://blog.运维网.com/attachment/201205/001923203.png


启动服务

http://blog.运维网.com/attachment/201205/002039780.png

设置主节点
# drbdadm -- --overwrite-data-of-peer primary web
#mount /dev/drbd0 /mnt/hf
# drbd-overview
0:web SyncSource Primary/Secondary UpToDate/Inconsistent C r----
      [=>..................] sync'ed: 10.4% (890392/987928)K delay_probe: 9
#
格式化
# mkdir /mnt/hf
# mkfs -t ext3 -L drbdweb /dev/drbd0
mke2fs 1.39 (29-May-2006)
Filesystem label=drbdweb
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
123648 inodes, 246982 blocks
12349 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=255852544
8 block groups
32768 blocks per group, 32768 fragments per group
15456 inodes per group
Superblock backups stored on blocks:
      32768, 98304, 163840, 229376

Writing inode tables: done                           
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
# df -h
   
/dev/sda2             9.7G 2.6G 6.6G 29% /
/dev/sda1            99M   12M   83M 12% /boot
tmpfs               101M   0 101M   0% /dev/shm
/dev/hdc            2.8G 2.8G   0 100% /media/RHEL_5.4 i386 DVD
/dev/hdc            2.8G 2.8G   0 100% /mnt/cdrom
#

察看状态 主节点上
# service drbd status
drbd driver loaded OK; device status:
version: 8.3.8 (api:88/proto:86-94)
GIT-hash: d78846e52224fd00562f7c225bcc25b2d422321d build by mockbuild@builder10.centos.org, 2010-06-04 08:04:16
m:res cs         ro               ds                p mounted fstype
0:web Connected Primary/Secondary UpToDate/UpToDate C /mnt/hf ext3
#
备用节点上
# service drbd status
drbd driver loaded OK; device status:
version: 8.3.8 (api:88/proto:86-94)
GIT-hash: d78846e52224fd00562f7c225bcc25b2d422321d build by mockbuild@builder10.centos.org, 2010-06-04 08:04:16
m:res cs         ro               ds               p mounted fstype
0:web Connected Secondary/Primary UpToDate/UpToDate C
#
NFS配置

#vim /etc/init.d/nfs
stop)
      # Stop daemons.
      echo -n $"Shutting down NFS mountd: "
      killproc rpc.mountd
      echo
      echo -n $"Shutting down NFS daemon: "
      killproc nfsd -9
      echo
      if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then
                echo -n $"Shutting down NFS quotas: "
                killproc rpc.rquotad
                RETVAL=$?
                echo
配置heartbeat
# yum localinstall heartbeat-2.1.4-9.el5.i386.rpm heartbeat-pils-2.1.4-10.el5.i386.rpm heartbeat-stonith-2.1.4-10.el5.i386.rpm libnet-1.1.4-3.el5.i386.rpm perl-MailTools-1.77-1.el5.noarch.rpm --nogpgcheck –y
# cp /usr/share/doc/heartbeat-2.1.4/ha.cf /etc/ha.d/
# cp /usr/share/doc/heartbeat-2.1.4/haresources /etc/ha.d/
# cp /usr/share/doc/heartbeat-2.1.4/authkeys /etc/ha.d/
# vim /etc/ha.d/ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility   local0
keepalive 2
deadtime 10
udpport 694
ucast eth0 192.168.10.102
ping 192.168.10.1
auto_failback off
node    bj1,com
node    bj2.com
配置haresources
# echo "server1 IPaddr::192.168.20.188/24/eth0 drbddisk::web Filesystem::/dev/drbd0::/mnt/hf::ext3 killnfsd" >> haresources
authkeys 配置相同
auth 1
1 crc
#2 sha1 HI!
#3 md5 Hello!
配置killnsfd
# cat /etc/ha.d/resource.d/killnfsd
killall -9 nfsd;/etc/init.d/nfs restart;exit 0
#
修改权限
# chmod 600 /etc/ha.d/authkeys
# chmod 755 /etc/ha.d/resource.d/killnfsd
开启heartbeat服务
# service heartbeat start; chkconfig heartbeat on
Starting High-Availability services:
2012/05/09_14:28:26 INFO: Resource is stopped
#




页: [1]
查看完整版本: DRBD+heartbeat+NFS组合应用