CentOS6.8はRAID-5を作成します

1 3つの新しいパーティションを作成します##

[ root@centos68 ~]# fdisk /dev/sdb
Command(m for help): p

Disk /dev/sdb:53.7 GB,53687091200 bytes
255 heads,63 sectors/track,6527 cylinders
Units = cylinders of16065*512=8225280 bytes
Sector size(logical/physical):512 bytes /512 bytes
I/O size(minimum/optimal):512 bytes /512 bytes
Disk identifier:0xb5c926a7

 Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               13917314632715  Extended
/dev/sdb5               1654525319283  Linux
/dev/sdb6             65513085253223+83  Linux
/dev/sdb7            130919625253223+83  Linux

2 パーティションタイプをfd(Linux raid autodetect)に変更します##

Command(m for help): t
Partition number(1-7):5
Hex code(type L to list codes): fd
Changed system type of partition 5 to fd(Linux raid autodetect)Command(m for help): t
Partition number(1-7):6
Hex code(type L to list codes): fd
Changed system type of partition 6 to fd(Linux raid autodetect)Command(m for help): t
Partition number(1-7):7
Hex code(type L to list codes): fd
Changed system type of partition 7 to fd(Linux raid autodetect)Command(m for help): p

Disk /dev/sdb:53.7 GB,53687091200 bytes
255 heads,63 sectors/track,6527 cylinders
Units = cylinders of16065*512=8225280 bytes
Sector size(logical/physical):512 bytes /512 bytes
I/O size(minimum/optimal):512 bytes /512 bytes
Disk identifier:0xb5c926a7

 Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               13917314632715  Extended
/dev/sdb5               16545253192   fd  Linux raid autodetect
/dev/sdb6             65513085253223+  fd  Linux raid autodetect
/dev/sdb7            130919625253223+  fd  Linux raid autodetect

保存して終了

Command(m for help): w
The partition table has been altered!

ディスクパーティションテーブルの再読み取りを強制します(数回実行)

[ root@centos68 ~]# partx -a /dev/sdb

3 新しい無料パーティション##

[ root@centos68 ~]# fdisk /dev/sdb

Command(m for help): n

Command action
 l   logical(5 or over)
 p   primary partition(1-4)
l
First cylinder(1963-3917,default1963):
Using default value 1963
Last cylinder,+cylinders or +size{K,M,G}(1963-3917,default3917):+5G

Command(m for help): t
Partition number(1-8):8
Hex code(type L to list codes): fd
Changed system type of partition 8 to fd(Linux raid autodetect)Command(m for help): p

Disk /dev/sdb:53.7 GB,53687091200 bytes
255 heads,63 sectors/track,6527 cylinders
Units = cylinders of16065*512=8225280 bytes
Sector size(logical/physical):512 bytes /512 bytes
I/O size(minimum/optimal):512 bytes /512 bytes
Disk identifier:0xb5c926a7

 Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               13917314632715  Extended
/dev/sdb5               16545253192   fd  Linux raid autodetect
/dev/sdb6             65513085253223+  fd  Linux raid autodetect
/dev/sdb7            130919625253223+  fd  Linux raid autodetect
/dev/sdb8            196326165253223+  fd  Linux raid autodetect

Command(m for help): w
The partition table has been altered!

# パーティションテーブルを強制的に再読み込みします
[ root@centos68 ~]# partx -a /dev/sdb

4 RAID-5を作成する##

[ root@centos68 ~]# mdadm -C /dev/md0 -a yes -n 3-x 1-l 5/dev/sdb{5,6,7,8}
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

データ同期プロセスを表示する

[ root@centos68 ~]# watch -n1 'cat /proc/mdstat'

すべてのmdタイプのデバイスのステータスを表示する

[ root@centos68 ~]# cat /proc/mdstat
Personalities :[raid6][raid5][raid4]
md0 : active raid5 sdb7[4] sdb8[3](S) sdb6[1] sdb5[0]10498048 blocks super1.2 level 5, 512k chunk, algorithm 2[3/3][UUU]

unused devices:<none>

RAIDの詳細を表示

