본문 바로가기
RedHatEnterpriseLinux

soft ware raid 1 구성

by 북한산산적 2012. 2. 8.

SOFT WARE RAID 1 구성

KVM에 가상 하드를 2개 추가

[root@localhost ~]# fdisk -l


Disk /dev/vdb: 1048 MB, 1048576000 bytes

16 heads, 63 sectors/track, 2031 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000


Disk /dev/vdb doesn't contain a valid partition table


Disk /dev/vdc: 1048 MB, 1048576000 bytes

16 heads, 63 sectors/track, 2031 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000


2개의 하드가 1048mb 용량을 가지고 있는것을 확인할수 있다.

/dev/vdb

/dev/vdc

RAID 장치 활성화 확인


[root@localhost ~]# cat /proc/mdstat

Personalities :

unused devices: <none>

[root@localhost ~]#



파티션 타입을 fd(Linux raid auto) 로 설정

[root@localhost ~]# fdisk /dev/vdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x1a33a14a.

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): n //파티션 생성

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-2031, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-2031, default 2031):

Using default value 2031


Command (m for help): t //타입을 설정

Selected partition 1

Hex code (type L to list codes): l // 여러가지 타입을 출력하여 보여준다.

// 타입 출력 생략

Hex code (type L to list codes): fd // (Linux raid auto)

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.



[root@localhost ~]# fdisk /dev/vdc

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x28b9e6a2.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.


/dev/vdb

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): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-2031, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-2031, default 2031):

Using default value 2031


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.




fdisk –l

[root@localhost ~]# fdisk -l


Device Boot Start End Blocks Id System

/dev/vda1 * 3 206 102400 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/vda2 206 2286 1048576 82 Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/vda3 2286 20318 9088000 83 Linux

Partition 3 does not end on cylinder boundary.


Disk /dev/vdb: 1048 MB, 1048576000 bytes

16 heads, 63 sectors/track, 2031 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x1a33a14a


Device Boot Start End Blocks Id System

/dev/vdb1 1 2031 1023592+ fd Linux raid autodetect


Disk /dev/vdc: 1048 MB, 1048576000 bytes

16 heads, 63 sectors/track, 2031 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x28b9e6a2


Device Boot Start End Blocks Id System

/dev/vdc1 1 2031 1023592+ fd Linux raid autodetect

Linux raid autodetect 로 변화 한것을 확인 할수 있다





mdadm 명령어로 레이드 생성

[root@localhost ~]# mdadm --create /dev/md1 --level=1 --raid-device=2 /dev/vdb1 /dev/vdc1


mdadm: Note: this array has metadata at the start 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.90

Continue creating array? y

mdadm: Defaulting to version 1.2 metadata

mdadm: array /dev/md1 started.


[root@localhost ~]# mdadm --detail --scan >/etc/mdadm.conf

[root@localhost ~]# cat /etc/mdadm.conf

ARRAY /dev/md1 metadata=1.2 name=localhost.localdomain:1 UUID=07880e97:e0b1e45e:3ef525a4:7d782ba3

[root@localhost ~]#


mdadm --detail --scan >/etc/mdadm.conf

mdadm.conf md1 장치값이 안들어가 있으면 리붓시.. md127 등 다른 device 로 잡힐수 있다.


/dev/md1 포멧

[root@localhost ~]# mkfs.ext3 /dev/md1


마운트 할 디렉토리를 만들어 주고 /etc/fstab 을 수정하여 장치를 마운트 해준다.

[root@localhost ~]# mkdir /rplinux

[root@localhost ~]# vi /etc/fstab


/dev/md1 /rplinux ext3 defaults 0 0



reboot 후 장치 연결 확인

[root@localhost ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/vda3 8.6G 2.4G 5.8G 30% /

tmpfs 504M 0 504M 0% /dev/shm

/dev/vda1 97M 26M 67M 28% /boot

/dev/md1 984M 18M 917M 2% /rplinux


[root@localhost ~]# mdadm --detail --scan

ARRAY /dev/md1 metadata=1.2 name=localhost.localdomain:1 UUID=07880e97:e0b1e45e:3ef525a4:7d782ba3


[root@localhost ~]# mdadm --detail /dev/md1

/dev/md1:

Version : 1.2

Creation Time : Tue Dec 13 18:31:47 2011

Raid Level : raid1

Array Size : 1023580 (999.76 MiB 1048.15 MB)

Used Dev Size : 1023580 (999.76 MiB 1048.15 MB)

Raid Devices : 2

Total Devices : 2

Persistence : Superblock is persistent


Update Time : Tue Dec 13 18:44:46 2011

State : clean

Active Devices : 2

Working Devices : 2

Failed Devices : 0

Spare Devices : 0


Name : localhost.localdomain:1 (local to host localhost.localdomain)

UUID : 07880e97:e0b1e45e:3ef525a4:7d782ba3

Events : 17


Number Major Minor RaidDevice State

0 252 17 0 active sync /dev/vdb1

1 252 33 1 active sync /dev/vdc1


레이드 상태 확인

[root@localhost ~]# cat /proc/mdstat

Personalities : [raid1]

md1 : active raid1 vdb1[0] vdc1[1]

1023580 blocks super 1.2 [2/2] [UU] // UU 정상적인 하드 상태

unused devices: <none>



트러블 슈팅


/dev/vdb1

/dev/vdc1 // 하드 하나를 빼고 부팅 후 raid 상태 확인


[root@localhost ~]# cat /proc/mdstat

Personalities : [raid1]

md1 : active raid1 vdb1[0]

1023580 blocks super 1.2 [2/1] [U_] //


하드 2개가 정상적으로 마운트 되어 있을때는 UU 라고 나왔지만 하드 하나가 빠졌을때는 U_ 라고 나온다.

[root@localhost ~]# mdadm /dev/md1 --add /dev/vdc1

mdadm: re-added /dev/vdc1

[root@localhost ~]# cat /proc//mdstat

Personalities : [raid1]

md1 : active raid1 vdc1[1] vdb1[0]

1023580 blocks super 1.2 [2/1] [U_]

[>....................] recovery = 4.5% (46656/1023580) finish=2.0min speed=7776K/sec



[root@localhost ~]# cat /proc/mdstat

Personalities : [raid1]

md1 : active raid1 vdc1[1] vdb1[0]

1023580 blocks super 1.2 [2/2] [UU]

정상적인 raid 상태를 확인할수 있다



Software RAID 삭제 방법

umount /dev/md0

mdadm –S /dev/md0

mdadm –-zero-superblock /dev/vdb1

mdadm -–zero-superblock /dev/vdc1









http://www.tcpdump.com/kb/os/linux/removing-raid-devices.html