首页 > 代码库 > RHEL6.5 部署RAID1
RHEL6.5 部署RAID1
# uname -a Linux hs105.localdomain2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64 x86_64 x86_64GNU/Linux # cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.4(Santiago)
使用rpm 安装mdadm
[root@hs105 ~]# mount /dev/cdrom/mnt/cdrom/ mount: block device /dev/sr0 iswrite-protected, mounting read-only [root@hs105 ~]# cd /mnt/cdrom/Packages/ [root@hs105 Packages]# rpm -ivhmdadm-3.2.5-4.el6.x86_64.rpm Preparing... ########################################### [100%] package mdadm-3.2.5-4.el6.x86_64 is already installed
查看安装文件
[root@hs105 Packages]# rpm -qa mdadm mdadm-3.2.5-4.el6.x86_64 [root@hs105 Packages]# rpm -qc mdadm /etc/cron.d/raid-check /etc/sysconfig/raid-check
格式化硬盘
[root@hs105 Packages]# fdisk /dev/sdb Device contains neither a valid DOSpartition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with diskidentifier 0xe4366023. Changes will remain in memory only, untilyou decide to write them. After that, of course, the previous contentwon‘t be recoverable. Warning: invalid flag 0x0000 of partitiontable 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): d No partition is defined yet! Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-3916, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G}(1-3916, default 3916): Using default value 3916 Command (m for help): t Selected partition 1 Hex code (type L to list codes): fd Changed system type of partition 1 to fd(Linux raid autodetect) Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
创建RAID1卷
[root@hs105 Packages]# mdadm -Cv /dev/md0 -l1 -n2 /dev/sdc /dev/sdb mdadm: /dev/sdc appears to contain anext2fs file system size=31457280K mtime=Thu Aug 1414:57:50 2014 mdadm: Note: this array has metadata at thestart and may not be suitable as a boot device. If you plan to store ‘/boot‘ on this device please ensure that your boot-loader understands md/v1.x metadata, or use --metadata=http://www.mamicode.com/0.90>
格式化 RAID卷
[root@hs105 /]# mkfs -t ext4 /dev/md0 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 1966080 inodes, 7860192 blocks 393009 blocks (5.00%) reserved for thesuper user First data block=0 Maximum filesystem blocks=4294967296 240 block groups 32768 blocks per group, 32768 fragments pergroup 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystemaccounting information: done This filesystem will be automaticallychecked every 29 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
将RAID卷挂载到 /DATA 目录下
[root@hs105 /]# mount /dev/md0 /DATA
将文件写入DATA下
[root@hs105 /]#cd DATA [root@hs105 DATA]# ll total 16 drwx------. 2 root root 16384 Aug 14 15:06lost+found [root@hs105 DATA]# touch 123.txt [root@hs105 DATA]# touch 456.txt [root@hs105 DATA]# touch 789.txt [root@hs105 DATA]# vi 123.txt [root@hs105 DATA]# cat 123.txt 12345678asfghrtyjuk T
模拟磁盘坏掉
可以看到此时连接虚拟机的的磁盘只有两个
进入虚拟机
查看/DATA 目录
发现原文件依然存在
查看系统日志
[root@hs105 DATA]# tail -f/var/log/messages Aug 14 15:19:15 hs105 kernel: sd 2:0:1:0:[sdb] CDB: Read(10): 28 00 03 bf ff f8 00 00 0 8 00 Aug 14 15:19:15 hs105 kernel: Buffer I/Oerror on device sdb, logical block 7864319 Aug 14 15:19:15 hs105 kernel: sd 2:0:1:0:[sdb] Unhandled error code Aug 14 15:19:15 hs105 kernel: sd 2:0:1:0:[sdb] Result: hostbyte=DID_NO_CONNECT driverby te=DRIVER_OK Aug 14 15:19:15 hs105 kernel: sd 2:0:1:0:[sdb] CDB: Read(10): 28 00 03 bf ff f8 00 00 0 8 00 Aug 14 15:19:15 hs105 kernel: Buffer I/O erroron device sdb, logical block 7864319 Aug 14 15:19:15 hs105 kernel: sd 2:0:1:0:[sdb] Unhandled error code Aug 14 15:19:15 hs105 kernel: sd 2:0:1:0:[sdb] Result: hostbyte=DID_NO_CONNECT driverby te=DRIVER_OK Aug 14 15:19:15 hs105 kernel: sd 2:0:1:0:[sdb] CDB: Read(10): 28 00 00 00 00 00 00 00 0 8 00 Aug 14 15:19:15 hs105 kernel: Buffer I/Oerror on device sdb, logical block 0
接下来进行RAID1的Rebuild
查看raid卷状态
[root@hs105 ~]# cat /proc/mdstat Personalities : [raid1] md127 : active (auto-read-only) raid1sdb[1] 31440768 blocks super 1.2 [2/1] [_U] unused devices: <none>发现/dev/md0 自动更名为md127
md127上存在sdb
于是我们将sdc格式化并
格式化操作参考之前的格式化RAID卷部分
接下来将sdc挂载到md127里面
[root@hs105 DATA]# mdadm /dev/md127 -a/dev/sdc mdadm: added /dev/sdc 查看raid卷状态 [root@hs105 DATA]# cat /proc/mdstat Personalities : [raid1] md127 : active raid1 sdb[2] sdc[1] 31438720 blocks super 1.2 [2/1] [_U] [=>...................] recovery = 7.0% (2201920/31438720) finish=2.4min speed=200174K/sec unused devices: <none>
查看/DATA
[root@hs105 DATA]# cd /DATA [root@hs105 DATA]# ll total 4 -rw-r--r--. 1 root root 23 Aug 14 15:48123.txt -rw-r--r--. 1 root root 0 Aug 14 15:47 456.txt -rw-r--r--. 1 root root 0 Aug 14 15:47 789.txt
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。