设置root密码

venusroot 密码设置为 flectrag 。您需要获得系统访问权限才能进行此操作。

解题

第一步

  1. 打开主机venus
  2. 点击Send key
  3. 选择 Ctrl+Alt+Del 重新启动
  4. 开机导航页面按e键

第二步

  1. 将光标移到Linux 那一行末尾添加如下内容: console=tty0 rd.break

第三步

  1. 第二步添加修改完成后,按下:Ctrl + X进入grup救援模式进修配置

第三步:按下:Ctrl + X进入grup救援模式

# 重新挂载/目录 

switch_root:/# mount -o rw,remount /sysroot

# 进入/目录

# switch_root:/# chroot /sysroot

# 设置root密码

# sh-4.4# echo "flectrag"|passwd --stdin root

# 在根目录下创建重新刷新SELinux 安全上下文标记的文件

sh-4.4# touch /.autorelabel

#退出重启系统

# sh-4.4# exit

# switch_root:/# reboot

配置您的系统以使用默认存储库

YUM 存储库已可以从 http://content/rhel8.0/x86_64/dvd/BaseOShttp://content/rhel8.0/x86_64/dvd/AppStream 使用配置您的系统,以将这些位置用作默认存储库。

解题

从第一个虚拟机复制过来

[root@mars ~]# scp /etc/yum.repos.d/rhcsa.repo

root@172.25.250.200:/etc/yum.repods.d/

[root@venus ~]# yum install -y vim
#或者重新配置

调整逻辑卷大小

将逻辑卷 vo 及其文件系统的大小调整到 230 MiB。确保文件系统内容保持不变。注:分区大小很少与请求的大小完全相同,因此可以接受范围为 217 MiB243 MiB 的大小。

解题1

查看需要调整的逻辑卷所挂载的路径和现有的大小、名字

[root@venus ~]# lvscan 
ACTIVE '/dev/vgroup/swap' [512.00 MiB] inherit
ACTIVE '/dev/myvol/vo' [184.00 MiB] inherit

查看卷组的容量有多大

[root@venus ~]# vgs
VG #PV #LV #SN Attr VSize VFree
myvol 1 1 0 wz--n- 508.00m 324.00m
vgroup 1 1 0 wz--n- <2.00g <1.50g

使用lvextend进行扩容

[root@venus ~]# lvextend -rL 230M /dev/myvol/vo

检查lvm大小是否符合

[root@venus ~]# lvscan
ACTIVE '/dev/vgroup/swap' [512.00 MiB] inherit
ACTIVE '/dev/myvol/vo' [232.00 MiB] inherit

