RHCSA

服务器主机名:server.group8.example.com
ip地址:172.24.8.254
网关: 172.24.8.254
DNS: 172.24.8.254

模拟题地址:
http://172.24.8.254/exam/

第一题
破解密码

第二题
完成IP和主机名配置
nmcli connection modify eth0 ipv4.addresses ipv4.addresses ‘172.24.11.10/24 172.24.11.254’

[root@desktop ~]# nmcli connection modify eth0 ipv4.addresses 172.24.8.10/24
[root@desktop ~]# nmcli connection modify eth0 ipv4.gateway 172.24.8.254
[root@desktop ~]# nmcli connection modify eth0 ipv4.dns 172.24.8.254
[root@desktop ~]# nmcli connection modify eth0 ipv4.method manual
[root@desktop ~]# nmcli connection modify eth0 connection.autoconnect yes
[root@desktop ~]# nmcli connection up eth0

[root@desktop ~]# hostnamectl set-hostname desktop.group8.example.com
修改完成后重新登陆主机即可生效

第二题
配置SeLinux
请按下列要求设定系统:
SeLinux的工作模式为enforcing
要求系统重启后依然生效

[root@desktop ~]# setenforce 1
[root@desktop ~]# getenforce
Enforcing
[root@desktop ~]# grep -i ^selinux= /etc/selinux/config
SELINUX=enforcing

第三题
配置软件仓库
[root@desktop ~]# cat /etc/yum.repos.d/base.repo
[base]
name=base
baseurl=http://server.group8.example.com/yum
enable=1
gpgcheck=0

第四题
调整逻辑卷容量
请按照以下要求调整本地逻辑卷 lv0 的容量:
调整后的逻辑卷及文件系统大小为 290 MiB
调整后确保文件系统中已存在的内容不能被破坏
调整后的容量可能出现误差,只要在270MiB - 320MiB之间都是允许的
调整后,保证其挂载目录不改变,文件系统完成

