博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Centos 6.8 上 DRBD安装和使用
阅读量:4080 次
发布时间:2019-05-25

本文共 7590 字,大约阅读时间需要 25 分钟。

环境:两台虚拟机os:centos 64位 6.8node1:192.168.11.64node2:192.168.11.69安装drbd前在两个虚拟机上加两个大小相同的物理磁盘分区,我这里是/dev/sdb1(注意:未经格式化的)分区如下(在两个节点都操作)[root@node1 ~]# fdisk /dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel with disk identifier 0xa5927bb4.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)WARNING: DOS-compatible mode is deprecated. It's strongly recommended to         switch off the mode (command 'c') and change display units to         sectors (command 'u').Command (m for help): nCommand action   e   extended   p   primary partition (1-4)pPartition number (1-4): 1First cylinder (1-2610, default 1): Using default value 1Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +10GCommand (m for help): wThe partition table has been altered![root@node1 /]# fdisk -lDisk /dev/sda: 53.7 GB, 53687091200 bytes255 heads, 63 sectors/track, 6527 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0007f236   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *           1          64      512000   83  LinuxPartition 1 does not end on cylinder boundary./dev/sda2              64        6528    51915776   8e  Linux LVMDisk /dev/sdb: 10.7 GB, 10737418240 bytes255 heads, 63 sectors/track, 1305 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x2eb7246b   Device Boot      Start         End      Blocks   Id  System/dev/sdb1               1        1305    10482381   83  LinuxDisk /dev/mapper/VolGroup-lv_root: 51.1 GB, 51078234112 bytes255 heads, 63 sectors/track, 6209 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/mapper/VolGroup-lv_swap: 2080 MB, 2080374784 bytes255 heads, 63 sectors/track, 252 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000源码安装(两台机器上都安装)[root@node1 tmp]# tar -xvf drbd-8.3.16.tar.gz[root@node1 drbd-8.3.16]# ./configure --with-km出现错误To (re)make the documentation: make docmake[1]: Leaving directory `/tmp/drbd-8.3.16/documentation'	Userland tools build was successful.    SORRY, kernel makefile not found.    You need to tell me a correct KDIR,    Or install the neccessary kernel source packages.make: *** [check-kdir] Error 1解决方法:安装kernel-devel   (我这是网上下载的)[root@node1 tmp]# rpm -ivh kernel-devel-2.6.32-642.el6.x86_64.rpm Preparing...                ########################################### [100%]   1:kernel-devel           ########################################### [100%]    出现这个错误 Cannot build utils without flex, either install flex or pass the --without-utils option.解决方法:安装flex[root@node1 drbd-8.3.16]# yum -y install flex[root@node1 drbd-8.3.16]# make KDIR=/usr/src/kernels/2.6.32-642.el6.x86_64/[root@node1 drbd-8.3.16]# make install加载drbd模块到内核[root@node2 etc]# depmod [root@node1 drbd-8.3.16]# modprobe drbd[root@node1 drbd-8.3.16]#  lsmod | grep -i drbddrbd                  332493  0 创建挂载点:创建一个用于挂载drbd设备的挂载点(两个节点都执行)[root@node1 etc]# mkdir /pg[root@node2 etc]# mkdir /pg配置drbd(两个节点都执行)配置全局变量[root@node1 drbd-8.3.16]# vim /usr/local/etc/drbd.d/global_common.conf     syncer {                rate 100M;                # rate after al-extents use-rle cpu-mask verify-alg csums-alg        }rate设置同步速度上限,100M则表示同步速率限制在100M/s以内。创建资源配置文件(两个节点均配置)[root@node1 ~]# vim /usr/local/etc/drbd.d/r0.resresource r0 {  on SPEC-PGdatabase {    device    /dev/drbd0;    disk      /dev/sda1;    address   1772.19.93.4:7789;    meta-disk internal;  }  on SPEC-PGback1 {    device    /dev/drbd0;    disk      /dev/sda1;    address   1772.19.93.19:7789;    meta-disk internal;  }}启动drdb[root@node1 ~]# service drbd startStarting DRBD resources: [ d(r0) s(r0) n(r0) ].[root@node1 ~]# cat /proc/drbd version: 8.3.16 (api:88/proto:86-97)GIT-hash: a798fa7e274428a357657fb52f0ecf40192c1985 build by root@node1, 2017-03-22 14:53:18 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:10482024设置主节点[root@node1 ~]#  drbdsetup /dev/drbd0 primary -o[root@node1 ~]# cat /proc/drbdversion: 8.3.16 (api:88/proto:86-97)GIT-hash: a798fa7e274428a357657fb52f0ecf40192c1985 build by root@node1, 2017-03-22 14:53:18 0: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r-----    ns:483328 nr:0 dw:0 dr:484000 al:0 bm:29 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:9998696	[>....................] sync'ed:  4.7% (9764/10236)M	finish: 0:03:47 speed: 43,936 (43,936) K/sec[root@node1 ~]# service drbd statusdrbd driver loaded OK; device status:version: 8.3.16 (api:88/proto:86-97)GIT-hash: a798fa7e274428a357657fb52f0ecf40192c1985 build by root@node1, 2017-03-22 14:53:18m:res  cs          ro                 ds                     p  mounted  fstype0:r0   SyncSource  Primary/Secondary  UpToDate/Inconsistent  C...    sync'ed:    12.4%              (8980/10236)M[root@node1 ~]# service drbd statusdrbd driver loaded OK; device status:version: 8.3.16 (api:88/proto:86-97)[root@node1 ~]# service drbd statusdrbd driver loaded OK; device status:version: 8.3.16 (api:88/proto:86-97)GIT-hash: a798fa7e274428a357657fb52f0ecf40192c1985 build by root@node1, 2017-03-22 14:53:18m:res  cs         ro                 ds                 p  mounted  fstype0:r0   Connected  Primary/Secondary  UpToDate/UpToDate  C格式化磁盘[root@node1 ~]# mkfs.ext3 /dev/drbd0mke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks655360 inodes, 2620506 blocks131025 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=268435456080 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632Writing inode tables: done                            Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 39 mounts or180 days, whichever comes first.  Use tune2fs -c or -i to override.[root@node1 ~]#  mount /dev/drbd0 /pg测试同步在node1上向drbd写入一个测试文件[root@node1 ~]# cd /pg[root@node1 pg]# lslost+found[root@node1 pg]# touch test.txt[root@node1 pg]# lltotal 16drwx------ 2 root root 16384 Mar 23 09:29 lost+found-rw-r--r-- 1 root root     0 Mar 23 09:32 test.txt在node1上卸载drbd磁盘[root@node1 /]# umount /pg/在node1上将primary降为secondary:[root@node1 /]#  drbdadm secondary r0在node2上将secondary升为primary:[root@node2 ~]# drbdadm primary r0[root@node2 ~]# service drbd statusdrbd driver loaded OK; device status:version: 8.3.16 (api:88/proto:86-97)GIT-hash: a798fa7e274428a357657fb52f0ecf40192c1985 build by root@node2, 2017-03-22 13:37:13m:res  cs         ro                 ds                 p  mounted  fstype0:r0   Connected  Primary/Secondary  UpToDate/UpToDate  C将drbd设备挂载到node2节点:[root@node2 ~]# mount /dev/drbd0 /pg查看测试文件是否在:[root@node2 ~]# cd /pg/[root@node2 pg]# lslost+found  test.txt文件存在,说明drbd配置没问题