[ root@centos68 ~]# mdadm -D /dev/md0
/dev/md0:
  Version :1.2
 Creation Time : Thu Jun 2503:49:102020
  Raid Level : raid5
  Array Size :10498048(10.01 GiB 10.75 GB)
 Used Dev Size :5249024(5.01 GiB 5.38 GB)
 Raid Devices :3
 Total Devices :4
 Persistence : Superblock is persistent

 Update Time : Thu Jun 2503:53:072020
   State : clean
 Active Devices :3
Working Devices :4
 Failed Devices :0
 Spare Devices :1

   Layout : left-symmetric
  Chunk Size : 512K

   Name : centos68:0(local to host centos68)
   UUID : be5cb284:275497f7:be5982ec:ce03ed15
   Events :18

 Number   Major   Minor   RaidDevice State
  08210  active sync   /dev/sdb5
  18221  active sync   /dev/sdb6
  48232  active sync   /dev/sdb7

  3824-  spare   /dev/sdb8

5 フォーマットパーティション##

[ root@centos68 ~]# mke2fs -t ext4 /dev/md0

見る

[ root@centos68 ~]# df -lh
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos68-lv_root
      50 G  861M   46G   2%/
tmpfs                 931M     0  931M   0%/dev/shm
/dev/sda1             477M   39M  413M   9%/boot
/dev/mapper/vg_centos68-lv_home
      45 G   52M   43G   1%/home
/dev/md0              9.8G   23M  9.3G   1%/data

起動時の自動マウントを実現

[ root@centos68 ~]# blkid /dev/md0
/dev/md0: UUID="e2303c17-62a6-4938-aa7a-d5b9c52ab4ea" TYPE="ext4"
# 取り付けまたはLABELボリュームラベルの取り付けにはUUIDを使用することをお勧めします
[ root@centos68 ~]# tail -1/etc/fstab
UUID=e2303c17-62a6-4938-aa7a-d5b9c52ab4ea       /data   defaults,acl    00

6 不良ディスクをシミュレートします##

[ root@centos68 ~]# mdadm /dev/md0 -f /dev/sdb5
mdadm:set/dev/sdb5 faulty in/dev/md0

スペアディスクの同期プロセスを表示する

[ root@centos68 ~]# cat /proc/mdstat #または時計を使用する-n1 'cat /proc/mdstat'回復プロセスを動的に観察する
Personalities :[raid6][raid5][raid4]
md0 : active raid5 sdb7[4] sdb8[3] sdb6[1] sdb5[0](F)10498048 blocks super1.2 level 5, 512k chunk, algorithm 2[3/2][_UU][=>...................]  recovery =6.8%(359808/5249024) finish=0.6min speed=119936K/sec

unused devices:<none>

RAIDの詳細をもう一度表示する

== スペアディスクsdb8が不良ディスクsdb5 ==に置き換わりました

[ root@centos68 ~]# mdadm -D /dev/md0
/dev/md0:
  Version :1.2
 Creation Time : Thu Jun 2503:49:102020
  Raid Level : raid5
  Array Size :10498048(10.01 GiB 10.75 GB)
 Used Dev Size :5249024(5.01 GiB 5.38 GB)
 Raid Devices :3
 Total Devices :4
 Persistence : Superblock is persistent

 Update Time : Thu Jun 2504:07:212020
   State : clean
 Active Devices :3
Working Devices :3
 Failed Devices :1
 Spare Devices :0

   Layout : left-symmetric
  Chunk Size : 512K

   Name : centos68:0(local to host centos68)
   UUID : be5cb284:275497f7:be5982ec:ce03ed15
   Events :37

 Number   Major   Minor   RaidDevice State
  38240  active sync   /dev/sdb8
  18221  active sync   /dev/sdb6
  48232  active sync   /dev/sdb7

  0821-  faulty   /dev/sdb5

7 不良ディスクをシミュレートし、データが正常にアクセスされているかどうかを観察します##

テストデータをRAID-5マウントポイント/ dataにコピーします

[ root@centos68 ~]# cp /etc/passwd /data/[root@centos68 ~]# ll /data/passwd
- rw-r--r--.1 root root 887 Jun 2504:13/data/passwd
[ root@centos68 ~]# cat /etc/passwd

