絖綛 N@i.jp  昨日:00043024
 今日:00006614
 総計:00299070
keywords
管理者専用
  Post   Add link   Control Panel 































新しいトピック
最新:04/16 19:55


新しいコメント
最新:07/28 16:47






管理人へMAIL

プライバシーポリシー

USBメモリでRAID 5を構築(2)

続きです。mdadmをインストールしてRAIDアレイを構築していきます


4. mdadmをインストールする

 RAIDを構築するには mdadm を使用するので、これをインストールします。インストール時にmdadmのセットアップも行われ、システム起動時にRAIDアレイを起動するか訊かれます。

# apt-get update
# apt-get install mdadm
┌────────────────────┤mdadm を設定しています├──────────────────────┐
│ あなたのシステムのルートファイルシステムが MD アレイ (RAID) 上に配置されているならば、ブートシーケンスの初期段  │
│ 階で MD アレイを開始する必要があります。ルートファイルシステムが MD のような論理ボリューム (LVM) 上にある場合は │
│ 、構成しているアレイ全ての開始が必要です。                                   │
│                                                        │
│ どのアレイがルートファイルシステムの立ち上げに必要かを正確に知っており、ブートシーケンスの後の時点まで意図して  │
│ いるもの以外全てのアレイ起動を遅らせたい場合、ここで最初に起動するアレイを入力してください。そうでない場合、  │
│ 'all' と入力して単に全ての利用可能なアレイを最初に立ち上げてください。                      │
│                                                        │
│ ルートファイルシステムのために、どのアレイも必要ない、あるいはどのアレイも起動したくは無いという場合は、空白の │
│ ままに (あるいは 'none' と入力) してください。これは、カーネルで自動的に起動される場合や起動時にはアレイは不要  │
│ であるという場合です。                                             │
│                                                        │
│ 'all' または 'none' 、あるいはデバイスのリストを 'md0 md1' や 'md/1 md/d0' のようにスペースで区切って入力してく  │
│ ださい (前に付く '/dev/' は省略可能です)。                                    │
│                                                        │
│ ルートファイルシステムに必要な MD アレイ:                                    │
│                                                        │
│ all______________________________________________________ │
│                                                        │
│                           <了解>                          │
│                                                        │
└────────────────────────────────────────────────────────┘

 ルートファイルシステムはmicroSDカードなので、ブート時にはアレイ(RAID)が起動している必要はないのだけど、noneとすると再起動時にいちいち手動でRAIDアレイを起動することになりそうです。なので、このallのままにしてみます。

5. RAID 5を構築する。

 mdadmの使用法(--help)を見て、RAIDの構築方法を調べておきましょう。

# mdadm --help
mdadm is used for building, managing, and monitoring
Linux md devices (aka RAID arrays)
Usage: mdadm --create device options...
            Create a new array from unused devices.
       mdadm --assemble device options...
            Assemble a previously created array.
       mdadm --build device options...
            Create or assemble an array without metadata.
       mdadm --manage device options...
            make changes to an existing array.
       mdadm --misc options... devices
            report on or modify various md related devices.
       mdadm --grow options device
            resize/reshape an active array
       mdadm --incremental device
            add/remove a device to/from an array as appropriate
       mdadm --monitor options...
            Monitor one or more array for significant changes.
       mdadm device options...
            Shorthand for --manage.
Any parameter that does not start with '-' is treated as a device name
or, for --examine-bitmap, a file name.
The first such name is often the name of an md device.  Subsequent
names are often names of component devices.

 For detailed help on the above major modes use --help after the mode
 e.g.
         mdadm --assemble --help
 For general help on options use
         mdadm --help-options

# mdadm --create --help
Usage:  mdadm --create device -chunk=X --level=Y --raid-devices=Z devices

 This usage will initialise a new md array, associate some
 devices with it, and activate the array.   In order to create an
 array with some devices missing, use the special word 'missing' in
 place of the relevant device name.

 Before devices are added, they are checked to see if they already contain
 raid superblocks or filesystems.  They are also checked to see if
 the variance in device size exceeds 1%.
 If any discrepancy is found, the user will be prompted for confirmation
 before the array is created.  The presence of a '--run' can override this
 caution.

 If the --size option is given then only that many kilobytes of each
 device is used, no matter how big each device is.
 If no --size is given, the apparent size of the smallest drive given
 is used for raid level 1 and greater, and the full device is used for
 other levels.

 Options that are valid with --create (-C) are:
  --bitmap=          : Create a bitmap for the array with the given filename
                     : or an internal bitmap is 'internal' is given
  --chunk=      -c   : chunk size in kibibytes
  --rounding=        : rounding factor for linear array (==chunk size)
  --level=      -l   : raid level: 0,1,4,5,6,10,linear,multipath and synonyms
  --parity=     -p   : raid5/6 parity algorithm: {left,right}-{,a}symmetric
  --layout=          : same as --parity, for RAID10: [fno]NN
  --raid-devices= -n : number of active devices in array
  --spare-devices= -x: number of spare (eXtra) devices in initial array
  --size=       -z   : Size (in K) of each drive in RAID1/4/5/6/10 - optional
  --data-offset=     : Space to leave between start of device and start
                     : of array data.
  --force       -f   : Honour devices as listed on command line.  Don't
                     : insert a missing drive for RAID5.
  --run         -R   : insist of running the array even if not all
                     : devices are present or some look odd.
  --readonly    -o   : start the array readonly - not supported yet.
  --name=       -N   : Textual name for array - max 32 characters
  --bitmap-chunk=    : bitmap chunksize in Kilobytes.
  --delay=      -d   : bitmap update delay in seconds.

 createのhelpに注意が書かれています。構成するデバイスに、既にraidのスーパーブロックやファイルシステムが含まれていないかチェックするようで、そのような矛盾が見つかった場合は確認を求めてくるとのこと。調べてみたら、過去にRAIDアレイに組み込んだことがあるデバイスを使う場合は、以下のようにして中身を完全に消去するのが良いとのことです。(例は/dev/sdcを完全消去する場合)

