1、创建10G的RAID1,要求CHUNK为128K,文件系统为ext4,有一个空闲盘,开机可自动挂载至/backup目录
2、创建一个可用空间为10G的RAID10设备,要求CHUNK为256K,文件系统为ext4,开机可自动挂载至/mydata目录
1、创建10G的RAID1,要求CHUNK为128K,文件系统为ext4,有一个空闲盘,开机可自动挂载至/backup目录
分区、创建、调整、查看、格式化、挂载、卸载、空间查看 1、RAID1的空闲空间为1 * min(S1,S2),两个磁盘和一个空闲盘 2、分区规划:3个分区,每个最小为10G。 3、使用用户空间中程序mdadm,调用md模块完成创建raid 4、格式化、挂载、开机实现自动挂载
1、管理磁盘 [root@localhost ~]# fdisk /dev/sda Command (m for help): p 2610 cylinders ## 查看总柱面 End 1962 ## 查看划分分区的结束柱面 .... t,3,fd t,4,fd w [root@localhost ~]# partx -a /dev/sda [root@localhost ~]# partx -a /dev/sda 2、创建raid1 [root@localhost ~]# mdadm -C /dev/md0 -a yes -l 1 -n 2 -x 1 -c 128K /dev/sdb{1,2,3} 3、格式化 [root@localhost ~]# mke2fs -t ext4 -b 4096 -m 3 -i 4096 -L ‘MY222‘ /dev/md0 操作系统:Linux 块大小=4096 (log=2) 78616 blocks (3.00%) reserved for the super user Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 4、开机挂载至/backup,编辑fstab文件 [root@localhost ~]# vim + /etc/fstab LABEL=‘MY222‘ /backup ext4 defaults 2 3 5、创建/backup目录 [root@localhost ~]# mkdir /backup 6、测试挂载 [root@localhost ~]# mount -a [root@localhost ~]# ls /backup lost+found 7、查看空间信息 [root@localhost ~]# df -hP Filesystem Size Used Avail Use% Mounted on /dev/md0 9.3G 23M 9.0G 1% /backup
2、创建一个可用空间为10G的RAID10设备,要求CHUNK为256K,文件系统为ext4,开机可自动挂载至/mydata目录
分区、创建、调整、查看、格式化、挂载、卸载、空间查看 1、RAID10的空闲空间为N/2 * min(S1,S2,S3,S4),4个磁盘 2、分区规划:2个分区,每个最小为5G。 3、使用用户空间中程序mdadm,调用md模块完成创建raid 4、格式化、挂载、开机实现自动挂载
1、管理磁盘 [root@localhost ~]# fdisk /dev/sda t 5,6,7,8 fd w [root@localhost ~]# partx -a /dev/sda [root@localhost ~]# partx -a /dev/sda 2、创建raid10 1)、查看已经存在的RAID设备的名字,为了避免重名 [root@localhost ~]# cat /proc/mdstat md0 : 2)、创建md10 [root@localhost ~]# mdadm -C /dev/md1 -a yes -l 10 -n 4 -c 256K /dev/sda{5,6,7,8} [root@localhost ~]# mdadm -D /dev/md1 Raid Level : raid10 Update Time : Sat Aug 12 10:48:15 2017 State : clean, resyncing Active Devices : 4 Working Devices : 4 Failed Devices : 0 Spare Devices : 0 Layout : near=2 Chunk Size : 256K Resync Status : 41% complete Name : localhost.localdomain:1 (local to host localhost.localdomain) UUID : ea7d9cd0:53b9d9a3:fd5a08f9:1f65eac3 Events : 6 Number Major Minor RaidDevice State 0 8 5 0 active sync set-A /dev/sda5 1 8 6 1 active sync set-B /dev/sda6 2 8 7 2 active sync set-A /dev/sda7 3 8 8 3 active sync set-B /dev/sda8 [root@localhost ~]# cat /proc/mdstat Personalities : [raid1] [raid10] md1 : active raid10 sda8[3] sda7[2] sda6[1] sda5[0] 10496512 blocks super 1.2 256K chunks 2 near-copies [4/4] [UUUU] [==================>..] resync = 91.7% (9631424/10496512) ============== 等待进度完成 ==================== 3、格式化 [root@localhost ~]# mkfs.ext4 /dev/md1 4、开机挂载至/mydata,编辑fstab文件 1)、查看UUID [root@localhost ~]# blkid /dev/md1 /dev/md1: UUID="ebbc94c3-66b9-433b-967b-c84e44ef35b0" TYPE="ext4" 2)、以UUID挂载 [root@localhost ~]# vim + /etc/fstab UUID="ebbc94c3-66b9-433b-967b-c84e44ef35b0" /mydata ext4 defaults 1 2 5、创建/mydata目录 [root@localhost ~]# install -d /mydata 6、测试挂载 [root@localhost ~]# mount -a -v mount: UUID=5009dc18-28f5-4b32-8c7c-0ea1328ea224 already mounted on /boot mount: /dev/mapper/myvg-lv_home already mounted on /home mount: /dev/mapper/myvg-lv_usr already mounted on /usr mount: /dev/mapper/myvg-lv_var already mounted on /var mount: tmpfs already mounted on /dev/shm mount: devpts already mounted on /dev/pts mount: sysfs already mounted on /sys mount: proc already mounted on /proc mount: LABEL=‘MY222‘ already mounted on /backup /dev/md1 on /mydata type ext4 (rw) 7、查看空间信息 [root@localhost ~]# df -lhP Filesystem Size Used Avail Use% Mounted on /dev/mapper/myvg-lv_root 48G 520M 45G 2% / tmpfs 122M 0 122M 0% /dev/shm /dev/sda1 477M 33M 419M 8% /boot /dev/mapper/myvg-lv_home 4.7G 9.9M 4.5G 1% /home /dev/mapper/myvg-lv_usr 15G 710M 13G 6% /usr /dev/mapper/myvg-lv_var 9.5G 88M 9.0G 1% /var /dev/md0 9.3G 23M 9.0G 1% /backup /dev/md1 9.8G 23M 9.3G 1% /mydata [root@localhost ~]# -l local 只显示本地设备 -h human-readable -P print for POSIX FORMAT
本文出自 “Reading” 博客,请务必保留此出处http://sonlich.blog.51cto.com/12825953/1955692
原文地址:http://sonlich.blog.51cto.com/12825953/1955692