[root@venus ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 887M 0 887M 0% /dev
tmpfs tmpfs 914M 0 914M 0% /dev/shm
tmpfs tmpfs 914M 17M 897M 2% /run
tmpfs tmpfs 914M 0 914M 0% /sys/fs/cgroup
/dev/vda3 xfs 9.9G 1.6G 8.4G 16% /
/dev/vda2 vfat 100M 6.8M 94M 7% /boot/efi
/dev/mapper/myvol-vo ext4 221M 2.1M 204M 1% /reports #这里显示的不是230M没有关系存在误差
tmpfs tmpfs 183M 0 183M 0% /run/user/0

解题2

[root@venus ~]# lvs

LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync

Convert

vo myvol -wi-ao---- 184.00m

swap vgroup -wi-ao---- 512.00m

[root@venus ~]# lvextend -L 230M /dev/

[root@venus ~]# lvextend -L 230M /dev/myvol/vo

[root@venus ~]# df -h

Filesystem Size Used Avail Use% Mounted on

devtmpfs 388M 0 388M 0% /dev

tmpfs 411M 0 411M 0% /dev/shm

tmpfs 411M 16M 395M 4% /run

tmpfs 411M 0 411M 0% /sys/fs/cgroup

/dev/vda1 10G 1.5G 8.6G 15% /

/dev/mapper/myvol-vo 175M 1.6M 160M 1% /reports

tmpfs 83M 0 83M 0% /run/user/0

[root@venus ~]# lsblk -f

[root@venus ~]# resize2fs /dev/myvol/vo

[root@venus ~]# df -h

Filesystem Size Used Avail Use% Mounted on

devtmpfs 388M 0 388M 0% /dev

tmpfs 411M 0 411M 0% /dev/shm

tmpfs 411M 16M 395M 4% /run

tmpfs 411M 0 411M 0% /sys/fs/cgroup

/dev/vda1 10G 1.5G 8.6G 15% /

/dev/mapper/myvol-vo 221M 2.1M 204M 1% /reports

tmpfs 83M 0 83M 0% /run/user/0

#ext4同步文件系统大小 resize2fs, xfs的话用 xfs_growfs

添加交换分区

向您的系统添加一个额外的交换分区 756MiB 。交换分区应在系统 启动时自动挂载 。不要删除或以任何方式改动系统上的任何现有交换分区。

解题1

fdisk分区

[root@venus ~]# fdisk /dev/vdb

Command (m for help): n

Partition number (2-128, default 2):

First sector (1000001-10485726, default 1001472):

Last sector, +sectors or +size{K,M,G,T,P} (1001472-10485726, default

10485726): +756M

Created a new partition 2 of type 'Linux filesystem' and of size 756 MiB.

Command (m for help): p

Disk /dev/vdb: 5 GiB, 5368709120 bytes, 10485760 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: gpt

Disk identifier: CBD519C0-D1F2-4E98-B8D3-C4F4B60C025A

Device Start End Sectors Size Type

/dev/vdb1 1024 1000000 998977 487.8M Linux filesystem

/dev/vdb2 1001472 2549759 1548288 756M Linux filesystem

Command (m for help): w

The partition table has been altered.

Syncing disks.

格式化

[root@venus ~]# mkswap /dev/vdb2

Setting up swapspace version 1, size = 756 MiB (792719360 bytes)

no label, UUID=4e337981-b8c7-48ee-86c6-1a11fd7dbb82

永久挂载

[root@system1 ~]# vim /etc/fstab

/dev/vdb2 swap swap defaults 0 0

[root@venus ~]# mount -a

激活交换分区

[root@venus ~]# swapon -a

[root@venus ~]# swapon --show

NAME TYPE SIZE USED PRIO

/dev/dm-0 partition 512M 0B -2

/dev/vdb2 partition 756M 0B -3

[root@venus ~]# free -m

total used free shared buff/cache

available

Mem: 821 175 328 15 316

500

Swap: 1267 0 1267

解题2

查看一下磁盘空间分配情况

[root@venus ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 10G 0 disk
├─vda1 252:1 0 1M 0 part
├─vda2 252:2 0 100M 0 part /boot/efi
└─vda3 252:3 0 9.9G 0 part /
vdb 252:16 0 5G 0 disk
├─vdb1 252:17 0 510M 0 part
│ └─myvol-vo 253:0 0 232M 0 lvm /reports
└─vdb2 252:18 0 2G 0 part
└─vgroup-swap 253:1 0 512M 0 lvm [SWAP]
vdc 252:32 0 10G 0 disk

使用磁盘分区分出一个swap

[root@venus ~]# fdisk /dev/vdb
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): p # 首先p打印一下现在的分区信息
Disk /dev/vdb: 5 GiB, 5368709120 bytes, 10485760 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: 0xdf110c4a

Device Boot Start End Sectors Size Id Type
/dev/vdb1 2048 1046528 1044481 510M 83 Linux
/dev/vdb2 1046529 5240833 4194305 2G 83 Linux

Command (m for help): n # 然后按n新建分区
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p): p # 再按p添加主分区
Partition number (3,4, default 3): # 然后是让你选择主分区代码3,4默认就可以(3)
First sector (5240834-10485759, default 5242880): # 之后是选择分区起始位置的大小默认就可以
Last sector,+sectors or +size{K,M,G,T,P} (5242880-10485759, default 10485759): +756M #最后是选择增加的大小+756M

Created a new partition 3 of type 'Linux' and of size 756 MiB.

Command (m for help): p # 现在按p再查看一下分区信息
Disk /dev/vdb: 5 GiB, 5368709120 bytes, 10485760 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: 0xdf110c4a

Device Boot Start End Sectors Size Id Type
/dev/vdb1 2048 1046528 1044481 510M 83 Linux
/dev/vdb2 1046529 5240833 4194305 2G 83 Linux
/dev/vdb3 5242880 6791167 1548288 756M 83 Linux

# 为了以后方便正常工作中查看将标识号更改为82(交换分区)
Command (m for help): t # 按t
Partition number (1-3, default 3): 3 # 选择3
Hex code (type L to list all codes): 82 # 再输入82

Changed type of partition 'Linux' to 'Linux swap / Solaris'.

