drbd之part2

[root@data-1-1 ~]# fdisk -l


   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         385      394224   83  Linux
/dev/sdb2             386         512      130048   83  Linux
[root@data-1-1 ~]# mkfs.ext4 /dev/sdb1
[root@data-1-1 ~]# tune2fs -c -1 /dev/sdb1
tune2fs 1.41.12 (17-May-2010)
Setting maximal mount count to -1

[root@data-1-2 ~]# mkfs.ext4 /dev/sdb1
[root@data-1-2 ~]# tune2fs -c -1 /dev/sdb1
tips这里的meta data分区一定不能够格式化建立文件系统
分好的区不能挂载
生产环境drbd meta data  分区一般可设为1-2G
[root@data-1-1 soft]# export LC_ALL=C
[root@data-1-1 soft]# wget http://oss.linbit.com/drbd/8.4/drbd-8.4.4.tar.gz
[root@data-1-1 drbd-8.4.4]# yum install flex
[root@data-1-1 soft]# tar xf drbd-8.4.4.tar.gz
#./configure --prefix=/application/drbd8.4.4 --with-km --with-heartbeat --sysconfdir=/etc/
第二个参数是激活内核,整合heartbeat
#ls -ld /usr/src/kernels/$(uname -r)若没有这个路径yum install kernel-devel kernel-headers flex drbd84-utils kmod-drbd84
#make KDIR=/usr/src/kernels/$(uname -r)/
#make install
[root@data-1-2 ~]# export LC_ALL=C
[root@data-1-2 drbd-8.4.4]# yum install flex
[root@data-1-2 ~]# wget http://oss.linbit.com/drbd/8.4/drbd-8.4.4.tar.gz
[root@data-1-2 soft]# tar xf drbd-8.4.4.tar.gz
./configure --prefix=/application/drbd8.4.4 --with-km --with-heartbeat --sysconfdir=/etc/
#make KDIR=/usr/src/kernels/$(uname -r)/
#make install
主机名称        data-1-1               data-1-2
管理ip          eth0:192.168.0.107     eth0:192.168.0.108
drbd管理名称    data                   data
drbd挂载目录    /data                  /data
drbd逻辑设备    /dev/drbd0             /dev/drbd0
drbd对接ip      192.168.1.107          192.168.1.108
drbd存储设备    /dev/sdb1              /dev/sdb1
drbd meta设备   /dev/sdb2[0]           /dev/sdb2[0]
nfs 导出目录    /data                  /data
nfs 虚拟ip      /eth0:192.168.1.249/24 /eth0:192.168.1.249/24
配置内核模块
[root@data-1-1 drbd-8.4.4]# lsmod |grep drbd
root@data-1-1 drbd-8.4.4]# modprobe drbd
检查drbd是否加载到内核
[root@data-1-1 drbd-8.4.4]# lsmod |grep drbd
drbd                  340583  0
libcrc32c               1246  1 drbd

配置文件
[root@data-1-2 drbd-8.4.4]# ll /etc/drbd.conf
-rw-r--r--. 1 root root 133 Jan  8 22:46 /etc/drbd.conf

[root@data-1-2 drbd-8.4.4]# ll /etc/drbd.d/
total 4
-rw-r--r--. 1 root root 1836 Jan  8 22:46 glob
/etc/drbd.conf
global {
   usage-count no;
}

common {
    syncer {
    rate 10M;#工作中开大一点
    verify-alg crc32c;
    }
}
#primary for drbd1
若增加资源就增加resource
resource data {
     protocol C;
     disk {
     on-io-error detach;
     }
    
    on data-1-1 {
    device /dev/drbd0;
    disk /dev/sdb1;
    address 192.168.1.107:7788;#直连
    meta-disk /dev/sdb2[0];
    }
    
    on data-1-2 {
    device /dev/drbd0;
    disk /dev/sdb1;
    address 192.168.1.108:7788;#直连
    meta-disk /dev/sdb2[0];
    }
}

[root@data-1-2 drbd-8.4.4]# vi /etc/drbd.conf
[root@data-1-1 drbd-8.4.4]# vi /etc/drbd.conf
[root@data-1-2 drbd-8.4.4]# vi /etc/hosts
[root@data-1-1 drbd-8.4.4]# vi /etc/hosts
[root@data-1-2 drbd-8.4.4]# tail -2 /etc/hosts;
192.168.1.107    data-1-1
192.168.1.108    data-1-2


[root@data-1-1 drbd-8.4.4]# drbdadm --help

USAGE: drbdadm COMMAND [OPTION...] {all|RESOURCE...}

GENERAL OPTIONS:
  --stacked, -S
  --dry-run, -d
  --verbose, -v
  --config-file=..., -c ...
  --config-to-test=..., -t ...
  --drbdsetup=..., -s ...
  --drbdmeta=..., -m ...
  --drbd-proxy-ctl=..., -p ...
  --sh-varname=..., -n ...
  --peer=..., -P ...
  --version, -V
  --setup-option=..., -W ...
  --help, -h

COMMANDS:
 attach                             disk-options                       
 detach                             connect                            
 net-options                        disconnect                         
 up                                 resource-options                   
 down                               primary                            
 secondary                          invalidate                         
 invalidate-remote                  outdate                            
 resize                             verify                             
 pause-sync                         resume-sync                        
 adjust                             adjust-with-progress               
 wait-connect                       wait-con-int                       
 role                               cstate                             
 dstate                             dump                               
 dump-xml                           create-md                          
 show-gi                            get-gi                             
 dump-md                            wipe-md                            
 apply-al                           hidden-commands                    

