RHEL6.5 部署RAID1

來源:互聯網
上載者:User

標籤:raid1   rhel6.5   

# uname -aLinux 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-releaseRed Hat Enterprise Linux Server release 6.4(Santiago)
使用rpm 安裝mdadm
[[email protected] ~]# mount /dev/cdrom/mnt/cdrom/mount: block device /dev/sr0 iswrite-protected, mounting read-only[[email protected] ~]# cd /mnt/cdrom/Packages/[[email protected] Packages]# rpm -ivhmdadm-3.2.5-4.el6.x86_64.rpmPreparing...               ########################################### [100%]       package mdadm-3.2.5-4.el6.x86_64 is already installed
查看安裝檔案

 

[[email protected] Packages]# rpm -qa mdadmmdadm-3.2.5-4.el6.x86_64[[email protected] Packages]# rpm -qc mdadm/etc/cron.d/raid-check/etc/sysconfig/raid-check

 

格式化硬碟

 

[[email protected] Packages]# fdisk /dev/sdbDevice contains neither a valid DOSpartition table, nor Sun, SGI or OSF disklabelBuilding 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): dNo partition is defined yet! Command (m for help): nCommand action  e   extended  p   primary partition (1-4)pPartition number (1-4): 1First cylinder (1-3916, default 1):Using default value 1Last cylinder, +cylinders or +size{K,M,G}(1-3916, default 3916):Using default value 3916 Command (m for help): tSelected partition 1Hex code (type L to list codes): fdChanged system type of partition 1 to fd(Linux raid autodetect) Command (m for help): wThe partition table has been altered! Calling ioctl() to re-read partition table.Syncing disks.

 

建立RAID1卷

 

[[email protected] Packages]#  mdadm -Cv /dev/md0 -l1 -n2  /dev/sdc /dev/sdbmdadm: /dev/sdc appears to contain anext2fs file system   size=31457280K  mtime=Thu Aug 1414:57:50 2014mdadm: 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=0.90mdadm: /dev/sdb appears to contain anext2fs file system   size=31457280K  mtime=Thu Aug 1414:44:05 2014mdadm: /dev/sdb appears to be part of araid array:   level=raid0 devices=0 ctime=Thu Jan 1 08:00:00 1970mdadm: partition table exists on /dev/sdbbut will be lost or      meaningless after creating arraymdadm: size set to 31440768KContinue creating array? ymdadm: Defaulting to version 1.2 metadatamdadm: array /dev/md0 started.[[email protected] Packages]# cd /[[email protected] /]# cat /proc/mdstatPersonalities : [raid1]md0 : active raid1 sdb[1] sdc[0]     31440768 blocks super 1.2 [2/2] [UU]     [===>.................]  resync= 16.4% (5166208/31440768) finish=2.1min speed=206648K/secunused devices: <none>

 

 

格式化    RAID卷
[[email protected] /]# mkfs -t ext4 /dev/md0mke2fs 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 blocks1966080 inodes, 7860192 blocks393009 blocks (5.00%) reserved for thesuper userFirst data block=0Maximum filesystem blocks=4294967296240 block groups32768 blocks per group, 32768 fragments pergroup8192 inodes per groupSuperblock backups stored on blocks:       32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,       4096000 Writing inode tables: doneCreating journal (32768 blocks): doneWriting superblocks and filesystemaccounting information: done This filesystem will be automaticallychecked every 29 mounts or180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

將RAID卷掛載到 /DATA 目錄下
[[email protected] /]# mount /dev/md0 /DATA

 

 

將檔案寫入DATA下
[[email protected] /]#cd DATA[[email protected] DATA]# lltotal 16drwx------. 2 root root 16384 Aug 14 15:06lost+found[[email protected] DATA]# touch 123.txt[[email protected] DATA]# touch 456.txt[[email protected] DATA]# touch 789.txt[[email protected] DATA]# vi 123.txt[[email protected] DATA]# cat 123.txt12345678asfghrtyjukT

 