不良ディスク/ dev / sdb8をシミュレートし、状態の状態を観察します

[ root@centos68 ~]# mdadm /dev/md0 -f /dev/sdb8
mdadm:set/dev/sdb8 faulty in/dev/md0
[ root@centos68 ~]# mdadm -D /dev/md0
/dev/md0:
  Version :1.2
 Creation Time : Thu Jun 2503:49:102020
  Raid Level : raid5
  Array Size :10498048(10.01 GiB 10.75 GB)
 Used Dev Size :5249024(5.01 GiB 5.38 GB)
 Raid Devices :3
 Total Devices :4
 Persistence : Superblock is persistent

 Update Time : Thu Jun 2504:15:232020
   State : clean, degraded #劣化した動作モード
 Active Devices :2
Working Devices :2
 Failed Devices :2
 Spare Devices :0

   Layout : left-symmetric #デフォルトのレイアウトは対称のままです
  Chunk Size : 512K

   Name : centos68:0(local to host centos68)
   UUID : be5cb284:275497f7:be5982ec:ce03ed15
   Events :39

 Number   Major   Minor   RaidDevice State
  0000  removed
  18221  active sync   /dev/sdb6
  48232  active sync   /dev/sdb7

  0821-  faulty   /dev/sdb5
  3824-  faulty   /dev/sdb8

データが正常にアクセスされているかどうかをテストします

[ root@centos68 ~]# cd /data
[ root@centos68 data]# cat passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin

8 不良ディスクを削除します##

[ root@centos68 data]# mdadm /dev/md0 -r /dev/sdb5
mdadm: hot removed /dev/sdb5 from/dev/md0
[ root@centos68 data]# mdadm /dev/md0 -r /dev/sdb8
mdadm: hot removed /dev/sdb8 from/dev/md0
[ root@centos68 data]# mdadm -D /dev/md0
/dev/md0:
  Version :1.2
 Creation Time : Thu Jun 2503:49:102020
  Raid Level : raid5
  Array Size :10498048(10.01 GiB 10.75 GB)
 Used Dev Size :5249024(5.01 GiB 5.38 GB)
 Raid Devices :3
 Total Devices :2
 Persistence : Superblock is persistent

 Update Time : Thu Jun 2504:19:052020
   State : clean, degraded
 Active Devices :2
Working Devices :2
 Failed Devices :0
 Spare Devices :0

   Layout : left-symmetric
  Chunk Size : 512K

   Name : centos68:0(local to host centos68)
   UUID : be5cb284:275497f7:be5982ec:ce03ed15
   Events :45

 Number   Major   Minor   RaidDevice State
  0000  removed
  18221  active sync   /dev/sdb6
  48232  active sync   /dev/sdb7

9 ディスクを追加##

[ root@centos68 data]# mdadm /dev/md0 -a /dev/sdb5
mdadm: added /dev/sdb5

データ同期プロセスを表示する

[ root@centos68 data]# watch -n1 'cat /proc/mdstat'

Every 1.0s: cat /proc/mdstat                                   Thu Jun 2504:23:042020

Personalities :[raid6][raid5][raid4]
md0 : active raid5 sdb5[3] sdb7[4] sdb6[1]10498048 blocks super1.2 level 5, 512k chunk, algorithm 2[3/2][_UU][================>....]  recovery =82.0%(4309708/5249024) finish=0.1min speed=1
00386 K/sec

unused devices:<none>

参照ドキュメント:[https://cloud.tencent.com/developer/article/1562726](https://cloud.tencent.com/developer/article/1562726?from=10680)

Recommended Posts

CentOS6.8はRAID-5を作成します
CentOS 8(2)
CentOS 8(1)
Centos 7 RAID5の詳細な説明と構成
centos7 python3.7 + vi
httpdサービスでCentOSDockerイメージを作成する
CentOS + Jenkins
1.5Centos7をインストールする
2019-07-09CentOS7のインストール
centos7_1708のインストール
Centos 7.5 python3.6
CentOS 7はKVMをインストールし、仮想マシンを作成します