[root@desktop ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 vg0 lvm2 a-- 496.00m 296.00m
[root@desktop ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg0 1 1 0 wz–n- 496.00m 296.00m
[root@desktop ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv0 vg0 -wi-ao---- 200.00m
[root@desktop ~]# lvextend /dev/vg0/lv0 -L 290M
Rounding size to boundary between physical extents: 292.00 MiB
Size of logical volume vg0/lv0 changed from 200.00 MiB (50 extents) to 292.00 MiB (73 extents).
Logical volume lv0 successfully resized.
[root@desktop ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.8G 3.3G 6.5G 34% /
devtmpfs 660M 0 660M 0% /dev
tmpfs 674M 0 674M 0% /dev/shm
tmpfs 674M 8.9M 666M 2% /run
tmpfs 674M 0 674M 0% /sys/fs/cgroup
/dev/mapper/vg0-lv0 190M 1.6M 179M 1% /home
tmpfs 135M 0 135M 0% /run/user/0
[root@desktop ~]# resize2fs /dev/mapper/vg0-lv0
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/mapper/vg0-lv0 is mounted on /home; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/mapper/vg0-lv0 is now 299008 blocks long.
[root@desktop ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.8G 3.3G 6.5G 34% /
devtmpfs 660M 0 660M 0% /dev
tmpfs 674M 0 674M 0% /dev/shm
tmpfs 674M 8.9M 666M 2% /run
tmpfs 674M 0 674M 0% /sys/fs/cgroup
/dev/mapper/vg0-lv0 279M 2.1M 263M 1% /home
tmpfs 135M 0 135M 0% /run/user/0

第五题
创建用户和用户组
请按照以下要求创建用户、用户组:
新建一个名为 adminuser 的组,组 id 为 40000
新建一个名为 natasha 的用户,并将 adminuser 作为其附属组
新建一个名为 harry 的用户,并将 adminuser 作为其附属组
新建一个名为 sarah 的用户,其不属于 adminuser 组,其在系统中没有任何可交互的 shell
natasha 、 harry 和 sarah 三个用户的密码均设置为 redhat

[root@desktop ~]# groupadd -g 40000 adminuser
[root@desktop ~]# useradd -G adminuser natasha
[root@desktop ~]# useradd -G adminuser harry
[root@desktop ~]# useradd -s /sbin/nologin sarah
[root@desktop ~]# echo redhat | passwd --stdin natasha
Changing password for user natasha.
passwd: all authentication tokens updated successfully.
[root@desktop ~]# echo redhat | passwd --stdin harry
Changing password for user harry.
passwd: all authentication tokens updated successfully.
[root@desktop ~]# echo redhat | passwd --stdin sarah
Changing password for user sarah.
passwd: all authentication tokens updated successfully.

第六题
配置文件 /var/tmp/fstab 的权限
复制文件 /etc/fstab 到 /var/tmp 目录下,并按照以下要求配置 /var/tmp/fstab 文件的权限:
该文件的所属人为 root
该文件的所属组为 root
该文件对任何人均没有执行权限
用户 natasha 对该文件有读和写的权限
用户 harry 对该文件既不能读也不能写
所有其他用户(包括当前已有用户及未来创建的用户)对该文件都有读的权限

[root@desktop ~]# cp /etc/fstab /var/tmp/
[root@desktop ~]# ll /var/tmp/
total 1
-rw-r–r--. 1 root root 451 Feb 24 12:02 fstab
[root@desktop ~]# chown root:root /var/tmp/fstab
[root@desktop ~]# chmod a-x /var/tmp/fstab
[root@desktop ~]# setfacl -m u:natasha:rw /var/tmp/fstab
[root@desktop ~]# setfacl -m u:harry:- /var/tmp/fstab
[root@desktop ~]# chmod a+r /var/tmp/fstab
[root@desktop ~]# ll /var/tmp/fstab
-rw-rw-r–+ 1 root root 451 Feb 24 12:02 /var/tmp/fstab
[root@desktop ~]# getfacl /var/tmp/fstab
getfacl: Removing leading ‘/’ from absolute path names

file: var/tmp/fstab

owner: root

group: root

user::rw-
user:natasha:rw-
user:harry:—
group::r–
mask::rw-
other::r–

第七题
建立计划任务

对natasha用户建立计划任务,要求在本地时间的每天14:23执行以下命令:
/bin/echo “hiya”

[root@desktop ~]# crontab -e -u natasha
no crontab for natasha - using an empty one
crontab: installing new crontab
[root@desktop ~]#
[root@desktop ~]#
[root@desktop ~]#
[root@desktop ~]# crontab -l -u natasha
23 14 * * * /bin/echo “hiya”

第八题
创建一个共享目录

在/home目录下创建名为admins的子目录,并按以下要求设置权限:
/home/admins 目录的所属组为adminuser
该目录对 adminuser 组的成员可读可执行可写,但对其他用户没有任何权限,但 root 不受限制
在 /home/admins 目录下所创建的文件的所属组自动被设置为 adminuser

[root@desktop ~]# mkdir /home/admins
[root@desktop ~]# chgrp adminuser /home/admins/
[root@desktop ~]# chmod g=rwx /home/admins/
[root@desktop ~]# chmod o=- /home/admins/
[root@desktop ~]# chmod g+s /home/admins/
[root@desktop ~]# ll -d /home/admins/
drwxrws—. 2 root adminuser 1024 Feb 24 13:37 /home/admins/

第九题
升级系统内核

从 http://server.group8.example.com/pub/ 下找到需要升级的内核,同时满足下列要求:
当系统重新启动之后,升级的内核要作为默认的内核
原来的内核要被保留,并且仍然可以正常启动

[root@desktop ~]# curl --silent http://server.group8.example.com/pub/ | grep kernel
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3252 100 3252 0 0 142k 0 --:–:-- --:–:-- --:–:-- 151k

[   ] kernel-3.10.0-327.4...>2016-12-30 16:48 33M  [root@desktop ~]# rpm -ivh http://server.group8.example.com/pub/kernel-3.10.0-327.4.5.el7.x86_64.rpm Retrieving http://server.group8.example.com/pub/kernel-3.10.0-327.4.5.el7.x86_64.rpm warning: /var/tmp/rpm-tmp.ZrawCB: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:kernel-3.10.0-327.4.5.el7 ################################# [100%] [root@desktop ~]# grub2-editenv list saved_entry=Red Hat Enterprise Linux Server (3.10.0-327.4.5.el7.x86_64) 7.2 (Maipo)

第十题
绑定外部验证服务

系统 server.group8.example.com 提供了一个 LDAP 验证服务。您的系统需要按照以下要求绑定到这个服务上:
验证服务器的基本 DN 是:dc=group8,dc=example,dc=com
账户信息和验证信息都是由 LDAP 提供
连接需要使用证书加密,证书可以在下面的链接中下载:
http://server.group8.example.com/pub/cacert.pem
当正确完成配置后,用户 thales 可以登录系统,登录密码是 redhat

[root@desktop ~]# yum install authconfig-tui sssd -y

Installed:
sssd.x86_64 0:1.13.0-40.el7
Dependency Installed:
c-ares.x86_64 0:1.10.0-3.el7 cyrus-sasl-gssapi.x86_64 0:2.1.26-19.2.el7 libdhash.x86_64 0:0.4.3-25.el7
libipa_hbac.x86_64 0:1.13.0-40.el7 python-sssdconfig.noarch 0:1.13.0-40.el7 sssd-ad.x86_64 0:1.13.0-40.el7
sssd-common.x86_64 0:1.13.0-40.el7 sssd-common-pac.x86_64 0:1.13.0-40.el7 sssd-ipa.x86_64 0:1.13.0-40.el7
sssd-krb5.x86_64 0:1.13.0-40.el7 sssd-krb5-common.x86_64 0:1.13.0-40.el7 sssd-ldap.x86_64 0:1.13.0-40.el7
sssd-proxy.x86_64 0:1.13.0-40.el7

Complete!

[root@desktop ~]# mkdir /etc/openldap/cacerts/
[root@desktop ~]# curl http://server.group8.example.com/pub/ | grep pem
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3252 100 3252 0 0 269k 0 --:–:-- --:–:-- --:–:-- 288k

[   ] cacert.pem 2016-07-23 05:45 1.3K  [root@desktop ~]# wget -O /etc/openldap/cacerts/ca.pem http://server.group8.example.com/pub/cacert.pem --2018-02-24 14:03:19-- http://server.group8.example.com/pub/cacert.pem Resolving server.group8.example.com (server.group8.example.com)... 172.24.8.254 Connecting to server.group8.example.com (server.group8.example.com)|172.24.8.254|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1350 (1.3K) Saving to: ‘/etc/openldap/cacerts/ca.pem’

100%[=============================================================================================>] 1,350 --.-K/s in 0s

2018-02-24 14:03:19 (95.4 MB/s) - ‘/etc/openldap/cacerts/ca.pem’ saved [1350/1350]

[root@desktop ~]# authconfig-tui

选择 Use LDAP
选择 Use LDAP Authentication
选择 Next
空格选中 Use TLS
Server 栏填写 server.group8.example.com/
Base DN 栏填写 dc=group8,dc=example,dc=com
[root@desktop ~]# systemctl enable sssd
[root@desktop ~]# getent passwd thales
thales:*:2001:2001:thales:/home/ldap/thales:/bin/bash

[root@desktop ~]# systemctl status sssd
● sssd.service - System Security Services Daemon
Loaded: loaded (/usr/lib/systemd/system/sssd.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/sssd.service.d
└─journal.conf
Active: active (running) since Sat 2018-02-24 14:05:30 CST; 5min ago

[root@desktop ~]# ssh thales@desktop
The authenticity of host ‘desktop (172.24.8.10)’ can’t be established.
ECDSA key fingerprint is b9:37:48:ed:bd:1a:52:80:b5:76:1c:fa:49:71🆎f5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘desktop,172.24.8.10’ (ECDSA) to the list of known hosts.
thales@desktop’s password:
Could not chdir to home directory /home/ldap/thales: No such file or directory
-bash-4.2$

如果有问题,则有可能是时间没有和服务器进行同步,把后面的时间服务配置好后,重启启动服务即可

第十一题
配置 autofs

按照下述要求配置 autofs 用来自动挂载 LDAP 用户的主目录:
server.group8.example.com 通过 NFS 输出了 /rhome 目录到您的系统。这个文件系统包含了用户 thales 的主目录,并且已经预先配置好了。
thales 用户的主目录是 server.group8.example.com:/rhome/thales
thales 用户的主目录应该挂载到本地的/home/ldap/thales
用户对其主目录必须是读写的
thales 的登录密码是 redhat

[root@desktop ~]# yum install autofs

Installed:
autofs.x86_64 1:5.0.7-54.el7

Dependency Installed:
hesiod.x86_64 0:3.2.1-3.el7

Complete!

[root@desktop ~]# grep ldap /etc/auto.master
/home/ldap /etc/auto.ldap
[root@desktop ~]# vim /etc/auto.ldap
[root@desktop ~]# cat /etc/auto.ldap

  • -rw.sync.soft server.group8.example.com:/rhome/&
    [root@desktop ~]# systemctl enable autofs
    Created symlink from /etc/systemd/system/multi-user.target.wants/autofs.service to /usr/lib/systemd/system/autofs.service.
    [root@desktop ~]# systemctl restart autofs
    [root@desktop ~]# ssh thales@localhost
    The authenticity of host ‘localhost (::1)’ can’t be established.
    ECDSA key fingerprint is b9:37:48:ed:bd:1a:52:80:b5:76:1c:fa:49:71🆎f5.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added ‘localhost’ (ECDSA) to the list of known hosts.
    thales@localhost’s password:
    Last login: Sat Feb 24 14:12:34 2018 from desktop.group8.example.com
    [thales@desktop ~]$ pwd
    /home/ldap/thales

第十二题

配置NTP

配置您的系统时间与服务器 server.group8.example.com 同步,要求系统重启后依然生效

[root@desktop ~]# grep iburst /etc/chrony.conf
#server 0.rhel.pool.ntp.org iburst
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst
#server 3.rhel.pool.ntp.org iburst
server server.group8.example.com iburst

[root@desktop ~]# systemctl enable chronyd
[root@desktop ~]# systemctl restart chronyd
[root@desktop ~]# chronyc
chrony version 2.1.1
Copyright © 1997-2003, 2007, 2009-2015 Richard P. Curnow and others
chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and
you are welcome to redistribute it under certain conditions. See the
GNU General Public License version 2 for details.

chronyc> waitsync
try: 1, refid: 172.24.8.254, correction: 0.000036563, skew: 38.177
chronyc> exit

第十三题

创建一个归档

创建一个名为 /root/sysconfig.tar.bz2 的归档文件,其中包含了/etc/sysconfig目录中的内容。tar归档文件必须使用 bzip2 进行压缩。

[root@desktop ~]# tar -jcf /root/sysconfig.tar.bz2 /etc/sysconfig/
tar: Removing leading `/’ from member names

第十四题

配置一个用户帐号
请创建一个名为jay的用户,并满足以下要求:
用户 id 为3456
密码为 glegunge

[root@desktop ~]# useradd -u 3456 jay
[root@desktop ~]# echo glegunge | passwd --stdin jay
Changing password for user jay.
passwd: all authentication tokens updated successfully.

第十五题
添加一个 swap 分区

在您的系统中添加一个新的 swap 分区,并满足以下要求:
swap 分区容量为 512 MiB
当您的系统启动时,swap 分区应该可以自动挂载
不要移除或者修改其他已经存在于您的系统中的 swap 分区

[root@desktop ~]# fdisk /dev/sda <----考试的时候应该为/dev/vda,注意看题
Welcome to fdisk (util-linux 2.23.2).

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
Select (default e): e
Selected partition 4
First sector (25602048-41943039, default 25602048):
Using default value 25602048
Last sector, +sectors or +size{K,M,G} (25602048-41943039, default 41943039):
Using default value 41943039
Partition 4 of type Extended and of size 7.8 GiB is set

Command (m for help): n
All primary partitions are in use
Adding logical partition 5
First sector (25604096-41943039, default 25604096):
Using default value 25604096
Last sector, +sectors or +size{K,M,G} (25604096-41943039, default 41943039): +512M
Partition 5 of type Linux and of size 512 MiB is set

Command (m for help): t
Partition number (1-5, default 5):
Hex code (type L to list all codes): 82
Changed type of partition ‘Linux’ to ‘Linux swap / Solaris’

Command (m for help): p

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 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
Disk label type: dos
Disk identifier: 0x000bffad

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 20482047 10240000 83 Linux
/dev/sda2 20482048 24578047 2048000 82 Linux swap / Solaris
/dev/sda3 24578048 25602047 512000 83 Linux
/dev/sda4 25602048 41943039 8170496 5 Extended
/dev/sda5 25604096 26652671 524288 82 Linux swap / Solaris

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@desktop ~]# partprobe
[root@desktop ~]# ll /dev/sda5
brw-rw----. 1 root disk 8, 5 Feb 27 10:12 /dev/sda5

[root@desktop ~]# mkswap /dev/sda5
Setting up swapspace version 1, size = 524284 KiB
no label, UUID=d6597a0a-44e8-4cf3-8c86-263a56eaf979
[root@desktop ~]# swapon /dev/sda5
[root@desktop ~]# swapon -s
Filename Type Size Used Priority
/dev/sda2 partition 2047996 0 -1
/dev/sda5 partition 524284 0 -2

[root@desktop ~]# grep swap /etc/fstab
UUID=ff7d2e6d-c2d7-46a0-af09-70c85898ab46 swap swap defaults 0 0
UUID=d6597a0a-44e8-4cf3-8c86-263a56eaf979 swap swap defaults 0 0

第十六题
查找文件
请把系统上拥有者为 jay 用户的所有文件,并将其拷贝到 /root/findfiles 目录中

[root@desktop ~]# find / -user jay -exec cp -a {} /root/findfiles/ ;
[root@desktop ~]# ls -la findfiles/
total 20
drwxr-xr-x. 5 root root 4096 Feb 27 10:19 .
dr-xr-x—. 15 root root 4096 Feb 27 10:18 …
-rw-r–r--. 1 jay jay 18 Jul 8 2015 .bash_logout
-rw-r–r--. 1 jay jay 193 Jul 8 2015 .bash_profile
-rw-r–r--. 1 jay jay 231 Jul 8 2015 .bashrc
drwxr-xr-x. 2 jay jay 6 Jan 27 2014 extensions
-rw-rw----. 1 jay mail 0 Feb 27 10:18 jay
drwxr-xr-x. 4 jay jay 37 Jul 19 2016 .mozilla
drwxr-xr-x. 2 jay jay 6 Jan 27 2014 plugins

第十七题
查找一个字符串

把 /usr/share/dict/words 文件中所有包含 seismic 字符串的行找到,并将这些行按照原始文件中的顺序存放到 /root/wordlist 中,/root/wordlist 文件不能包含空行

[root@desktop ~]# grep seismic /usr/share/dict/words | grep -v ^$ > /root/wordlist

第十八题
创建一个逻辑卷

请按下列要求创建一个新的逻辑卷:

创建一个名为 datastore 的卷组,卷组的PE尺寸为 16 MiB
逻辑卷的名字为 database ,所属卷组为 datastore,该逻辑卷由 50 个 PE 组成
将新建的逻辑卷格式化为 xfs 文件系统,要求系统启动时,该逻辑卷能被自动挂载到 /mnt/database 目录 

[root@desktop ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 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
Disk label type: dos
Disk identifier: 0x000bffad

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 20482047 10240000 83 Linux
/dev/sda2 20482048 24578047 2048000 82 Linux swap / Solaris
/dev/sda3 24578048 25602047 512000 83 Linux
/dev/sda4 25602048 41943039 8170496 5 Extended
/dev/sda5 25604096 26652671 524288 82 Linux swap / Solaris

Command (m for help): n
All primary partitions are in use
Adding logical partition 6
First sector (26654720-41943039, default 26654720):
Using default value 26654720
Last sector, +sectors or +size{K,M,G} (26654720-41943039, default 41943039):
Using default value 41943039
Partition 6 of type Linux and of size 7.3 GiB is set

Command (m for help): p

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 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
Disk label type: dos
Disk identifier: 0x000bffad

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 20482047 10240000 83 Linux
/dev/sda2 20482048 24578047 2048000 82 Linux swap / Solaris
/dev/sda3 24578048 25602047 512000 83 Linux
/dev/sda4 25602048 41943039 8170496 5 Extended
/dev/sda5 25604096 26652671 524288 82 Linux swap / Solaris
/dev/sda6 26654720 41943039 7644160 83 Linux

Command (m for help): t
Partition number (1-6, default 6):
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: 21.5 GB, 21474836480 bytes, 41943040 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
Disk label type: dos
Disk identifier: 0x000bffad

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 20482047 10240000 83 Linux
/dev/sda2 20482048 24578047 2048000 82 Linux swap / Solaris
/dev/sda3 24578048 25602047 512000 83 Linux
/dev/sda4 25602048 41943039 8170496 5 Extended
/dev/sda5 25604096 26652671 524288 82 Linux swap / Solaris
/dev/sda6 26654720 41943039 7644160 8e Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@desktop ~]# partprobe
[root@desktop ~]# pvcreate /dev/sda6
Physical volume “/dev/sda6” successfully created
[root@desktop ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 vg0 lvm2 a-- 496.00m 296.00m
/dev/sda6 datastore lvm2 a-- 7.28g 7.28g
[root@desktop ~]# vgcreate -s 16M datastore /dev/sda6
Volume group “datastore” successfully created
[root@desktop ~]# vgdisplay datastore | grep “PE Size”
PE Size 16.00 MiB
[root@desktop ~]# lvcreate -n database -l 50 datastore
[root@desktop ~]# lvdisplay /dev/datastore/database | grep LE
Current LE 50
[root@desktop ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
database datastore -wi-a----- 800.00m
lv0 vg0 -wi-ao---- 200.00m
[root@desktop ~]# mkfs.xfs /dev/datastore/database
meta-data=/dev/datastore/database isize=256 agcount=4, agsize=51200 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=204800, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=853, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@desktop ~]# mkdir /mnt/database
[root@desktop ~]# blkid
/dev/sda5: UUID=“d6597a0a-44e8-4cf3-8c86-263a56eaf979” TYPE=“swap”
/dev/sda1: UUID=“3c6e20fa-3e12-42ca-8dba-b12eee74e43e” TYPE=“xfs”
/dev/sda2: UUID=“ff7d2e6d-c2d7-46a0-af09-70c85898ab46” TYPE=“swap”
/dev/sda3: UUID=“4Ntfep-th0e-bCXr-Qo3b-EPJ1-SRsu-nfeOru” TYPE=“LVM2_member”
/dev/sda6: UUID=“gmmg8T-uUpQ-AhM5-WSLU-aRKa-CQ6F-7hjQbf” TYPE=“LVM2_member”
/dev/mapper/vg0-lv0: UUID=“b2285e5e-de78-4392-945a-817843fd7f10” TYPE=“ext3”
/dev/mapper/datastore-database: UUID=“8a121a97-79c9-4dca-a412-8667bd4aa0d4” TYPE=“xfs”
[root@desktop ~]# vim /etc/fstab
[root@desktop ~]# grep mnt /etc/fstab
UUID=8a121a97-79c9-4dca-a412-8667bd4aa0d4 /mnt/database xfs defaults 0 0

[root@desktop ~]# mount -a
[root@desktop ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.8G 3.3G 6.5G 34% /
devtmpfs 660M 0 660M 0% /dev
tmpfs 674M 0 674M 0% /dev/shm
tmpfs 674M 8.9M 666M 2% /run
tmpfs 674M 0 674M 0% /sys/fs/cgroup
/dev/mapper/vg0-lv0 190M 1.6M 179M 1% /home
tmpfs 135M 0 135M 0% /run/user/0
/dev/mapper/datastore-database 797M 33M 765M 5% /mnt/database

至此,所有题目已完成,重启desktop.group8.example.com,再次检查所有的配置已生效

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值