RHCE--红帽考题题库(2020.07最后一次7版本考试)

初始化:两台服务器设置yum源
[root@desktopX ~]# vim /etc/yum.repos.d/yum.repo
[root@desktopX ~]# cat /etc/yum.repos.d/yum.repo
[yum] #yum名称
name=yum #描述信息
baseurl=ftp://server.rhce. cc/dvd #仓库路径
enabled=1
gpgcheck=0 #秘钥是否需要验证
[root@desktopX ~]# yum repolist #刷新yum仓库
[root@desktopX yum.repos.d]# scp yum.repo serverX:/etc/yum.repos.d/
——————————————————————————————————
1.配置SELinux
SELinux必须在两个系统desktopX和serverX中运行于Enforcing模式
[root@desktopX ~]# vim /etc/selinux/config #设置SELinux值
SELINUX=enforcing
[root@desktopX ~]# getenforce #查看SELinux值
Enforcing
[root@desktopX ~]# scp /etc/selinux/config serverX:/etc/selinux/
____________________________________________________________+
2.配置SSH访问
按以下要求配置SSH访问:
用户能够从域rhce .cc内的客户端通过SSH远程访问您的两个虚拟机系统
在域my133t.org内的客户端不能访问您的两个虚拟机系统
[root@desktopX ~]# host rhce.cc //先查看本机网段
[root@desktopX ~]# vim /etc/hosts. allow
[root@desktopX ~]# cat /etc/hosts allow
sshd:192.168.122.0/255.255.255.0
[root@desktopX ~]# vim /etc/hosts.deny
[root@desktopX ~]# cat /etc/hosts.deny
sshd…my133t.org
[root@desktopX ~]# scp /etc/hosts. allow serverX:/etc/
[root@desktopX ~]# scp /etc/hosts deny serverX:/etc/
___________________________________________________________+
3.自定义用户环境
在系统desktopX和serverX_上创建自定义命令名为qstat此自定义命令将执行以下命令:
/bin/ps-Aopid,tt,user,fname,rsz此命令对系统中所有用户有效。
[root@desktopX ~]# alias qstat=*/bin/ps -ao pid,tt,user,fname,rsz’
[root@desktopX ~]# qstat
PID TT USER COMMAND RSZ
2425 pts/0 root ps 1168
___________________________________________________________+
4配置端口转发
在系统desktopx配置端a转发,要求如下:
在192.168.122 0/24网络中的系统,访问desktopx 的本地端口5423将被转发到80此设置必须永久有效

[root@desktopX ~]# firewall-cmd --add-rich-rule ‘rule family=ipv4 source address= 192.168.122.0/24 forward-
port port=5423 protocol=tcp to-port=80’
success
[root@desktopX ~]# firewall-cmd --add-rich-rule ‘rule family=ipv4 source address=192. 168.122.0/24 forward-
port port=5423 protocol=tcp to-port=80’ --permanent
success
__________________________________________________+
5.配置聚合链路
在desktopX.rhce.cc和serverX.hce.cc之间按以下要求配置一个链路:
此链路使用接口eth1和eth2,此链路在一个接口失效时仍然能工作
此链路在desktopX使用下面的地址172.16.11.25/255 255.255.0
此链路在serverX使用下面的地址172.16.11.35/255.255.255.0
此链路在系统重启之后依然保持正常状态
[root@desktopX ~]# cd /usr/share/doc/teamd-1 .9/example
ifcfgs/1/
[root@desktopX 1]# cp * /etc/sysconfig/network-scripts/
[root@desktopX 1]# cd /etc/sysconfig/network-scripts/
[root@desktopX network-scripts]# cat ifcfg-team
test0
DEVICE="team
test0"
NAME="team
test0"
DEVICETYPE=“Team”
ONBOOT=“yes”
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR=172.16.11.25
TEAM
CONFIG=’“runner”: {“name’”: “activebackup”}’
[root@desktopX network-scripts]# cat ifcfg-eth1
DEVICE=“eth1”
NAME=“eth1”
DEVICETYPE=“TeamPort”
ONBOOT=“yes”
TEAM
MASTER="team
test0"
[root@desktopX network-scripts]# cat ifcfg-eth2
DEVICE=“eth2”
NAME=“eth2”
DEVICETYPE=“TeamPort”
ONBOOT=“yes”
TEAM
MASTER="team
test0"
[root@desktopX ~]# systemctl restart network
[root@desktopX ~]# scp /etc/sysconfig/network-scripts/ifcfg-team
test0 serverX:/etc/sysconfig/network-
scripts/
[root@desktopX ~]# scp /etc/sysconfig/network- scripts/ifcfg-eth1 serverX:/etc/sysconfig/network-scripts/
[root@desktopX ~]# scp /etc/sysconfig/network-scripts/ifcfg-eth2 serverX:/etc/sysconfig/network-scripts/
最后修改serverX:team
test文本ip, 重启服务,在用ping和ifconfig检测结果


