红帽认证9版本2023年12月的红帽9.0版本RHCSA题⽬+答案,本人已过,全国通用
需要完整的RHCSA和RHCE的考试答案的题目以及RHCE9考试的模拟环境和考试笔记教材的请添加微信,需备注来自csdn,不然通不过
1、配置⽹络设置?
将?node1?配置为具有以下⽹络配置:??
主机名:?node1.domain250.example.com?
IP?地址:?172.25.250.100?
⼦⽹掩码:?255.255.255.0?
⽹关:?172.25.250.254?
DNS服务器:?172.25.250.254?
[kiosk@foundation0 -]$ virt-manager #点击打开Servera(node1)机器输⼊⽤⼾名:
root 密码:flectrag
[root@clear ~]$ nmcli con show #查看⽹卡信息
[root@clear ~]$ nmcli con mod ‘Wired connection 1’ ipv4.method manual
ipv4.addresses 172.25.250.100/24 ipv4.gateway 172.25.250.254 ipv4.dns
172.25.250.254 autoconnect yes
[root@clear ~]$ nmcli con up ‘Wired connection 1’ #启⽤配置好的⽹卡
[root@clear ~]$ ip a
[kiosk@foundation0 -]$ ssh root@172.25.250.100 #然后连接终端
[root@clear ~] hostnamectl set-hostname node1.domain250.example.com #设置主
机名
检查
[root@node1 ~] ip a //查看IP是否正确
[root@node1 ~] hostname //查看主机名是否正确
1
2
3
4
5
6
7
8
9
10
11
2、配置您的系统以使⽤默认存储库?
[root@node1 ~]# vim /etc/yum.repos.d/rhcsa.repo
[Base]
name=Base
baseurl=http://content/rhel9.0/x86_64/dvd/BaseOS
enabled=1
gpgcheck=no
[App]
name=App
baseurl=http://content/rhel9.0/x86_64/dvd/AppStream
enabled=1
gpgcheck=no
检查
[root@node1 ~]# yum repoinfo
[root@node1 ~]# yum -y install vsftpd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
3、调试?SELinux?
[root@node1 ~]# yum provides “*/semanage”
[root@node1 ~]# yum -y install policycoreutils-python-utils
[root@node1 ~]# semanage fcontext -m -t httpd_sys_content_t /var/www/html/file1
[root@node1 ~]# semanage port -a -t http_port_t -p tcp 82
[root@node1 ~]# restorecon -Rv /var/www/html
也可以使⽤man semanage port,然后/EXAMPLE
[root@node1 ~]# firewall-cmd --permanent --add-service=http
[root@node1 ~]# firewall-cmd --permanent --add-port=82/tcp
[root@node1 ~]# firewall-cmd --reload
[root@node1 ~]# systemctl restart httpd
[root@node1 ~]# systemctl enable --now httpd
验证,出现源码即正确(必做操作)
[root@node1 ~]# curl http://node1.domain250.example.com:82/file(1-3)
1
2
3
4
5
6
7
8
9
10
11
12
13
4、创建⽤⼾帐⼾?
[root@node1 ~]# groupadd sysmgrs
[root@node1 ~]# useradd -G sysmgrs natasha
[root@node1 ~]# useradd -G sysmgrs harry
[root@node1 ~]# useradd -s /bin/false sarah
[root@node1 ~]# echo flectrag |passwd --stdin natasha
[root@node1 ~]# echo flectrag |passwd --stdin harry
[root@node1 ~]# echo flectrag |passwd --stdin sarah
1
2
3
4
5
6
7
5、配置?cron?作业?
[root@node1 ~]# systemctl status crond
[root@node1 ~]# systemctl enable crond
[root@node1 ~]# crontab -e -u harry
23 14 * * * /usr/bin/echo hello
检查
[root@node1 ~]# crontab -l -u harry
1
2
3
4
5
6
7
6、创建协作⽬录?
[root@node1 ~]# mkdir /home/managers
[root@node1 ~]# chgrp sysmgrs /home/managers
[root@node1 ~]# chmod 2770 /home/managers
检查
[root@node1 ~]# ll -Z /home
1
2
3
4
5
6
7、配置?NTP?
[root@node1 ~]# yum -y install chrony
[root@node1 ~]# vim /etc/chrony.conf
server materials.example.com iburst
[root@node1 ~]# systemctl restart chronyd
[root@node1 ~]# systemctl enable chronyd
检查
[root@node1 ~]# date -s “1982-1-1”
[root@node1 ~]# systemctl restart chronyd
隔3-5秒执⾏,太快了时间不会同步
[root@node1 ~]# date
1
2
3
4
5
6
7
8
9
10
11
8、配置?autofs?
暂时记做法,环境暂时没做出来
[root@node1 ~]# yum -y install nfs-utils
[root@node1 ~]# yum -y install autofs
[root@node1 ~]# vim /etc/auto.master
/rhome /etc/auto.rhome
[root@node1 ~]# vim /etc/auto.rhome
remoteuser1 -rw materials.example.com:/rhome/remoteuser1
[root@node1 ~]# systemctl enable --now autofs
检查
[root@node1 ~]# ll /rhome/
[root@node1 ~]# ssh remoteuser1@localhost
remoteuser1@localhost’s password: flectrag
$ pwd
/rhome/remoteuser1
$ touch my.file
$ mount | grep rhome
…
materials.example.com:/rhome/remoteuser1 on /rhome/remoteuser1 type nfs4
(rw
,relatime,vers=4.2,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,tim
eo=600,r
etrans=2,sec=sys,clientaddr=172.25.250.100,local_lock=none,addr=172.25.254.254)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
9、?配置⽤⼾帐⼾?
[root@node1 ~]# useradd -u 3533 manalo
[root@node1 ~]# echo flectrag | passwd --stdin manalo
1
2
10、查找⽂件?
[root@node1 ~]# mkdir /root/findfiles
[root@node1 ~]# find / -user jacques
[root@node1 ~]# find / -user jacques -exec cp -a {} /root/findfiles ;
检查
[root@node1 ~]# ll /root/findfiles/
1
2
3
4
5
6
11、查找字符串?
[root@node1 ~]# grep ng /usr/share/xml/iso-codes/iso_639_3.xml
[root@node1 ~]# grep ng /usr/share/xml/iso-codes/iso_639_3.xml > /root/list
检查
[root@node1 ~]# cat /root/list
1
2
3
4
5
12、创建存档?
创建⼀个名为/root/backup.tar.bz2的tar存档,其应包含/usr/local的tar存档,其应包含/usr/local
的内容。该tar存档使⽤bzip2进⾏压缩。?
[root@node1 ~]# yum -y install bzip2
[root@node1 ~]# tar -cvjf /root/backup.tar.bz2 /usr/local
另外⼀个格式GZIP2
[root@node1 ~]# tar -cvzf /root/backup.tar.gz /usr/local
验证
[root@node1 ~]# file /root/backup.tar.bz
1
2
3
4
5
6
7
13、创建⼀个容器镜像?
[root@node1 ~]# dnf -y install container-tools
[root@node1 ~]# ssh wallah@node1
[wallah@node1 ~]# podman login -u admin -p redhat321 registry.lab.example.com
[wallah@node1 ~]# wget http://classroom/Containerfile
[wallah@node1 ~]# podman build -t pdf .
1
2
3
4
5
14、将容器配置为服务?
准备相关的映射⽬录
1
[wallah@node1 ~]# sudo mkdir /opt/{file,progress}
[wallah@node1 ~]# sudo chown wallah:wallah /opt/{file,progress}
启动容器并映射⽬录
[wallah@node1 ~]# podman run -d --name ascii2pdf -v /opt/file:/dir1:Z -v /opt/pr
[wallah@node1 ~]# podman ps -a #查看全部
创建systemd服务⽂件
[wallah@node1 ~]# mkdir -p ~/.config/systemd/user
[wallah@node1 ~]# cd ~/.config/systemd/user/
[wallah@node1 ~]# podman generate systemd -n ascii2pdf -f --new
[wallah@node1 ~]# ls
[wallah@node1 ~]# podman stop ascii2pdf
[wallah@node1 ~]# podman rm ascii2pdf
[wallah@node1 ~]# podman ps -a
[wallah@node1 ~]# systemctl --user daemon-reload
启⽤并启动container-ascii2pdf服务
[wallah@node1 ~]# systemctl --user enable --now container-ascii2pdf
[wallah@node1 ~]# systemctl --user status container-ascii2pdf
[wallah@node1 ~]# podman ps
确保wallah⽤⼾的服务在系统启动时启动
[wallah@node1 ~]# loginctl enable-linger
[wallah@node1 ~]# loginctl show-user wallah
检查,测试容器是否开机⾃启(必做操作)
[wallah@node1 ~]# exit
[root@node1 ~]# reboot
[root@node1 ~]# ssh wallah@node1
[wallah@node1 ~]# podman ps
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
15、添加sudo免密操作?
[root@node1 ~]# visudo
…
%wheel ALL=(ALL) NOPASSWD: ALL
%sysmgrs ALL=(ALL) NOPASSWD: ALL
检查(必做操作)
[root@node1 ~]# su - natasha
1
2
3
4
5
6
7
[natasha@node1 ~]# sudo cat /etc/shadow
8
node2?
16、设置?root?密码?
图1?
图2?
[kiosk@foundation0 -]$ virt-manager #点击打开Serverb(node2)机器,重启
Serverb(node2)机器,等待如图1所⽰⻚⾯,按e进⼊图2⻚⾯,原配置如图所⽰。修改原配置为红⾊
框选部分,如图⼆所⽰,然后按ctrl+x,执⾏以下命令
chroot /sysroot
echo flectrag | passwd --stdin root
touch /.autorelabel
sync
exit
reboot
检查(必做操作)
#打开Serverb(node2)机器输⼊⽤⼾名:root 密码:flectrag,检查是否可以进⼊
1
2
3
4
5
6
7
8
9
10
17、配置您的系统以使⽤默认存储库?
⽅法⼀:
[root@node2 ~]# scp root@node1:/etc/yum.repos.d/rhcsa.repo /etc/yum.repos.d/
⽅法⼆:
[root@node2 ~]# vim /etc/yum.repos.d/rhcsa.repo
[Base]
name=Base
baseurl=http://content/rhel9.0/x86_64/dvd/BaseOS
enabled=1
gpgcheck=no
[App]
name=App
baseurl=http://content/rhel9.0/x86_64/dvd/AppStream
enabled=1
gpgcheck=no
检查
[root@node2 ~]# yum repoinfo
[root@node2 ~]# yum -y install ftp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
18、调整逻辑卷⼤⼩?
[root@node2 ~]# lvscan
[root@node2 ~]# lvextend -L 230M /dev/myvol/vo
[root@node2 ~]# blkid /dev/myvol/vo
[root@node2 ~]# resize2fs /dev/myvol/vo
检查
[root@node2 ~]# df -h
1
2
3
4
5
6
7
19、添加交换分区?
[root@node2 ~]# lsblk
[root@node2 ~]# fdisk /dev/vdb
[root@node2 ~]# mkswap /dev/vdb3
[root@node2 ~]# vim /etc/fstab
/dev/vdb3 swap swap defaults 0 0
[root@node2 ~]# swapon -a
[root@node2 ~]# swapon
1
2
3
4
5
6
7
20、创建逻辑卷?
[root@node2 ~]# lsblk
[root@node2 ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.37.4).
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 (1 primary, 0 extended, 3 free) //主分区
e extended (container for logical partitions) //扩展分区
Select (default p): p
Partition number (2-4, default 2): 回⻋
First sector (1026048-20971519, default 1026048): 回⻋
***此处,分区⼤⼩,必须⼤于总⼤⼩,不可以刚好等于,建议多200M
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1026048-20971519, default
20971519): +1200M //分区⼤⼩
Created a new partition 2 of type ‘Linux’ and of size 1200 MiB.
Command (m for help): w //保存退出
The partition table has been altered.
Syncing disks.
[root@node2 ~]# vgcreate -s 16M qagroup /dev/vdb4
[root@node2 ~]# lvcreate -l 60 -n qa qagroup
[root@node2 ~]# yum provides */mkfs.vfat
[root@node2 ~]# yum -y install dosfstools
[root@node2 ~]# mkfs.vfat /dev/qagroup/qa
[root@node2 ~]# mkdir /mnt/qa
[root@node2 ~]# vim /etc/fstab
/dev/qagroup/qa /mnt/qa vfat defaults 0 0
[root@node2 ~]# mount -a
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
21、配置系统调优?
[root@node2 ~]# yum -y install tuned
[root@node2 ~]# systemctl enable tuned
[root@node2 ~]# systemctl restart tuned
[root@node2 ~]# tuned-adm active
[root@node2 ~]# tuned-adm recommend
检查
[root@node2 ~]# tuned-adm profile virtual-guest