MDADM (리눅스RAID) 사용하기

// mdadm 명령으로 직접 리눅스 머신상에서 구현해 보았습니다.

[root@ruset root]# rpm -qi mdadm

Name        : mdadm                        Relocations: (not relocateable)

Version     : 1.0.1                             Vendor: Red Hat, Inc.

Release     : 1                             Build Date: 2003년 01월 29일 (수)

오전 05시 03분 32초

Install Date: 2006년 09월 14일 (목) 오후 12시 06분 54초      Build Host:

stripples.devel.redhat.com

Group       : 시스템 환경/기반              Source RPM: mdadm-1.0.1-1.src.rpm

Size        : 117762                           License: GPL

Signature   : DSA/SHA1, 2003년 02월 24일 (월) 오후 03시 36분 13초, Key ID

219180cddb42a60e

Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>

URL         : http://www.cse.unsw.edu.au/~neilb/source/mdadm/

Summary     : mdadm는 리눅스 md 장치 (소프트웨어 RAID 배열)을 제어합니다.

Description :

mdadm 프로그램은 Linux MD (소프트웨어 RAID) 장치를 만들고, 관리하며 감시하는데

사용됩니다. 따라서 raidtools 패키지와 유사한 기능을 제공합니다.

그러나 mdadm은 단독 프로그램이기 때문에, 설정 파일을 사용하여 일부 작업을

수행하는데 도움을 받을 수는 있지만 설정 파일 없이도 거의 모든 기능을

수행할 수 있습니다.

==> mdadm 패키지 정보

  

[root@ruset root]# rpm -ql mdadm

/etc/mdadm.conf

/etc/rc.d/init.d/mdmonitor

/sbin/mdadm

/usr/share/doc/mdadm-1.0.1

/usr/share/doc/mdadm-1.0.1/COPYING

/usr/share/doc/mdadm-1.0.1/ChangeLog

/usr/share/doc/mdadm-1.0.1/TODO

/usr/share/doc/mdadm-1.0.1/mdadm.conf-example

/usr/share/man/man4/md.4.gz

/usr/share/man/man5/mdadm.conf.5.gz

/usr/share/man/man8/mdadm.8.gz

[root@redhat root]#

==> 각종 설정파일들. 설정파일을 보니 raid-tool과 비슷하게 mdadm.conf파일이 있다. 설정파일로도 구성할 수 있는듯 한데… 이 설정파일을 통한 구성은 찾아보기 힘들었다..

[root@ruset ~]# fdisk -l

Disk /dev/hda: 160.0 GB, 160041885696 bytes

255 heads, 63 sectors/track, 19457 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System

/dev/hda1   *         1      4700  37752718+   7  HPFS/NTFS

/dev/hda2          4701     19456 118527570    f  Win95 Ext’d (LBA)

/dev/hda5          4701     11074  51199123+   7  HPFS/NTFS

/dev/hda6         11075     11087    104391   83  Linux

/dev/hda7         11088     12362  10241406   83  Linux

/dev/hda8         12363     12884   4192933+  82  Linux swap

==>  현재 파티션 구성