# mdadm --zero-superblock /dev/sdc

 今回は新品のUSBメモリなので完全消去しなくても大丈夫。さて、アレイ(RAID 5)を作成してみます。チャンク(分割して書き込む)サイズは256KiBにしてみました。チャンクサイズは4KiBの整数倍である必要があり、省略時には512KiBになるらしいです。
 大容量のHDDでアレイを構成し、大きなサイズのファイルを扱うなら、チャンクサイズは大きい方が性能が良くなります。しかし、今回は64GBと容量が少ないUSBメモリなので、半分の256KiBくらいが丁度良いんじゃないかと・・・
 --levelオプションには5(RAID 5)を指定、--raid-deviceオプションは構成デバイス数なので3、その後先にudevで作成したデバイス名を3つ指定します。(/dev/usbm[abc]1という書き方でも可)

# mdadm --create /dev/md0 --chunk=256 --level=5 --raid-devices=3 /dev/usbma1 /dev/usbmb1 /dev/usbmc1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
# 

 mdadmコマンドはすぐ返ってきますが、裏では頑張ってRAIDを構築しています。進行状況は"cat /proc/mdstat"で確認できます。

# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sdc1[3] sdb1[1] sda1[0]
      123369472 blocks super 1.2 level 5, 256k chunk, algorithm 2 [3/2] [UU_]
      [>....................]  recovery =  2.9% (1824472/61684736) finish=92.2min speed=10818K/sec

unused devices: <none>

92分ほどかかる見込みだと言ってます。そのまま作業を続けても良いのですが、一応構築が完了するまで待ちました(*2)
 構築中はUSBメモリがかなり熱くなりました。数秒と触っていられないほどの熱さですので、おそらく60度以上にはなったのではないかと思います。熱暴走したり壊れたりしないかな?

 完了すると以下のようになります。

# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sdc1[3] sdb1[1] sda1[0]
      123369472 blocks super 1.2 level 5, 256k chunk, algorithm 2 [3/3] [UUU]
                                                                         ~~~ ここがUUUなら正常ということ
unused devices: <none>

6. RAID構成情報を記録しておく

 "/etc/mdadm/mdadm.conf"ファイルにRAIDアレイの設定情報を記録しておきます。これを忘れると、再起動でRAIDアレイが構成されなくなってしまうので注意です。

# mdadm --detail --scan >> /etc/mdadm/mdadm.conf
# cat /etc/mdadm/mdadm.conf
# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#

# by default (built-in), scan all partitions (/proc/partitions) and all
# containers for MD superblocks. alternatively, specify devices to scan, using
# wildcards if desired.
#DEVICE partitions containers

# auto-create devices with Debian standard permissions
CREATE owner=root group=disk mode=0660 auto=yes

# automatically tag new arrays as belonging to the local system
HOMEHOST 

# instruct the monitoring daemon where to send mail alerts
MAILADDR root

# definitions of existing MD arrays

# This configuration was auto-generated on Sat, 30 Jul 2016 11:12:07 +0900 by mkconf
ARRAY /dev/md0 metadata=1.2 name=RaspberryPi3:0 UUID=c26559b7:abb329b4:1960d0d5:7b9c8287
[続く]

(*2):RAID構築には結構時間がかかりますが、これはマシンの他の作業やサービスに影響を与えないよう、意図的に速度を落としているからだそうです。マシンで他の作業をしていなく、CPUに余裕があるのであれば、速度制限を上げることができます。

現在の速度制限を確認する。

# cat /proc/sys/dev/raid/speed_limit_min
1000
# cat /proc/sys/dev/raid/speed_limit_max
200000

上記のファイルに書き込むことで速度制限を上げます。

# echo 400000 >/proc/sys/dev/raid/speed_limit_min
# echo 400000 >/proc/sys/dev/raid/speed_limit_max


< 過去の記事 [ 8月の 全てのカテゴリ リスト ] 新しい記事 >

2016 calendar
8月
123456
78910111213
14151617181920
21222324252627
28293031


掲示板
最新:08/15 17:19


GsBlog was developed by GUSTAV, Copyright(C) 2003, Web Application Factory All Rights Reserved.