Command (m for help): p # 再按p再查看一下分区信息
Disk /dev/vdb: 5 GiB, 5368709120 bytes, 10485760 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: 0xdf110c4a

Device Boot Start End Sectors Size Id Type
/dev/vdb1 2048 1046528 1044481 510M 83 Linux
/dev/vdb2 1046529 5240833 4194305 2G 83 Linux
/dev/vdb3 5242880 6791167 1548288 756M 82 Linux swap / Solaris # 更改成功

Command (m for help): w # 按w保存退出
The partition table has been altered.
Syncing disks.

查看分区信息

[root@venus ~]# lsblk 
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 10G 0 disk
├─vda1 252:1 0 1M 0 part
├─vda2 252:2 0 100M 0 part /boot/efi
└─vda3 252:3 0 9.9G 0 part /
vdb 252:16 0 5G 0 disk
├─vdb1 252:17 0 510M 0 part
│ └─myvol-vo 253:0 0 232M 0 lvm /reports
├─vdb2 252:18 0 2G 0 part
│ └─vgroup-swap 253:1 0 512M 0 lvm [SWAP]
└─vdb3 252:19 0 756M 0 part
vdc 252:32 0 10G 0 disk

格式化分区

[root@venus ~]# mkswap /dev/vdb3
Setting up swapspace version 1, size = 756 MiB (792719360 bytes)
no label, UUID=dd5e8738-83a0-45fb-9014-4533d7a94e8e

编辑fstab设置开机自动挂载

# 查看UUID
[root@venus ~]# blkid /dev/vdb3
/dev/vdb3: UUID="dd5e8738-83a0-45fb-9014-4533d7a94e8e" TYPE="swap" PARTUUID="df110c4a-03"

# 在末行插入
[root@venus ~]# vim /etc/fstab
UUID="dd5e8738-83a0-45fb-9014-4533d7a94e8e" swap swap defaults 0 0

# 挂载
[root@venus ~]# swapon -a
[root@venus ~]# swapon -s
Filename Type Size Used Priority
/dev/dm-1 partition 524284 0 -2
/dev/vdb3 partition 774140 0 -3

创建逻辑卷

根据如下要求,创建新的逻辑卷:

  • 逻辑卷取名为 qa ,属于 qagroup 卷组,大小为 60 个扩展块

  • qagroup 卷组中逻辑卷的扩展块大小应当为 16 MiB

  • 使用 ext3 文件系统格式化新逻辑卷。该逻辑卷应在系统启动时自动挂载到 /mnt/qa

解题1

分区

[root@venus ~]# fdisk /dev/vdb

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

Partition number (3-128, default 3):

First sector (2549760-10485726, default 2549760):

Last sector, +sectors or +size{K,M,G,T,P} (2549760-10485726, default

10485726): +1G

Created a new partition 3 of type 'Linux filesystem' and of size 1 GiB.

Command (m for help): w

The partition table has been altered.

Syncing disks.

创建pv vg lv

[root@venus ~]# pvcreate /dev/vdb3

[root@venus ~]# vgcreate -s 16M qagroup /dev/vdb3

[root@venus ~]# lvcreate -l 60 -n qa qagroup

[root@venus ~]# lvs

LV VG Attr LSize Pool Origin Data% Meta% Move Log

Cpy%Sync Convert

vo myvol -wi-ao---- 232.00m

qa qagroup -wi-a----- 960.00m

swap vgroup -wi-ao---- 512.00m

[root@venus ~]# lvdisplay

创建挂载路径

[root@venus ~]# mkdir /mnt/qa

格式化

[root@venus ~]# mkfs.ext3 /dev/qagroup/qa

开机挂载

[root@venus ~]# vim /etc/fstab

/dev/qagroup/qa /mnt/qa ext3 defaults 0 0

[root@venus ~]# mount -a

[root@venus ~]# df -h

Filesystem Size Used Avail Use% Mounted on

devtmpfs 388M 0 388M 0% /dev

tmpfs 411M 0 411M 0% /dev/shm

tmpfs 411M 16M 395M 4% /run

tmpfs 411M 0 411M 0% /sys/fs/cgroup

/dev/vda1 10G 1.5G 8.6G 15% /

/dev/mapper/myvol-vo 221M 2.1M 204M 1% /reports

tmpfs 83M 0 83M 0% /run/user/0

/dev/mapper/qagroup-qa 929M 1.2M 880M 1% /mnt/q

解题2