Version: 8.4.4 (api:1)
GIT-hash: 74402fecf24da8e5438171ee8c19e28627e1c98a build by root@data-1-1, 2016-01-08 22:44:23
[root@data-1-1 drbd-8.4.4]# drbdadm create-md --help

USAGE: drbdadm create-md [OPTION...] {all|RESOURCE...}

GENERAL OPTIONS:
  --stacked, -S
  --dry-run, -d
  --verbose, -v
  --config-file=..., -c ...
  --config-to-test=..., -t ...
  --drbdsetup=..., -s ...
  --drbdmeta=..., -m ...
  --drbd-proxy-ctl=..., -p ...
  --sh-varname=..., -n ...
  --peer=..., -P ...
  --version, -V
  --setup-option=..., -W ...
  --help, -h

Version: 8.4.4 (api:1)


初始化meta data
[root@data-1-1 drbd-8.4.4]# drbdadm create-md data
Writing meta data...
initializing activity log
NOT initializing bitmap
New drbd meta data block successfully created.
[root@data-1-1 drbd-8.4.4]# drbdadm up data       
/application/drbd8.4.4/var/run/drbd: No such file or directory
/application/drbd8.4.4/var/run/drbd: No such file or directory
0: Failure: (119) No valid meta-data signature found.

    ==> Use 'drbdadm create-md res' to initialize meta-data area. <==

Command 'drbdsetup attach 0 /dev/sdb1 /dev/sdb2 0 --on-io-error=detach --resync-rate=10M' terminated with exit code 10

[root@data-1-1 drbd-8.4.4]# drbdadm create-md data  ###########

Valid meta data seems to be in place.
Do you really want to overwrite?
[need to type 'yes' to confirm] yes

Writing meta data...
md_offset 0
al_offset 4096
bm_offset 36864

Found some data

 ==> This might destroy existing data! <==

Do you want to proceed?
[need to type 'yes' to confirm] yes

initializing activity log
NOT initializing bitmap
New drbd meta data block successfully created.
[root@data-1-1 drbd-8.4.4]# mkdir /application/drbd8.4.4/var/run/drbd -p
root@data-1-1 drbd-8.4.4]# dd if=/dev/zero of=/dev/sdb2 bs=1K count=100

[root@data-1-1 drbd-8.4.4]# drbdadm up data
no valid meta data found
Command 'drbdmeta 0 v08 /dev/sdb2 0 apply-al' terminated with exit code 255
解决方法:
drbdadm up all
相当于以下三个命令的组合
drbdadm attach all
drbdadm syncer all
drbdadm connect all
[root@data-1-1 drbd-8.4.4]# fdisk -l

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         385      394224   83  Linux
/dev/sdb2             386         512      130048   83  Linux

[root@data-1-1 drbd-8.4.4]# fdisk /dev/sdb
Command (m for help): d########
Partition number (1-4): 2########

Command (m for help): p#######33
Command (m for help): d####
Selected partition 1

Command (m for help): p######

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): w####
[root@data-1-1 drbd-8.4.4]# partprobe
[root@data-1-1 drbd-8.4.4]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        18G  2.7G   14G  16% /
tmpfs           495M  228K  495M   1% /dev/shm
/dev/sda1       291M   34M  242M  13% /boot
root@data-1-1 drbd-8.4.4]# fdisk /dev/sdb
Command (m for help): n####
Command action
   e   extended
   p   primary partition (1-4)
p###
Partition number (1-4): 1##
First cylinder (1-512, default 1): ##
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-512, default 512): 256####
Command (m for help): n######
Command action
   e   extended
   p   primary partition (1-4)
p#####
Partition number (1-4): 2####3
First cylinder (257-512, default 257):
Using default value 257
Last cylinder, +cylinders or +size{K,M,G} (257-512, default 512): ##
Using default value 512

Command (m for help): p###

Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xdab6013b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         256      262128   83  Linux
/dev/sdb2             257         512      262144   83  Linux
Command (m for help): w##
The partition table has been altered!

Calling ioctl() to re-read partition table.

[root@data-1-1 drbd-8.4.4]# partprobe

[root@data-1-1 drbd-8.4.4]#reboot
[root@data-1-1 ~]# modprobe drbd
[root@data-1-1 ~]# lsmod|grep drbd
drbd                  340583  0
libcrc32c               1246  1 drbd
[root@data-1-1 ~]# mkfs.ext4 /dev/sdb1
[root@data-1-1 ~]# tune2fs -c -1 /dev/sd
tune2fs 1.41.12 (17-May-2010)
tune2fs: No such file or directory while trying to open /dev/sd
Couldn't find valid filesystem superblock.
[root@data-1-1 ~]# tune2fs -c -1 /dev/sdb1
tune2fs 1.41.12 (17-May-2010)
Setting maximal mount count to -1
[root@data-1-1 ~]# drbdadm create-md data
[root@data-1-1 ~]# drbdadm up data
[root@data-1-1 ~]# cat /proc/drbd
version: 8.4.4 (api:1/proto:86-101)
GIT-hash: 74402fecf24da8e5438171ee8c19e28627e1c98a build by root@data-1-1, 2016-01-08 22:44:43
 0: cs:Connected ro:Secondary/Secondary ds:Inconsistent/Inconsistent C r-----
    ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:2




[root@data-1-2 drbd-8.4.4]# drbdadm create-md data
Writing meta data...
initializing activity log
NOT initializing bitmap
New drbd meta data block successfully created.
[root@data-1-2 drbd-8.4.4]# mkdir /application/drbd8.4.4/var/run/drbd -p
[root@data-1-2 drbd-8.4.4]# drbdadm up data
Device '0' is configured!
Command 'drbdmeta 0 v08 /dev/sdb2 0 apply-al' terminated with exit code 20



你可能感兴趣的:(drbd之part2)