软件RAID
-
[root@zyl ~]# grep mpt /sys/class/scsi_host/host?/proc_name /sys/class/scsi_host/host2/proc_name:mptspi [root@zyl ~]# echo '- - -' > /sys/class/scsi_host/host2/scan [root@zyl ~]# ls /dev/sd* /dev/sda /dev/sda2 /dev/sdb1 /dev/sdb3 /dev/sdd /dev/sdf /dev/sda1 /dev/sdb /dev/sdb2 /dev/sdc /dev/sde /dev/sdg
-
[root@zyl ~]# lsblk /dev/sd* NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 19G 0 part ├─centos-root 253:0 0 17G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sda1 8:1 0 1G 0 part /boot sda2 8:2 0 19G 0 part ├─centos-root 253:0 0 17G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 20G 0 disk ├─sdb1 8:17 0 500M 0 part ├─sdb2 8:18 0 1G 0 part [SWAP] └─sdb3 8:19 0 1G 0 part sdb1 8:17 0 500M 0 part sdb2 8:18 0 1G 0 part [SWAP] sdb3 8:19 0 1G 0 part sdc 8:32 0 1G 0 disk └─sdc1 8:33 0 1023M 0 part sdc1 8:33 0 1023M 0 part sdd 8:48 0 1G 0 disk └─sdd1 8:49 0 1023M 0 part sdd1 8:49 0 1023M 0 part sde 8:64 0 1G 0 disk └─sde1 8:65 0 1023M 0 part sde1 8:65 0 1023M 0 part sdf 8:80 0 1G 0 disk └─sdf1 8:81 0 1023M 0 part sdf1 8:81 0 1023M 0 part sdg 8:96 0 1G 0 disk └─sdg1 8:97 0 1023M 0 part sdg1 8:97 0 1023M 0 part
-
[root@zyl ~]# mdadm -C /dev/md1 -a yes -l 5 -n 5 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1 /dev/sdg1 mdadm: Fail create md1 when using /sys/module/md_mod/parameters/new_array mdadm: Defaulting to version 1.2 metadata mdadm: array /dev/md1 started. [root@zyl ~]# cat /proc/mdstat Personalities : [raid6] [raid5] [raid4] md1 : active raid5 sdg1[5] sdf1[3] sde1[2] sdd1[1] sdc1[0] 4182016 blocks super 1.2 level 5, 512k chunk, algorithm 2 [5/5] [UUUUU] unused devices: <none>
-
[root@zyl ~]# mkfs.ext4 /dev/md1 #格式化阵列 mke2fs 1.42.9 (28-Dec-2013) 文件系统标签= OS type: Linux 块大小=4096 (log=2) 分块大小=4096 (log=2) Stride=128 blocks, Stripe width=512 blocks 261632 inodes, 1045504 blocks 52275 blocks (5.00%) reserved for the super user 第一个数据块=0 Maximum filesystem blocks=1071644672 32 block groups 32768 blocks per group, 32768 fragments per group 8176 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736 Allocating group tables: 完成 正在写入inode表: 完成 Creating journal (16384 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 [root@zyl ~]# mount /dev/md1 /project/ #挂载阵列 [root@zyl ~]# df -T #查看挂载信息 文件系统 类型 1K-块 已用 可用 已用% 挂载点 /dev/mapper/centos-root xfs 17811456 8155824 9655632 46% / devtmpfs devtmpfs 919444 0 919444 0% /dev tmpfs tmpfs 931612 0 931612 0% /dev/shm tmpfs tmpfs 931612 9780 921832 2% /run tmpfs tmpfs 931612 0 931612 0% /sys/fs/cgroup /dev/sda1 xfs 1038336 148728 889608 15% /boot tmpfs tmpfs 186324 0 186324 0% /run/user/0 /dev/md1 ext4 4050752 16344 3808924 1% /project
-
[root@zyl ~]# cp -R /etc/ /project/
-
[root@zyl project]# mdadm /dev/md1 -f /dev/sdc1 mdadm: set /dev/sdc1 faulty in /dev/md1
-
[root@zyl project]# ls etc file lost+found
-
[root@zyl project]# mdadm /dev/md1 -r /dev/sdc1 mdadm: hot removed /dev/sdc1 from /dev/md1
-
[root@zyl project]# mdadm /dev/md1 -a /dev/sdh1
-
[root@zyl project]# mdadm -D /dev/md1 /dev/md1: Version : 1.2 Creation Time : Tue Oct 15 17:44:23 2019 Raid Level : raid5 Array Size : 4182016 (3.99 GiB 4.28 GB) Used Dev Size : 1045504 (1021.00 MiB 1070.60 MB) Raid Devices : 5 Total Devices : 5 Persistence : Superblock is persistent Update Time : Tue Oct 15 17:59:57 2019 State : clean Active Devices : 5 Working Devices : 5 Failed Devices : 0 Spare Devices : 0 Layout : left-symmetric Chunk Size : 512K Consistency Policy : resync Name : zyl:1 (local to host zyl) UUID : 1e6a698b:3ff4ac5f:0d11efa2:15c2f4f7 Events : 44 Number Major Minor RaidDevice State 6 8 33 0 active sync /dev/sdc1 1 8 49 1 active sync /dev/sdd1 2 8 65 2 active sync /dev/sde1 3 8 81 3 active sync /dev/sdf1 5 8 97 4 active sync /dev/sdg1 [root@zyl project]# df -T
-
[root@zyl project]# blkid /dev/md1 /dev/md1: UUID="9e019ec0-214a-49ee-9b74-45a7dca816ea" TYPE="ext4" [root@zyl project]# vim /etc/mdadm.conf #绑定识md1 DEVICE /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1 /dev/sdg1 [root@zyl project]# mdadm --examine --scan --config=mdadm.conf #绑定识别md1 ARRAY /dev/md/1 metadata=1.2 UUID=1e6a698b:3ff4ac5f:0d11efa2:15c2f4f7 name=zyl:1 [root@zyl project]# mdadm --examine --scan --config=mdadm.conf >> /etc/mdadm.conf 复制UUID,进入开机挂载文件/etc/fstab vim /etc/fstab 键入追加:UUID="9e019ec0-214a-49ee-9b74-45a7dca816ea" /project ext4 defaults 0 0 重启之后查看挂载情况 [root@zyl ~]# df -T 文件系统 类型 1K-块 已用 可用 已用% 挂载点 /dev/mapper/centos-root xfs 17811456 8158364 9653092 46% / devtmpfs devtmpfs 919444 0 919444 0% /dev tmpfs tmpfs 931612 0 931612 0% /dev/shm tmpfs tmpfs 931612 9836 921776 2% /run tmpfs tmpfs 931612 0 931612 0% /sys/fs/cgroup /dev/sda1 xfs 1038336 148728 889608 15% /boot /dev/md1 ext4 4050752 153476 3671792 5% /project tmpfs tmpfs 186324 0 186324 0% /run/user/0