[root@ruset ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/hda7             9.7G  4.1G  5.2G  45% /

/dev/hda6              99M   15M   80M  16% /boot

none                 1003M     0 1003M   0% /dev/shm

==> 현재 mount 정보

[root@ruset ~]# fdisk /dev/hda

The number of cylinders for this disk is set to 19457.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/hda: 160.0 GB, 160041885696 bytes

255 heads, 63 sectors/track, 19457 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System

/dev/hda1   *         1      4700  37752718+   7  HPFS/NTFS

/dev/hda2          4701     19456 118527570    f  Win95 Ext’d (LBA)

/dev/hda5          4701     11074  51199123+   7  HPFS/NTFS

/dev/hda6         11075     11087    104391   83  Linux

/dev/hda7         11088     12362  10241406   83  Linux

/dev/hda8         12363     12884   4192933+  82  Linux swap

Command (m for help): n

Command action

   l   logical (5 or over)

   p   primary partition (1-4)

l

First cylinder (12885-19456, default 12885):

Using default value 12885

Last cylinder or +size or +sizeM or +sizeK (12885-19456, default 19456): +1000m

Command (m for help): p

Disk /dev/hda: 160.0 GB, 160041885696 bytes

255 heads, 63 sectors/track, 19457 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System

/dev/hda1   *         1      4700  37752718+   7  HPFS/NTFS

/dev/hda2          4701     19456 118527570    f  Win95 Ext’d (LBA)

/dev/hda5          4701     11074  51199123+   7  HPFS/NTFS

/dev/hda6         11075     11087    104391   83  Linux

/dev/hda7         11088     12362  10241406   83  Linux

/dev/hda8         12363     12884   4192933+  82  Linux swap

/dev/hda9         12885     13007    987966   83  Linux

Command (m for help): n

Command action

   l   logical (5 or over)

   p   primary partition (1-4)

l

First cylinder (13008-19456, default 13008):

Using default value 13008

Last cylinder or +size or +sizeM or +sizeK (13008-19456, default 19456): +1000m

Command (m for help): p

Disk /dev/hda: 160.0 GB, 160041885696 bytes

255 heads, 63 sectors/track, 19457 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System

/dev/hda1   *         1      4700  37752718+   7  HPFS/NTFS

/dev/hda2          4701     19456 118527570    f  Win95 Ext’d (LBA)

/dev/hda5          4701     11074  51199123+   7  HPFS/NTFS

/dev/hda6         11075     11087    104391   83  Linux

/dev/hda7         11088     12362  10241406   83  Linux

/dev/hda8         12363     12884   4192933+  82  Linux swap

/dev/hda9         12885     13007    987966   83  Linux

/dev/hda10        13008     13130    987966   83  Linux

Command (m for help): t

Partition number (1-10): 9

Hex code (type L to list codes): fd

Changed system type of partition 9 to fd (Linux raid autodetect)

Command (m for help): t

Partition number (1-10): 10

Hex code (type L to list codes): fd

Changed system type of partition 10 to fd (Linux raid autodetect)

Command (m for help): p

Disk /dev/hda: 160.0 GB, 160041885696 bytes

255 heads, 63 sectors/track, 19457 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System

/dev/hda1   *         1      4700  37752718+   7  HPFS/NTFS

/dev/hda2          4701     19456 118527570    f  Win95 Ext’d (LBA)

/dev/hda5          4701     11074  51199123+   7  HPFS/NTFS

/dev/hda6         11075     11087    104391   83  Linux

/dev/hda7         11088     12362  10241406   83  Linux

/dev/hda8         12363     12884   4192933+  82  Linux swap

/dev/hda9         12885     13007    987966   fd  Linux raid autodetect

/dev/hda10        13008     13130    987966   fd  Linux raid autodetect

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 장치나 자원이 동작 중.

The kernel still uses the old table.

The new table will be used at the next reboot.

Syncing disks.

[root@ruset ~]# reboot

==> 1기가로 파티션을 2개 구성한후 재부팅을 한다.

[root@ruset root]# fdisk -l

                                                                                

Disk /dev/hda: 160.0 GB, 160041885696 bytes

255 heads, 63 sectors/track, 19457 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

                                                                                

   Device Boot    Start       End    Blocks   Id  System

/dev/hda1   *         1      4700  37752718+   7  HPFS/NTFS

/dev/hda2          4701     19456 118527570    f  Win95 Ext’d (LBA)

/dev/hda5          4701     11074  51199123+   7  HPFS/NTFS

/dev/hda6         11075     11087    104391   83  Linux

/dev/hda7         11088     12362  10241406   83  Linux

/dev/hda8         12363     12884   4192933+  82  Linux swap

/dev/hda9         12885     13007    987966   fd  Linux raid autodetect

/dev/hda10        13008     13130    987966   fd  Linux raid autodetect

[root@redhat root]# mdadm -C /dev/md0 -l 1 -n 2 /dev/hda9 /dev/hda10

mdadm: /dev/hda9 appears to contain an ext2fs file system

    size=987840K  mtime=Fri Oct 20 17:32:33 2006

mdadm: /dev/hda9 appear to be part of a raid array:

    level=1 devices=2 ctime=Tue Oct 17 15:33:51 2006

mdadm: /dev/hda10 appears to contain an ext2fs file system

    size=987840K  mtime=Fri Oct 20 17:32:33 2006

mdadm: /dev/hda10 appear to be part of a raid array:

    level=1 devices=2 ctime=Tue Oct 17 15:33:51 2006

Continue creating array? y

mdadm: array /dev/md0 started.

==> mdadm 명령으로 raid를 구성한다. -l은 raid level, -n은 디바이스 갯수. hda9와 hda10이 예전에 meta정보를 포함하고 있어서 강제로 구성해준다.

[root@redhat root]# more /proc/mdstat

Personalities : [raid1]

read_ahead 1024 sectors

Event: 1

md0 : active raid1 hda10[1] hda9[0]

      987840 blocks [2/2] [UU]

      [>………………..]  resync =  0.6% (6848/987840) finish=9.4min

speed=1712K/sec

unused devices:

==>  resync 하는 중…

[root@redhat root]# mkfs.ext3 /dev/md0

mke2fs 1.32 (09-Nov-2002)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

123648 inodes, 246960 blocks

12348 blocks (5.00%) reserved for the super user

First data block=0

8 block groups

32768 blocks per group, 32768 fragments per group

15456 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376

Writing inode tables: done

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 25 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

==> ext3파일시스템으로 구성해준다.

[root@redhat root]# vi /etc/fstab

#device name            mount point             file    option

dump,fsck

                                                                                

LABEL=/                 /                       ext3    defaults        1 1

LABEL=/boot             /boot                   ext3    defaults        1 2

none                    /dev/pts                devpts  gid=5,mode=620  0 0

none                    /proc                   proc    defaults        0 0

none                    /dev/shm                tmpfs   defaults        0 0

/dev/hda8               swap                    swap    defaults        0 0

/dev/fd0                /mnt/floppy             auto    noauto,owner,kudzu 0 0

/dev/cdrom              /mnt/cdrom              udf,iso9660

noauto,owner,kudzu,ro 0 0

/dev/md0                /mdadm                  ext3    defaults        1 2

==> vi 편집기로 md정보를 기입해준다.

[root@redhat root]# cat /etc/fstab

#device name            mount point             file    option

dump,fsck

                                                                                

LABEL=/                 /                       ext3    defaults        1 1

LABEL=/boot             /boot                   ext3    defaults        1 2

none                    /dev/pts                devpts  gid=5,mode=620  0 0

none                    /proc                   proc    defaults        0 0

none                    /dev/shm                tmpfs   defaults        0 0

/dev/hda8               swap                    swap    defaults        0 0

/dev/fd0                /mnt/floppy             auto    noauto,owner,kudzu 0 0

/dev/cdrom              /mnt/cdrom              udf,iso9660

noauto,owner,kudzu,ro 0 0

/dev/md0                /mdadm                  ext3    defaults        1 2

[root@redhat root]# mount -a

==> mount해준다.

[root@redhat root]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/hda7             9.7G  4.1G  5.2G  45% /

/dev/hda6              99M   15M   80M  16% /boot

none                 1003M     0 1003M   0% /dev/shm

/dev/md0              950M   17M  886M   2% /mdadm

==> 정상적으로 mount된것을 볼 수가 있다.

[root@ruset root]# mdadm –detail /dev/md0

/dev/md0:

        Version : 00.90.00

  Creation Time : Fri Oct 20 17:45:41 2006

     Raid Level : raid1

     Array Size : 987840 (964.69 MiB 1011.55 MB)

    Device Size : 987840 (964.69 MiB 1011.55 MB)

   Raid Devices : 2

  Total Devices : 2

Preferred Minor : 0

    Persistence : Superblock is persistent

    Update Time : Fri Oct 20 17:45:41 2006

          State : dirty, no-errors

Active Devices : 2

Working Devices : 2

Failed Devices : 0

  Spare Devices : 0

    Number   Major   Minor   RaidDevice State

       0       3        9        0      active sync   /dev/hda9

       1       3       10        1      active sync   /dev/hda10

           UUID : 6e1e09ec:619f9d64:acd8d6b1:b4b7ff66

==> –detail 옵션으로 어떻게 구성되었는지 확인한다.

[root@redhat root]# more /proc/mdstat

Personalities : [raid1]

read_ahead 1024 sectors

Event: 1

md0 : active raid1 hda10[1] hda9[0]

      987840 blocks [2/2] [UU]

      

unused devices:

[root@ruset root]#

==> resync완료!…md 구성이 정말 간단해졌다;

서진우

슈퍼컴퓨팅 전문 기업 클루닉스/ 상무(기술이사)/ 정보시스템감리사/ 시스존 블로그 운영자

You may also like...

4 Responses

  1. 2024년 9월 10일

    … [Trackback]

    […] There you will find 24119 more Info to that Topic: nblog.syszone.co.kr/archives/3052 […]

  2. 2024년 9월 15일

    … [Trackback]

    […] Info on that Topic: nblog.syszone.co.kr/archives/3052 […]

  3. 2024년 10월 25일

    … [Trackback]

    […] Read More Information here to that Topic: nblog.syszone.co.kr/archives/3052 […]

  4. 2024년 11월 19일

    … [Trackback]

    […] There you will find 66388 additional Information on that Topic: nblog.syszone.co.kr/archives/3052 […]

페이스북/트위트/구글 계정으로 댓글 가능합니다.