2、总结RAID的各个级别及其组合方式和性能的不同。
RAID类型:
RAID 0、RAID 1、RAID 4、RAID 5、RAID 6、RAID 10、RAID 01、RAID 50
RAID常用性能介绍:
RAID 0:需要至少2块硬盘,读写性能提升,可用空间为n容量之和,无容错能力。
RAID 1:至少需要2块硬盘,硬盘数为2的倍数。可用空间为n/2容量的空间,读性能提升,写性能降低,有冗余能力。
RAID 5:至少需要3块硬盘,硬盘数为3块以上。可用空间为(n-1)读写性能提升,有容错能力。最多允许坏1块盘。
RAID 6:至少需要4块硬盘,硬盘数为4块以上。可以空间为(n-2)的空间容量,读写性能提升,有容错能力。最多允许坏2块盘。
RAID 10:至少4块盘,硬盘数为4的偶数。可用空间为n/2,读写性能提升,有容错能力,每组镜像最多只能坏一块。先组RAID 1再组RAID 0。
RAID 01:至少4块盘,硬盘数为4以上的偶数。可用空间为n/2,读写性能提升,有容错能力。不同镜像不能坏存储相同内容的硬盘。先组RAID 0再组RAID 1.
3、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项
#创建2G分区
[root@centos8 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 100G 0 part /
├─sda3 8:3 0 50G 0 part /data
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 2G 0 part [SWAP]
sr0 11:0 1 7.7G 0 rom
[root@centos8 ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
All primary partitions are in use.
Adding logical partition 6
First sector (320870400-419430399, default 320870400):
Last sector, +sectors or +size{K,M,G,T,P} (320870400-419430399, default 419430399): +2G
Created a new partition 6 of type 'Linux' and of size 2 GiB.
Command (m for help): p
Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xcc0623e1
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 2099199 2097152 1G 83 Linux
/dev/sda2 2099200 211814399 209715200 100G 83 Linux
/dev/sda3 211814400 316671999 104857600 50G 83 Linux
/dev/sda4 316672000 419430399 102758400 49G 5 Extended
/dev/sda5 316674048 320868351 4194304 2G 82 Linux swap / Solaris
/dev/sda6 320870400 325064703 4194304 2G 83 Linux
Command (m for help): w
The partition table has been altered.
Syncing disks.
[root@centos8 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 100G 0 part /
├─sda3 8:3 0 50G 0 part /data
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 2G 0 part [SWAP]
└─sda6 8:6 0 2G 0 part
sr0 11:0 1 7.7G 0 rom
#创建2G文件系统
[root@centos8 ~]# mkfs.ext4 -b 2048 -L 'TEST' -m 1 /dev/sda6
mke2fs 1.45.6 (20-Mar-2020)
/dev/sda6 contains a ext4 file system labelled 'TEST'
created on Sun Jan 10 22:28:38 2021
Proceed anyway? (y,N) y
Creating filesystem with 1048576 2k blocks and 131072 inodes
Filesystem UUID: b200988b-fe8c-4f03-969a-a81bf64f7101
Superblock backups stored on blocks:
16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
[root@centos8 ~]# lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
├─sda1 ext4 7ee7650b-9e95-4d2f-b4de-9f691e67f1dc /boot
├─sda2 xfs bfefda69-47bf-4448-8686-af65c2b22aca /
├─sda3 xfs 41fa2dd3-2e4b-4083-9585-508125f8d1b1 /data
├─sda4
├─sda5 swap 82e4e1d3-b679-428f-bceb-f334b48788c4 [SWAP]
└─sda6 ext4 TEST b200988b-fe8c-4f03-969a-a81bf64f7101
sr0 iso9660 CentOS-8-2-2004-x86_64-dvd 2020-06-08-22-08-25-00
#修改挂载配置文件
[root@centos8 http24]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Sep 1 20:25:59 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=bfefda69-47bf-4448-8686-af65c2b22aca / xfs defaults 0 0
UUID=7ee7650b-9e95-4d2f-b4de-9f691e67f1dc /boot ext4 defaults 1 2
UUID=41fa2dd3-2e4b-4083-9585-508125f8d1b1 /data xfs defaults 0 0
UUID=82e4e1d3-b679-428f-bceb-f334b48788c4 swap swap defaults 0 0
UUID=b200988b-fe8c-4f03-969a-a81bf64f7101 /mnt ext4 defaults 0 0
#挂载sda6
[root@centos8 ~]# mount /dev/sda6 /mnt
[root@centos8 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 100G 0 part /
├─sda3 8:3 0 50G 0 part /data
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 2G 0 part [SWAP]
└─sda6 8:6 0 2G 0 part /mnt
sr0 11:0 1 7.7G 0 rom
[root@centos8 http24]# dumpe2fs -h /dev/sda6
dumpe2fs 1.45.6 (20-Mar-2020)
Filesystem volume name: TEST
Last mounted on: <not available>
Filesystem UUID: b200988b-fe8c-4f03-969a-a81bf64f7101
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 131072
Block count: 1048576
Reserved block count: 10485
Free blocks: 1011035
Free inodes: 131061
First block: 0
Block size: 2048
Fragment size: 2048
Group descriptor size: 64
Reserved GDT blocks: 512
Blocks per group: 16384
Fragments per group: 16384
Inodes per group: 2048
Inode blocks per group: 256
Flex block group size: 16
Filesystem created: Sun Jan 10 22:46:51 2021
Last mount time: n/a
Last write time: Sun Jan 10 22:46:52 2021
Mount count: 0
Maximum mount count: -1
Last checked: Sun Jan 10 22:46:51 2021
Check interval: 0 (<none>)
Lifetime writes: 1058 kB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 32
Desired extra isize: 32
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: b4284201-c662-49e3-9417-7a32fd2de10b
Journal backup: inode blocks
Checksum type: crc32c
Checksum: 0xe25211a7
Journal features: (none)
Journal size: 32M
Journal length: 16384
Journal sequence: 0x00000001
Journal start: 0
4、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录
#创建两个分区,5G和15G
[root@centos8 ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
All primary partitions are in use.
Adding logical partition 6
First sector (320870400-419430399, default 320870400):
Last sector, +sectors or +size{K,M,G,T,P} (320870400-419430399, default 419430399): +5G
Created a new partition 6 of type 'Linux' and of size 5 GiB.
Command (m for help): n
All primary partitions are in use.
Adding logical partition 7
First sector (331358208-419430399, default 331358208):
Last sector, +sectors or +size{K,M,G,T,P} (331358208-419430399, default 419430399): +15G
Created a new partition 7 of type 'Linux' and of size 15 GiB.
Command (m for help): t
Partition number (1-7, default 7): 6
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'.
Command (m for help): t
Partition number (1-7, default 7): 7
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'.
Command (m for help): p
Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xcc0623e1
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 2099199 2097152 1G 83 Linux
/dev/sda2 2099200 211814399 209715200 100G 83 Linux
/dev/sda3 211814400 316671999 104857600 50G 83 Linux
/dev/sda4 316672000 419430399 102758400 49G 5 Extended
/dev/sda5 316674048 320868351 4194304 2G 82 Linux swap / Solaris
/dev/sda6 320870400 331356159 10485760 5G 8e Linux LVM
/dev/sda7 331358208 362815487 31457280 15G 8e Linux LVM
Command (m for help): w
The partition table has been altered.
Syncing disks.
#创建物理卷
[root@centos8 ~]# pvcreate /dev/sda6 /dev/sda7
Physical volume "/dev/sda6" successfully created.
Physical volume "/dev/sda7" successfully created.
[root@centos8 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda6 lvm2 --- 5.00g 5.00g
/dev/sda7 lvm2 --- 15.00g 15.00g
#创建卷组
[root@centos8 ~]# vgcreate testvg -s 16 /dev/sda6 /dev/sda7
Volume group "testvg" successfully created
[root@centos8 ~]# vgdisplay
--- Volume group ---
VG Name testvg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size <19.97 GiB
PE Size 16.00 MiB
Total PE 1278
Alloc PE / Size 0 / 0
Free PE / Size 1278 / <19.97 GiB
VG UUID NYKl9P-ExM5-Sd01-PaBK-uyjQ-erBH-h32Rff
#创建逻辑卷
[root@centos8 ~]# lvcreate -L +5G -n testlv testvg
Logical volume "testlv" created.
[root@centos8 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
testlv testvg -wi-a----- 5.00g
#创建文件系统并挂载至/users目录下
[root@centos8 ~]# mkfs.ext4 /dev/testvg/testlv
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 1310720 4k blocks and 327680 inodes
Filesystem UUID: 23e40118-c7a0-4022-a064-c5f61773db34
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
[root@centos8 ~]# lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
├─sda1 ext4 7ee7650b-9e95-4d2f-b4de-9f691e67f1dc /boot
├─sda2 xfs bfefda69-47bf-4448-8686-af65c2b22aca /
├─sda3 xfs 41fa2dd3-2e4b-4083-9585-508125f8d1b1 /data
├─sda4
├─sda5 swap 82e4e1d3-b679-428f-bceb-f334b48788c4 [SWAP]
├─sda6 LVM2_member n9XqlZ-jXQl-N68R-tXeH-PvMa-2krK-hrddoT
└─sda7 LVM2_member 1rhzmz-zedq-CuL4-cq8w-EIhl-eyQN-0FxbaF
└─testvg-testlv ext4 23e40118-c7a0-4022-a064-c5f61773db34
sr0 iso9660 CentOS-8-2-2004-x86_64-dvd 2020-06-08-22-08-25-00
[root@centos8 ~]# mkdir /users
[root@centos8 ~]# mount /dev/mapper/testvg-testlv /users
[root@centos8 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 100G 0 part /
├─sda3 8:3 0 50G 0 part /data
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 2G 0 part [SWAP]
├─sda6 8:6 0 5G 0 part
└─sda7 8:7 0 15G 0 part
└─testvg-testlv 253:0 0 5G 0 lvm /users
sr0 11:0 1 7.7G 0 rom
#永久保存挂载
[root@centos8 users]# vim /etc/fstab
# Created by anaconda on Tue Sep 1 20:25:59 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=bfefda69-47bf-4448-8686-af65c2b22aca / xfs defaults 0 0
UUID=7ee7650b-9e95-4d2f-b4de-9f691e67f1dc /boot ext4 defaults 1 2
UUID=41fa2dd3-2e4b-4083-9585-508125f8d1b1 /data xfs defaults 0 0
UUID=82e4e1d3-b679-428f-bceb-f334b48788c4 swap swap defaults 0 0
UUID=23e40118-c7a0-4022-a064-c5f61773db34 /users ext4 defaults 0 0