先将所有剩余空间给扩展分区

# 在这里解释一下为什么给全部容量,而不是60个拓展块*16M=960M 因为红帽考试存在bug尽量在已知条件给更大的空间
[root@venus ~]# fdisk /dev/vdb

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
Partition type
p primary (3 primary, 0 extended, 1 free)
e extended (container for logical partitions)
Select (default e):

Using default response e.
Selected partition 4
First sector (5240834-10485759, default 6791168):
Last sector, +sectors or +size{K,M,G,T,P} (6791168-10485759, default 10485759):

Created a new partition 4 of type 'Extended' and of size 1.8 GiB.

Command (m for help): w
The partition table has been altered.
Syncing disks.

Command (m for help): n
All primary partitions are in use.
Adding logical partition 5
First sector (6793216-10485759, default 6793216):
Last sector, +sectors or +size{K,M,G,T,P} (6793216-10485759, default 10485759):

Created a new partition 5 of type 'Linux' and of size 1.8 GiB.

Command (m for help): p
Disk /dev/vdb: 5 GiB, 5368709120 bytes, 10485760 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: 0xdf110c4a

Device Boot Start End Sectors Size Id Type
/dev/vdb1 2048 1046528 1044481 510M 83 Linux
/dev/vdb2 1046529 5240833 4194305 2G 83 Linux
/dev/vdb3 5242880 6791167 1548288 756M 82 Linux swap / Solaris
/dev/vdb4 6791168 10485759 3694592 1.8G 5 Extended
/dev/vdb5 6793216 10485759 3692544 1.8G 83 Linux

Command (m for help): w
The partition table has been altered.
Failed to add partition 5 to system: Device or resource busy

The kernel still uses the old partitions. The new table will be used at the next reboot.
Syncing disks.

# 在模拟环境中显示需要重启
[root@venus ~]# reboot

