上机作业六 磁盘管理综合测试2019 7 31
2、为三块硬盘分区
[root@localhost ~]# fdisk /dev/sdf
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0xcf3610b6 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-41943039,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-41943039,默认为 41943039):
将使用默认值 41943039
分区 1 已设置为 Linux 类型,大小设为 20 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@localhost ~]# fdisk /dev/sde
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0xfae43c11 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-41943039,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-41943039,默认为 41943039):
将使用默认值 41943039
分区 1 已设置为 Linux 类型,大小设为 20 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@localhost ~]# fdisk /dev/sdg
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0x0e0afac9 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-41943039,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-41943039,默认为 41943039):
将使用默认值 41943039
分区 1 已设置为 Linux 类型,大小设为 20 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
3、创建RAID 5
[root@localhost ~]# mdadm -C /dev/md55 -l 5 -n 3 /dev/sd[efg]
mdadm: /dev/sde appears to be part of a raid array:
level=raid0 devices=0 ctime=Thu Jan 1 08:00:00 1970
mdadm: partition table exists on /dev/sde but will be lost or
meaningless after creating array
mdadm: /dev/sdf appears to be part of a raid array:
level=raid0 devices=0 ctime=Thu Jan 1 08:00:00 1970
mdadm: partition table exists on /dev/sdf but will be lost or
meaningless after creating array
mdadm: /dev/sdg appears to be part of a raid array:
level=raid0 devices=0 ctime=Thu Jan 1 08:00:00 1970
mdadm: partition table exists on /dev/sdg but will be lost or
meaningless after creating array
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md55 started.
[root@localhost ~]# mdadm -D /dev/md55
/dev/md55:
Version : 1.2
Creation Time : Sat Aug 3 13:45:55 2019
Raid Level : raid5
Array Size : 41910272 (39.97 GiB 42.92 GB)
Used Dev Size : 20955136 (19.98 GiB 21.46 GB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Sat Aug 3 13:46:02 2019
State : clean, degraded, recovering
Active Devices : 2
Working Devices : 3
Failed Devices : 0
Spare Devices : 1
Layout : left-symmetric
Chunk Size : 512K
Rebuild Status : 10% complete
Name : localhost.localdomain:55 (local to host localhost.localdomain)
UUID : 862f8db5:c4a3594c:0a7b4ffa:a5fadc0a
Events : 2
Number Major Minor RaidDevice State
0 8 64 0 active sync /dev/sde
1 8 80 1 active sync /dev/sdf
3 8 96 2 spare rebuilding /dev/sdg
4、创建物理卷
[root@localhost ~]# pvcreate /dev/md55
Physical volume "/dev/md55" successfully created
[root@localhost ~]# pvscan
PV /dev/sdb1 VG myvg lvm2 [20.00 GiB / 0 free]
PV /dev/sdb2 VG myvg lvm2 [20.00 GiB / 4.99 GiB free]
PV /dev/sda2 VG centos lvm2 [39.51 GiB / 44.00 MiB free]
PV /dev/sdb3 lvm2 [20.00 GiB]
PV /dev/md55 lvm2 [39.97 GiB]
Total: 5 [139.47 GiB] / in use: 3 [79.50 GiB] / in no VG: 2 [59.97 GiB]
5、创建卷组
[root@localhost ~]# vgcreate vg /dev/md55
Volume group "vg" successfully created
[root@localhost ~]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "myvg" using metadata type lvm2
Found volume group "vg" using metadata type lvm2
Found volume group "centos" using metadata type lvm2
6、创建逻辑卷
[root@localhost ~]# lvcreate -L +30G -n lv vg
Logical volume "lv" created.
[root@localhost ~]# lvscan
ACTIVE '/dev/myvg/mylv' [35.00 GiB] inherit
ACTIVE '/dev/vg/lv' [30.00 GiB] inherit
ACTIVE '/dev/centos/swap' [2.00 GiB] inherit
ACTIVE '/dev/centos/root' [37.46 GiB] inherit
7、格式化逻辑卷
[root@localhost ~]# mkfs.xfs /dev/vg/lv
log stripe unit (524288 bytes) is too large (maximum is 256KiB)
log stripe unit adjusted to 32KiB
meta-data=/dev/vg/lv isize=256 agcount=16, agsize=491392 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=7862272, imaxpct=25
= sunit=128 swidth=256 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=3840, version=2
= sectsz=512 sunit=8 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
8、安装apache
[root@localhost ~]# bash yuanma.sh
#!/bin/bash
yum -y install gcc gcc-c++
tar xf httpd-2.2.17.tar.gz -C /usr/src
cd /usr/src/httpd*
./configure --prefix=/usr/local/apache
make
make install
cd /usr/local/apache/conf/
set "s/#ServerName w/ServerName w" /httpd.conf
/usr/local/apache/bin/apachectl start
yum -y install lynx
lynx 127.0.0.1
9、挂载
[root@localhost ~]# mount -0 usrquota,grpquota /dev/vg/lv /usr/local/apache/htdocs
[root@localhost ~]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root xfs 38G 3.6G 34G 10% /
devtmpfs devtmpfs 985M 0 985M 0% /dev
tmpfs tmpfs 994M 80K 994M 1% /dev/shm
tmpfs tmpfs 994M 8.9M 985M 1% /run
tmpfs tmpfs 994M 0 994M 0% /sys/fs/cgroup
/dev/md5 xfs 20G 33M 20G 1% /data1
/dev/md0 xfs 20G 33M 20G 1% /data2
/dev/sda1 xfs 497M 107M 391M 22% /boot
/dev/mapper/vg-lv xfs 30G 33M 30G 1% /usr/local/apache/htdocs
10、磁盘配额
[root@localhost ~]# quotacheck -auvg
quotacheck: Skipping /dev/mapper/myvg-mylv [/data]
quotacheck: Skipping /dev/mapper/vg-lv [/usr/local/apache/htdocs]
quotacheck: Cannot find filesystem to check or filesystem not mounted with quota option.
[root@localhost ~]# quotaon -avug
11、创建index.html
[root@localhost ~]# cd /usr/local/apache/htdocs
[root@localhost htdocs]# vim index.html
<html><body><h1>胡富豪</h1></body></html>
12、创建用户并对LVM配置磁盘配额
[root@localhost ~]#useradd -d /usr/local/apache/htdocs/hfh hfh
[root@localhost ~]# edquota -u hfh
Disk quotas for user hfh (uid 1001):
Filesystem blocks soft hard inodes soft hard
/dev/mapper/myvg-mylv 0 0 0 0 0 0
/dev/mapper/vg-lv 12 81920 102400 7 80 100