6.配置IPv6地址
在您的考试系统上配置接口eth0使用下列IPv6地址:
desktopX.上的地址应该是200e:ac18::e0a/64 ; serverX. 上的地址应该是200e:ac18.:e14/64
两个系统必须能与网络200e:ac18/64内的系统通信,地址必须在重启后依旧生效。
两个系统必须保持当前的IPv4地址并能通信。
desktopX:先查看eth0设备对应连接名: nmcli connection
[root@desktopX ~]# nmcli connection modify eth0 ipv6.method auto
[root@desktopX ~]# nmcli connection modify eth0 ipv6. address 200e:ac8::e0a/64
[root@desktopX ~]# nmcli connection modify eth0 ipv6.method manual
[root@desktopX ~]# systemctl restart network
serverX:先查看eth0设备对应连接名: nmcli connection
[root@serverX ~]# nmcli connection modify eth0 ipv6.method auto
[root@serverX ~]# nmcli connection modify eth0 ipv6.address 200e:ac18:e14/64
[root@serverX ~]# nmcli connection modify eth0 ipv6 method manual
[root@serverX ~]# systemctl restart network
______________________________________________________________+
7.配置本地邮件服务
在系统desktopX和serverX.上配置邮件服务,满足以下要求:
这些系统不接收外部发送来的邮件,在这些系统上本地发送的任何邮件都会自动路由到rhgls.rhce.cc
从这些系统上发送的邮件显示来自于rhce.cc,您可以通过发送邮件到本地用户’dave’来测试您的配置
系统rhgls.rhce.cc已经配置把此用户的邮件转到下列URL http://rhgls.rhce .cc/received
mail/11
desktopX执行:
[root@desktopX ~]# firewall-cmd --add-service=smtp
[root@desktopX ~]# firewall-cmd --add-service=smtp --permanent
[root@desktopX postfix]# vim /etc/postfix/main.cf
vim main.cf中复制一-行mydestination, 编辑mydestination=""
vim main.cf中复制一-行relayhost, 编辑relayhost=[rhgls.rhce.cc]
vim main.cf中复制一-行myorigin, 编辑myorigin=rhce.cc
[root@desktopX postfix]# systemctl restart postix
[root@desktopX postfix]# yum install -y mailx
[root@desktopX postfix]# echo hello | mail -S “lyshark” dave
浏览器中打开ttp://rhgls.rhce.cc/received
mail/11打开邮件
发现成功以后直接拷贝到目标主机
[root@desktopX postfix]# scp main.cf serverX:/etc/postfix/
serverX执行:
[root@serverX postfix]# yum install -y mailx
[root@serverX ~]# firewall-cmd --add-service=smtp
[root@serverX ~]# firewall-cmd --add-service=smtp --permanent
[root@serverX ~]# systemctl restart postfix
[root@serverX ~]# echo “hello” I mail -s “Iyshark” dave
______________________________________________________________+
8.通过SMB共享目录
在desktopX_上配置SMB服务,您的SMB服务器必须是STAFF工作组的-一个成员
共享/common目录共享名必须为common,只有rhce.cc域内的客户端可以访问common共享
common必须是可以浏览的,用户andy必须能够读取共享中的内容,验证的密码是redhat
desktopX执行:
[root@desktopX ~]# yum install -y samba
[root@desktopX ~]# vim /etc/samba//smb.conf
workgroup = STAFF
[common]
path = /common
hosts allow = 192. 168.122.0/24
[root@desktopX ~]# firewall-cmd --add-service=samba
[root@desktopX ~]# firewall-c-mnd --add-service=samba --permanent
[root@desktopX ~]# mkdir /common
[root@desktopX ~]# chcon -R -t samba
share
_t /common/
[root@desktopX ~]# id andy //查询是否存在
[root@desktopX ~]# useradd andy
[root@desktopX ~]# yum whatprovides /smbpasswd
[root@desktopX ~]# yum install -y samba-client
[root@desktopX ~]# pdbedit -L //创建用户密码
[root@desktopX ~]# smbpasswd -a andy
New SMB password: redhat
[root@desktopX ~]# systemctl enable smb
[root@desktopX ~]# systemctl restart smb
serverX测试连通性: .
[root@serverX ~]# yum install -y samba-client
[root@serverX ~]# smbclient //desktopX/common _U andy%redhat
[root@serverX ~]# smbclient -L //desktopX/common _U andy%redhat
____________________________________________________________+
9.配置多用户SMB挂载
在desktopX共享通过SMB目录/miscellaneous满足以下要求:
共享名为miscellaneous,共享目录miscellaneous,只能被rhce cc域中的客户端使用
共享目录miscellaneous必须可以被浏览,用户silene必须能以读的方式访问此共享,访问密码是redhat
用户akira必须能以读写的方式访问此共享,访问密码是redhat, 此共享永久挂载在serverX.rhce.cc上
的/mnt/multi目录
并使用用户silene作为认,证任何用户可以通过用户akira来临时获取写的权限
desktopX_上执行:
[root@desktopX ~]# mkdir /miscellaneous
[root@desktopX ~]# chcon -R -t samba
share
t /miscellaneous/
[root@desktopX ~]# vim /etc/samba/smb.conf
[miscellaneous] //追加写入
path = /miscellaneous
hosts allow=192.168.122.0/24
writable = no
write list = akira
[root@desktopX ~]# chmod o+rWx /miscellaneous/
[root@desktopX ~]# useradd silene
[root@desktopX ~]# useradd akira
[root@desktopX ~]# smbpasswd -a silene
New SMB password: redhat
[root@desktopX ~]# smbpasswd -a akira
New SMB password: redhat
[root@desktopX ~]# systemctl restart smb
serverX_上验证结果:
[root@serverX ~]# smbclient //desktopX/miscellaneous _∪silene%redhat测试读权限
[root@serverX ~]# smbclient //desktopX/miscellaneous _∪akira%redhat测试写权限
[root@serverX ~]# mkdir /mnt/multi
[root@serverX ~]# smbclient /desktopX/miscellaneous -U silene%redhat
[root@serverX ~]# vim /etc/fstab //写入开机自动挂载
//desktopX/miscellaneous /mnt/multi cifs defaults,username=silene ,password=redhat,multiuser, sec=ntlmssp
00
[root@serverX ~]# yum install -y cifs-utils
[root@serverX ~]# mount -a
[root@serverX ~]# df -h
文件系统容量已用可用已用%挂载点
//desktopX/miscellaneous 3.9G 1.3G 2.7G 32% /mnt/multi
创建用户tom1 tom2用于测试属性分配是否正常
[root@serverX ~]# useradd tom1
[root@serverX ~]# useradd tom2
[root@serverX ~]# su - tom1
[tom1 @serverX ~]$ cd /mnt/multi
[tom1@serverX multi]$ cifscreds add desktopX -U silene
Password: redhat //测试有无读取权限
[tom1@serverX multi]$ exit
[root@serverX ~]# su - tom2
[tom2@serverX ~]$ cd /mnt/multi
[tom2@serverX multi]$ cifscreds add desktopX -u akira
Password: redhat //测试有无写权限
[tom2@serverX multi]$ exit
____________________________________________________________+
10.配置NFS服务
在desktopX配置NFS服务,要求如下:
以只读的方式共享目录/public同时只能被rhce.cc域中的系统访问,以读写的方式共享目录/protected能被
rhce.cc域中的系统访问
访问/protected需要通过Kerberos安全加密,您可以使用下面URL提供的密钥
http://host.rhce. cc/materials/nfs
server.keytab
目录/protected应该包含名为confidential拥有人为Idapuser11的子目录,用户Idapuser11以读写方式访
问/protected/confidential
desktopX.上执行:
[root@desktopX ~]# systemctl restart nfs-server
[root@desktopX ~]# systemctl enable nfs-server
[root@desktopX ~]# firewall-cmd --add-rich-rule “rule family=ipv4 source address=192. 168.122.0/24 service
name=nfs accept”
[root@desktopX ~]# firewal-cmd --add-rich-rule “rule family=ipv4 source address=192. 168.122.0/24 service
name=nfs accept” --permanent
[root@desktopX ~]# firewall-cmd --add-rich-rule “rule family=ipv4 source address= 192.168.122.0/24 service
name=rpc-bind accept”
[root@desktopX ~]# firewall-cmd --add-rich-rule “rule family=ipv4 source address=192.168. 122.0/24 service
name=rpc-bind accept” --permanent
[root@desktopX ~]# firewall-cmd --add-rich-rule “rule family=ipv4 source address= 192. 168.122.0/24 service
name=mountd accept”
[root@desktopX ~]# firewall-c-mnd --add-rich-rule “rule family=ipv4 source address=192. 168.122.0/24 service
name=mountd accept” --permanent
[root@desktopX ~]# mkdir /public
[root@desktopX ~]# cat /etc/exports
/public *(ro,sync)//写入属性
[root@desktopX ~]# exportfs -arv
exporting *:/public
在serverX_上测试:
[root@serverX ~]# showmount -e desktopX
Export list for desktopX:
/public *
[root@serverX ~]# mount desktopX:/public /mnt
确认没问题后再卸载掉umount /mnt
继续共享第二个目录desktopX:
[root@desktopX ~]# mkdir /protected
[root@desktopX ~]# cat /etc/exports
/public *(ro,sync)
/protected *(rw,sync,sec=krb5p)
[root@desktopX ~]# exportfs -arv
exporting *:/protected
exporting *:/public
下载证书并配置: .
[root@desktopX ~]# wget -O /etc/krb5.keytab http://host.rhce.cc/materials/nfs
server.keytab
[root@desktopX ~]# cat /etc/sysconfig/nfs找到rpcnfsdargs="V 4.2”
[root@desktopX ~]# mkdir /protected/confidential
[root@desktopX ~]# chcon -R -t public
content
_t /protected/
[root@desktopX ~]# chown Idapuser11 /protected/confidential
[root@desktopX ~]# systemctl restart nfs-server
[root@desktopX ~]# systemctl restart nfs-secure-server
______________________________________________________________+
11.挂载一个NFS共享
在serverX.上挂载一个来自desktopX.rhce cc的NFS共享,并符合下列要求:
/public挂载在下面的目录上/mnt/nfsmount,/protected挂载在 下面的目录上/mnt/nfssecure并使用安全的方