# 重启后查看之前创建的vdb5已经创建完成
[root@venus ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 10G 0 disk
├─vda1 252:1 0 1M 0 part
├─vda2 252:2 0 100M 0 part /boot/efi
└─vda3 252:3 0 9.9G 0 part /
vdb 252:16 0 5G 0 disk
├─vdb1 252:17 0 510M 0 part
│ └─myvol-vo 253:0 0 232M 0 lvm /reports
├─vdb2 252:18 0 2G 0 part
│ └─vgroup-swap 253:1 0 512M 0 lvm [SWAP]
├─vdb3 252:19 0 756M 0 part [SWAP]
├─vdb4 252:20 0 1K 0 part
└─vdb5 252:21 0 1.8G 0 part
vdc 252:32 0 10G 0 disk

创建pv物理卷

[root@venus ~]#  pvcreate /dev/vdb5 
Physical volume "/dev/vdb5" successfully created.

创建vg逻辑卷组

[root@venus ~]#  vgcreate qagroup /dev/vdb5 -s 16M
Volume group "qagroup" successfully created

创建lv逻辑卷

[root@venus ~]# lvcreate -l 60 -n qa qagroup
Logical volume "qa" created.

格式化文件系统

[root@venus ~]# mkfs.ext3 /dev/qagroup/qa
mke2fs 1.45.4 (23-Sep-2019)
Creating filesystem with 245760 4k blocks and 61440 inodes
Filesystem UUID: 04a9f331-7f7d-4b0d-945e-12d48fdba124
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

创建挂载的路径

[root@venus ~]# mkdir /mnt/qa

编辑fstab设置开机自动挂载

# 查看UUID
[root@venus ~]# blkid /dev/qagroup/qa
/dev/qagroup/qa: UUID="04a9f331-7f7d-4b0d-945e-12d48fdba124" SEC_TYPE="ext2" TYPE="ext3"

# 在末行插入
[root@venus ~]# vim /etc/fstab
UUID="04a9f331-7f7d-4b0d-945e-12d48fdba124" /mnt/qa ext3 defaults 0 0

# 挂载
[root@venus ~]# mount -a

#检查
[root@venus ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 887M 0 887M 0% /dev
tmpfs tmpfs 914M 0 914M 0% /dev/shm
tmpfs tmpfs 914M 17M 897M 2% /run
tmpfs tmpfs 914M 0 914M 0% /sys/fs/cgroup
/dev/vda3 xfs 9.9G 1.7G 8.3G 17% /
/dev/mapper/myvol-vo ext4 221M 2.1M 204M 1% /reports
/dev/vda2 vfat 100M 6.8M 94M 7% /boot/efi
tmpfs tmpfs 183M 0 183M 0% /run/user/0
/dev/mapper/qagroup-qa ext3 929M 1.2M 880M 1% /mnt/qa

创建 VDO 卷

根据如下要求,创建新的 VDO 卷:

  • 使用未分区的磁盘

  • 该卷的名称为 vdough

  • 该卷的逻辑大小为 50G

  • 该卷使用 xfs 文件系统格式化

  • 该卷(在系统启动时)挂载到 /vbread

解题1

[root@venus ~]# yum install -y vdo

[root@venus ~]# man vdo

[root@venus ~]# vdo create --name=vdough --device=/dev/vdc --

vdoLogicalSize=50G

[root@venus ~]# mkfs.xfs /dev/mapper/vdough

[root@venus ~]# mkdir /vbread

[root@venus ~]# vim /etc/fstab

/dev/mapper/vdough /vbread xfs defaults,_netdev 0 0

[root@venus ~]# mount -a

[root@venus ~]# df -h

[root@venus ~]# systemctl start vdo

[root@venus ~]# systemctl enable vdo

#在新版本8.4中,man vdo有fstab文件的提示

/dev/mapper/vdo0 /vdo xfs defaults,x-systemd.requires=vdo.service 0 0

解题2

安装VDO工具

[root@venus ~]# yum -y install vdo kmod-kvdo

创建VDO虚拟磁盘

# 查看创建VDO的命令
[root@venus ~]# man vdo | grep \#
# vdo create --name=vdo0 --device=/dev/sdb1 --vdoLogicalSize=10T
#

[root@venus ~]# vdo create --name=vdough --device=/dev/vdc --vdoLogicalSize=50G
Creating VDO vdough
The VDO volume can address 6 GB in 3 data slabs, each 2 GB.
It can grow to address at most 16 TB of physical storage in 8192 slabs.
If a larger maximum size might be needed, use bigger slabs.
Starting VDO vdough
Starting compression on VDO vdough
VDO instance 0 volume is ready at /dev/mapper/vdough

格式化VDO

[root@venus ~]#  mkfs.xfs -K /dev/mapper/vdough
meta-data=/dev/mapper/vdough isize=512 agcount=4, agsize=3276800 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=13107200, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=6400, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

创建挂载的路径

[root@venus ~]# mkdir /vbread

编辑fstab设置开机自动挂载

# 查看UUID
[root@venus ~]# blkid /dev/mapper/vdough
/dev/mapper/vdough: UUID="93e995d3-e334-4735-98c4-f69820ef22ef" TYPE="xfs"

# 在末行插入
[root@venus ~]# vim /etc/fstab
UUID="93e995d3-e334-4735-98c4-f69820ef22ef" /vbread xfs defaults,x-systemd.requires=vdo.service 0 0

# 挂载
[root@venus ~]# mount -a
[root@venus ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 887M 0 887M 0% /dev
tmpfs tmpfs 914M 0 914M 0% /dev/shm
tmpfs tmpfs 914M 17M 897M 2% /run
tmpfs tmpfs 914M 0 914M 0% /sys/fs/cgroup
/dev/vda3 xfs 9.9G 1.7G 8.3G 17% /
/dev/mapper/myvol-vo ext4 221M 2.1M 204M 1% /reports
/dev/vda2 vfat 100M 6.8M 94M 7% /boot/efi
tmpfs tmpfs 183M 0 183M 0% /run/user/0
/dev/mapper/qagroup-qa ext3 929M 1.2M 880M 1% /mnt/qa
/dev/mapper/vdough xfs 50G 390M 50G 1% /vbread

## 挂载时defaults后的参数通过man vdo 查找fstab找到
For /etc/fstab mounting, in order to make sure the mount waits for the VDO to start, use the mount
option x-systemd.requires=vdo.service For example, an /etc/fstab line involving VDO could be the fol‐
lowing:

/dev/mapper/vdo0 /vdo xfs defaults,x-systemd.requires=vdo.service 0 0

配置系统调优

为您的系统选择建议的 tuned 配置集并将它设为默认设置

解题


[root@venus ~]# tuned-adm recommend # 查看tuned目前推荐使用的策略

virtual-guest

[root@venus ~]# tuned-adm profile virtual-guest 设置profile为推荐值

[root@venus ~]# tuned-adm active 查看是否配置成功

Current active profile: virtual-guest