转载地址:http://dbsni.baihongyu.com/

你可能感兴趣的文章
找工作准备的方向(4月22日写的)
查看>>
关于fwrite写入文件后打开查看是乱码的问题
查看>>
用结构体指针前必须要用malloc,不然会出现段错误
查看>>
Linux系统中的美
查看>>
一些实战项目(linux应用层编程,多线程编程,网络编程)
查看>>
我觉得专注于去学东西就好了,与世无争。
查看>>
原来k8s docker是用go语言写的,和现在所讲的go是一个东西!
查看>>
STM32CubeMX 真的不要太好用
查看>>
STM32CubeMX介绍、下载与安装
查看>>
电机和桨叶要搭配选择
查看>>
现在发现如果无人机的电机不同,浆可能是不能混用的。
查看>>
不要买铝合金机架的无人机,不耐摔,易变形弯曲。
查看>>
ACfly也是基于FreeRTOS的
查看>>
F330装GPS的位置
查看>>
STM32时钟系统
查看>>
我想先用三个或者五个激光测距做无人机的室内定位和避障
查看>>
pixhawk也可以用Airsim仿真
查看>>
《无人机电机与电调技术》可以看看
查看>>
我发现七月在线的GAAS课程基本都讲到了
查看>>
电机堵转
查看>>