類比磁碟壞掉

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/45/DD/wKioL1PskrWxoIs8AABNtBJicqc409.jpg" style="float:none;" title="snap013.jpg" alt="wKioL1PskrWxoIs8AABNtBJicqc409.jpg" />

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/45/DB/wKiom1PskZ2S532wAAFO-pryqWI255.jpg" style="float:none;" title="snap014.jpg" alt="wKiom1PskZ2S532wAAFO-pryqWI255.jpg" />

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/45/DD/wKioL1PskraAgvQ8AAFOpqb-ZVE190.jpg" style="float:none;" title="snap015.jpg" alt="wKioL1PskraAgvQ8AAFOpqb-ZVE190.jpg" />

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/45/DB/wKiom1PskZ2Q3sxcAAEDtrtR2vw285.jpg" style="float:none;" title="snap016.jpg" alt="wKiom1PskZ2Q3sxcAAEDtrtR2vw285.jpg" />



可以看到此時串連虛擬機器的的磁碟只有兩個

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/45/DD/wKioL1PskrbT5KhdAAE5nmakoV8232.jpg" style="float:none;" title="snap017.jpg" alt="wKioL1PskrbT5KhdAAE5nmakoV8232.jpg" />


進入虛擬機器

查看/DATA 目錄

 

 

發現原檔案依然存在


650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/45/DB/wKiom1PskZ7gEZORAAYBanxzCBk422.jpg" style="width:850px;height:817px;" title="snap018.jpg" width="850" height="817" border="0" hspace="0" vspace="0" alt="wKiom1PskZ7gEZORAAYBanxzCBk422.jpg" />


查看系統日誌
[[email protected] DATA]# tail -f/var/log/messagesAug 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 00Aug 14 15:19:15 hs105 kernel: Buffer I/Oerror on device sdb, logical block 7864319Aug 14 15:19:15 hs105 kernel: sd 2:0:1:0:[sdb] Unhandled error codeAug 14 15:19:15 hs105 kernel: sd 2:0:1:0:[sdb] Result: hostbyte=DID_NO_CONNECT driverby                             te=DRIVER_OKAug 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 00Aug 14 15:19:15 hs105 kernel: Buffer I/O erroron device sdb, logical block 7864319Aug 14 15:19:15 hs105 kernel: sd 2:0:1:0:[sdb] Unhandled error codeAug 14 15:19:15 hs105 kernel: sd 2:0:1:0:[sdb] Result: hostbyte=DID_NO_CONNECT driverby                             te=DRIVER_OKAug 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 00Aug 14 15:19:15 hs105 kernel: Buffer I/Oerror on device sdb, logical block 0


接下來進行RAID1的Rebuild


650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/45/DB/wKiom1PskZ7yFSpqAAJEnF7UXpU128.jpg" style="float:none;" title="snap019.jpg" alt="wKiom1PskZ7yFSpqAAJEnF7UXpU128.jpg" />

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/45/DD/wKioL1Pskreh2vA4AAMa6PTICss355.jpg" style="float:none;" title="snap020.jpg" alt="wKioL1Pskreh2vA4AAMa6PTICss355.jpg" />

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/45/DD/wKioL1Pskrew-uA6AABaN61ZyWk103.jpg" style="float:none;" title="snap021.jpg" alt="wKioL1Pskrew-uA6AABaN61ZyWk103.jpg" />


查看raid卷狀態

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/45/DB/wKiom1PskZ_wkuEeAAaVteD15Fs558.jpg" style="width:900px;height:692px;" title="snap022.jpg" width="900" height="692" border="0" hspace="0" vspace="0" alt="wKiom1PskZ_wkuEeAAaVteD15Fs558.jpg" />


[[email protected] ~]# cat /proc/mdstatPersonalities : [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裡面

 

[[email protected] DATA]# mdadm /dev/md127 -a/dev/sdcmdadm: added /dev/sdc 查看raid卷狀態[[email protected] DATA]# cat/proc/mdstatPersonalities : [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

 

[[email protected] DATA]# cd /DATA[[email protected] DATA]# lltotal 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


650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/45/DD/wKioL1PskrqC9PIvAABBqb5X34E374.jpg" style="float:none;" title="snap023.jpg" alt="wKioL1PskrqC9PIvAABBqb5X34E374.jpg" />


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.