密钥下载URL如下: http://host.rhce .cc/materials/nfs
client.keytab.
用户ldapusre11能够在/mntnfssecure/confidential.上创建文件,这些文件系统在系统启动时自动挂载
[root@serverX ~]# showmount -e desktopX
[root@serverX ~]# mkdir /mnt/nfsmount
vim /etc/fstab中添加desktopX .rhce.cc:/public /mnt/nfsmount nfs defaults 0 0
[root@serverX ~]# mount -a //检查是否挂载成功
[root@serverX ~]# df -h
[root@serverX ~]# mkdir /mnt/nfssecure
[root@serverX ~]# wget -O /etc/krb5.keytab htp://host.rhce .cc/materials/nfs
_client.keytab
[root@serverX ~]# systemctl restart nfs-secure
vim /etc/fstab中添加desktopX.rhce cc:/protected /mnt/nfssecure nfs defaults,v4.2,sec=krb5p 0 0
[root@serverX ~]# mount -a
[root@serverX ~]# ssh [email protected]验证
________________________________________________________________+
12.配置web站点
desktopX.上配置一个站点http://desktopX.rhce.cc然后执行 下述步骤:
h从ttp://rhgls .rhce cc/materials/station.html下载文件
并且将文件重命名为index.html不要修改此文件的内容
将文件index.html拷贝到您的web服务器的DocumentRoot目录下
来自于rhce.cc域的客户端可以访问此Web服务,来自于my133t.org域的客户端拒绝访问此Web服务
[root@desktopX ~]# yum groupinstall web
-y
[root@desktopX ~]# firewall-cmd --add-rich-rule “rule family=ipv4 source address=192. 168.122.0/24 service
name=http accept”
[root@desktopX ~]# firewall-cmnd --add-rich-rule “rule family=ipv4 source address=192.168. 122.0/24 service
name=http accept” --permanent .
[root@desktopX ~]# vim /etc/httpd/conf/httpd. conf
ServerName desktopX.rhce .cc:80取消注释
[root@desktopX ~]# vim /etc/hosts
192.168.122.100 desktopX.rhce.cc写入以下条目
[root@desktopX ~]# wget -O /var/www/html/index.html http://rhgls .rhce. cc/materials/station.html
[root@desktopX ~]# systemctl restart httpd
[root@desktopX ~]# systemctl enable httpd
________________________________________________________________+
13.配置安全web服务
为站点ttp://desktopX.rhce.cc配置TLS加密一个已签名证书从
http://host.thce. cc/materials/desktopX.crt获取此证书的密钥从
http://host.rhce.cc/materials/desktopX key获取此证书的签名授权信息从
http://host.rhce. cc/materials/domain11.crt获取
[root@desktopX ~]# cd /etc/httpd/conf
[root@desktopX conf]# wget http://host.rhce cc/materials/desktopX.crt
[root@desktopX conf]# wget http://host.rhce.cc/materials/desktopX.key
[root@desktopX conf]# wget htp://hos/t.rhce. cc/materials/domain11.crt
[root@desktopX conf]# vim /etc/httpd/conf.d/ssl.conf
依次修改配置项
SSLCertificateFile /etc/httpd/conf/desktopX .crt
SSLCertificateKeyFile /etc/httpd/conf/desktopX.key
SSL CertificateChainFile /etc/httpd/conf/domain11.crt
[root@desktopX ~]# systemctl restart httpd
[root@desktopX ~]# firewall-cmd --add-rich-rule "rule family=ipv4 source address= 192.168.122.0/24 service
name=https accept"ss
[root@desktopX ~]# firewall-cmd --add-rich-rule “rule family=ipv4 source address=192.168. 122.0/24 service
name=https accept” --permanent
________________________________________________________________+
14.配置虚拟主机
在desktopX.上扩展您的web服务器,为站点ttp://www.rhce.cc创建一 个虚拟主机, 执行步骤:设置
DocumentRoot为/var/www/virtual
h从ttp://rhgls. rhce cc/materials/www.html下载文件并重命名为index.html不要对文件index.html的内容做任何
修改
将文件index.html放到虚拟主机的DocumentRoot目录下确保andy用户能够在/var/www/virtual目录下创建文件
注意:原始站点ttp://desktopX .rhce .cc必须仍然能够访问,名称服务器rhce. cc提供对主机名www.rhce.cc的
域名解析
[root@desktopX ~]# mkdir Ivar/www/virtual
[root@desktopX ~]# wget -0 /var/www/virtual/index.html htp://rhgls.rhce cc/materials/www.html
[root@desktopX ~]# setfacl -m u:andy:rwx /var/www/virtual
[root@desktopX ~]# cd /etc/httpd/conf.d/拷贝模板文件
root@desktopX conf.d]# cp -a /usr/share/doc/httpd-2 .4.6/httpd-vhosts.conf vhost.conf
[root@desktopX conf.d]# vim vhost.conf


