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’;
理解清題目中的中英文姓名!!

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