19.配置iSCSI服务端
配置desktopX提供一个iSCSI服务磁盘名为iqn.2014-09. com. example .domain11:desktopX,
并符合要求:服务端口为3260,使用iscsi vol作其后端卷其大小为3G,此服务只能被serverX.rhce.cc访问
[root@desktopX ~]# yum install -y target*
[root@desktopX ~]# systemctl restart target
fdisk /dev/vda创建3G分区
partprobe /dev/vda
targetcli后Is/
/backstores/block create iscsi
vol /dev/vda4
/iscsi create iqn.2014-09.com.example.domain11:desktopX
cd /iscsi/iqn.2014-09.com.example.domain11:desktopX/tpg1/
acls/ create iqn.2014-09.com.example.domain11:xx
luns/ create /backstores/blockliscsi
vol Is 1
portals/ create 0.0.0.0 3260 exit
设置防火墙并重启服务(systemctl restart firewalld)
________________________________________________________________+
20.配置iSCSI的客户端
配置serverX使其能连接在desktopX的_上提供的iqn.2014-09.com.example .domain11:desktopX

并符合以下要求:
iSCSI设备在系统启动的期间自动加载
块设备iSCSI上包含一个大小为1700MiB的分区,并格式化为xfs
此分区挂载在/mnt/data_上同时在系统启动的期间自动挂载
yum install iscsi* -y
vim /etc/iscsi/initiatorname.iscsi中将=后面值修改成iqn.2014-09.com.example.domain11:xx
systemctl start iscsid
systemctl enable iscsid
iscsiadm -m discovery -t st -p desktopX .rhce.cc-I
创建一个1700m的分区, 格式化mkfs .xfs /dev/vda?
自动挂载vim /etc/fstab中添加一-行
/dev/sda? /mnt/data xfs defaults, netdev0 0
mkdir /mnt/data
mount -a检查结果
________________________________________________________________+
21、配置一个数据库
在desktopX 上创建一个mariadb 数据库, 名为contacts ,并符合以下条件:
数据库应该包含来自数据库复制的内容,复制文件的url 为
http://rhgls.rhce.cc/materials/users.mdb 。
数据库只能被localhost 访问。
除了root 用户, 此数据库只能被用户luigi 查询。此用户密码为redhat。
root 用户的密码为redhat ,同时不允许空密码登录。
yum install mariadb-server mariadb –y
systemctl start mariadb
systecmctl enable mariadb
进入mysql show databases;
create database contacts;
show databases;
退出后wget http://rhgls.rhce.cc/materials/users.mdb
登陆数据库mysql
use contacts;
source /root/users.mdb(下载的文件路径)
show tables; 查看
grant select on contacts.* to luigi@’localhost’ identified by ‘redhat’;
set password=password(‘redhat’)
退出后在连接数据库:quit mysql
_________________________________________________________________-
22、数据库查询
在系统desktopX 上使用数据库contacts ,并使用相应的sql 查询以回答下列问题:
密码是tangerine 的人的名字?
有多少人的姓名是John 同时居住在Santa Clara?
mysql –uroot –predhat
use contacts;
show tables;
desc loc;
desc name;
desc pass;
select * from name join pass where name.aid=pass.bid;
select * from name join pass where name.aid=pass.bid and password=’ tangerine ’;
select * from name join loc where name.aid=loc.cid;
select * from name join loc where name.aid=loc.cid and firstname= ’John’ and loction=’Santa Clara’;
select count(*) from name join loc where name.aid=loc.cid and firstname=’John’ and loction=’ santa clara’;
理解清题目中的中英文姓名!!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章