RHCE7.0練習題匯總38
RHCSA部分
關於密碼破解,在上午的考試中需要我們自己安裝圖形化界面和破解root密碼,root的密碼按照題目的要求來進行修改。可以使用單用戶模式或者使用上課講的re.break都可以。
re.break方法:
刪除 console=ttys0,115200n8這句話 在最后加入rd.break
進入交換模式以后輸入下列指令:
1
2
3
4
5
|
mount
-o remount,rw
/sysroot
chroot
/sysroot
passwd
#密碼
touch
/.autorelabel
reboot
|
init方法估計在考試的虛擬機中無法使用,可能是我的打開方式不對吧。
圖形化界面安裝:
考試的時候可能需要自己安裝圖形化界面,如果在startx無法啟動圖形化的情況下可以是下面的命令進行安裝:
1
2
3
4
|
yum –y
install
xorg*
yum –y
install
gnome*
yum –y
install
glx*
startx
#or init 5
|
密碼修完完成,注意此處是修改的你考試用的虛擬機密碼,而不是物理機密碼。 關於IP地址的設置,請查看考題的其他信息里面可以看到虛擬機應該設置的IP地址信息,和主機名信息。
1
2
3
4
5
6
7
|
hostnamectl
set
-
hostname
station.domain11.example.com
nmcli connection modify eno16777736 ipv4.method manual
nmcli connection modify eno16777736 ipv4.addresses
'172.24.11.10/24 172.24.11.254'
nmcli connection modify eno16777736 ipv4.dns
'172.24.11.250'
nmcli connection up eno16777736
nmcli con show eno16777736 |
grep
ipv4
host server.domain11.example.com
route -n
|
IP地址也可以使用nm-connection-editor圖形化界面進行修改。
修改完成以上信息以后就可以開始正式做題了。
1. 配置SELINUX使其工作在enforcing模式下
1
2
3
4
5
|
getenforce
#查看模式
setenforce 1
#設置為enforcing模式
getenforce
#查看
vim
/etc/selinux/config
#永久修改
selinux=enforcing
|
然后使用sestatus命令查看
2. 為您的系統配置一個默認的軟件倉庫
一個YUM 源已經提供了在http://server.domain11.example.com/pub/x86_64/Server,配置你的系統,並且能正常使用。
1
2
3
4
5
6
|
vim
/etc/yum
.reopos
/base
.repo
[base]
name=base
baseurl= http:
//server
.domain11.example.com
/pub/x86_64/Server
gpgcheck=0
enable
=1
|
yum list進行驗證,能列出軟件包信息就是正確的。Yum 配置不正確會導致后面一些題目做不出來。
3. 調整邏輯卷的大小
調整邏輯卷vo的大小,它的文件系統大小應該為290M.確保這個文件系統的內容完整。注:分區很少能精確到和要求的大小相同,因此在范圍270M到320M之間都是可以接受的
解法—加法
1
2
3
4
5
|
df
–hT
lvextend -L +100M
/dev/vg0/vo
lvscan
xfs_growfs
/home/
#home為LVM掛載的目錄 這步僅僅是在我們練習的環境中需要做,考試的時候是EXT4不需要此步驟。
resize2fs
/dev/vg0/vo
#考試的時候用這條命令進行更新就可以了。 df –hT
|
解法—減法
1
2
3
4
5
6
|
e2fsck –f
/dev/vg0/vo
umount
/home
resize2fs
/dev/vg0/vo
#最終要求的分區容量 如100M
lvreduce –l 100M
/dev/vg0/vo
mount
/dev/vg0/vo
/home
df
-hT
|
4. 創建用戶賬號
創建下面的用戶、組和組成員關系
名字為adminuser 的組
用戶natasha,使用adminuser 作為附屬組
用戶harry,也使用adminuser 作為附屬組
用戶sarah,在系統商不能訪問可交互的SHELL,且不是adminuser 的成員,natasha,harry,sarah密碼都是redhat
1
2
3
4
5
6
|
groupadd adminuser
useradd
natasha –G adminuser
useradd
haryy –G adminuser
useradd
sarah –s
/sbin/nologin
passwd
用戶名
#來修改密碼
id
natasha
#查看用戶組
|
5. 配置/var/tmp/fstab的權限
復制文件/etc/fstab到/var/tmp/fstab
配置/var/tmp/fstab的權限如下:
文件/var/tmp/fstab所有者是ROOT
文件/var/tmp/fstab屬於root組
文件/var/tmp/fstab不能被任何用戶執行
用戶natasha可讀和可寫/var/tmp/fstab
用戶harry不能讀寫/var/tmp/fstab
所有其他用戶(現在和將來的)具有讀/var/tmp/fstab的能力。
1
2
3
4
|
cp
/etc/fstab
/var/tmp/
ll
/var/tmp/fstab
#查看所有者
setfacl –m u:natasha:rw-
/var/tmp/fstab
setfacl –m u:haryy:---
/var/tmp/fstab
|
使用getfacl /var/tmp/fstab查看權限
6. 配置一個cron任務
用戶natasha必須配置一個cron job,當地時間每天14:23運行,執行: */bin/echo hiya
1
2
3
|
crontab
–e –u natasha
23 14 * * *
/bin/echo
hiya
crontab
–l –u natasha
#查看
|
7. 創建一個共享目錄
創建一個共享目錄/home/admins,使之具有下面的特性:
/home/admins 所屬組為adminuser
這個目錄對組adminuser的成有具有可讀、可寫和可執行。
在/home/ admins創建的任何文件所屬組自動設置為adminuser。
1
2
3
4
|
mkdir
/home/admins
chgrp
-R adminuser
/home/admins
chmod
g+w
/home/admins
chmod
g+s
/home/admins
|
8. 安裝內核的升級
從http://server.domain11.example.com/pub/updates安裝適合的內核更新。下面的要求必須滿足:
更新的內核作為系統啟動的默認內核
原來的內核在系統啟動的時候依然有效和可引導
使用瀏覽器打開題目給的網址,並下載內核文件,到根或者家目錄。
1
2
3
|
uname
-r
#查看當前內核版本
rpm –ivh kernel-*.rpm
vi
/boot/grub/grub
.conf
#查看
|
9. 綁定到外部驗證服務器
系統server.domain11.example.com提供了一個LDAP的驗證服務,你的系統應該接下面的要求綁定到這個服務:
驗證服務的基准DN是dc=example,dc=com
LDAP用於提供賬戶信息和驗證信息
連接應用使用位子
http://server.domain11.example.com/pub/EXAMPLE-CA-CERT的證書加密 當正確的配置后,ldapuser1可以登錄你的系統,但是沒有HOME目錄,直到你完成autofs題目的ldapuser1的密碼是password
1
2
|
yum -y
install
auth*
system-config-authentication
|
將user account database 修改為ldap,根據題目要求填寫 DN和LDAP SERVER,use TLS to encrypt connections打鈎,在download ca 中寫入 http://server.domain11.example.com/pub/EXAMPLE-CA-CERT。authentication metod選擇ldap password。
Id ldapuser1 查看有沒有學習到用戶
注:這題中只要能學習到用戶即可,用戶密碼不需要設置。
10. 配置NTP
配置你的系統使它server.domain11.example.com的一個NTP用戶
System-config-date 需安裝
Synchronize date and time over the network 打鈎
刪除默認的NTP server
添加一個NTP server 地址為:server.domain11.example.com
11. 配置autofs
配置autofs自動掛在LDAP用戶的家目錄,如下要求
server.domain11.example.com使用NFS共享了home給你的系統。這個文件系統包含了預先配置 好的用戶ldapuserX的home目錄
ldapuserX的home目錄是
server.domain11.example.com /home/guests/ldapuser
ldapuserX的home目錄應該自動掛載到本地/home/guests下面的ldapuserX home目錄必須對用戶具有可寫權限
ldapuser1的密碼是password
1
2
3
4
5
6
7
8
9
|
yum
install
–y autofs
mkdir
/home/rehome
vi
/etc/auto
.master
/home/rehome
/etc/auto
.ldap
cp
/etc/auto
.misc
/etc/auto
.ldap
vi
/etc/auto
.ldap
ldapuserX -fstype=nfs,rw server.domain11.example.com:
/home/guests/
systemctl start autofs
systemctl
enable
autofs
|
su – ldapuserX 測試
如果以上寫法在考試的時候無法創建文件或者命令提示符是-bash-4.2$這樣的話可能存在多級目錄也需要將server.domain11.example.com:/home/guests/
的寫法變為server.domain11.example.com:/home/guests/ldapuserX就可以了。何為多級目錄也就是題目給的/home/guests/ldapuserX下面還有一個ldapuserX的目錄這個目錄才是真正的目錄。
12. 配置一個用戶賬號
創建一個用戶iar,uid是3400.這個用戶的密碼是redhat
1
2
|
useradd
–u 3400 iar
passwd
iar
|
13. 添加一個swap分區
為你的系統額外添加一個大小為500M的交換分區,這個交換分區在系統啟動的時候應該能自動掛載。不要移除和修改你系統上現有的交換分區。 解法:
fdisk –cu /dev/vda 以擴展分區的方式來做,不要做主分區。
1
2
3
4
5
6
7
|
partx –a
/dev/vda
mkswap
/dev/vdax
swapon
/dev/vdax
swapon –s
vi
/etc/fstab
/dev/vdax
swap swap defaults 0 0
mount
-a
|
14. 查找文件
找到所有者是iar的文件,並把題目拷貝到/root/findresults目錄
useradd iar 可以使用id iar 看是否有用戶,有則不需要創建
1
2
3
|
mkdir
/root/findresults
find
/ -user iar –
exec
cp
-rfp {}
/root/findresults
\;
ls
/root/findresults
|
15. 查找一個字符串
在/usr/share/dict/words內找出所有包含字符串seismic的列,然后把這些列依照原來的次序拷貝到/root/lines.txt內,在此檔內不存在空行,所有的行必須是/usr/share/dict/words中原有行的精確復制。
grep seismic /usr/share/dict/words > /root/lines.txt
16. 創建名為/root/backup.tar.bz2的備份文件,其中包含/usr/local的內容,tar必須使用bzip2壓縮。
1
2
3
4
|
cd
/usr/local
tar
–jcvf
/root/backup
.
tar
.bz2 *
mkdir
/test
tar
–jxvf
/root/backup
.
tar
.bz2 –C
/test/
解壓看下類容是不是和
/usr/local
里面的一樣
|
如果題目要求使用gzip壓縮就把-j換成-z即可
17. 創建一個邏輯卷
按照下面的要求創建一個新的邏輯卷
邏輯卷的命名為database,屬於卷組的datastore,且大小為50個PE。 在卷組datastore的邏輯卷每個擴展的大小為16MB
使用ext3格式化這個新的邏輯卷,此邏輯卷在系統啟動的時候應該自動掛載到/mnt/database
1
2
3
4
5
6
7
8
9
10
11
12
|
fdisk
–cu
/dev/vda
#創建一個1G的分區根據情況修改
partx –a
/dev/vda
pvcreate
/dev/vdax
vgcreate datastore
/dev/vdax
–s 16M
lvcreate – l 50 –n database datastore
mkfs.ext3
/dev/datastore/database
mkdir
/mnt/database
mount
/dev/datastore/database
/mnt/database/
df
–Th
vi
/etc/fstab
/dev/datastore
/database
/mnt/database/
ext3 defaults 0 0
mount
–a
|
重啟檢查所有題目要求。
RHCE部分
1. 配置SELINUX
修改selinux的狀態為Enforcing模式
1
2
3
4
5
6
7
|
vim
/etc/selinux
getenforce
#查看當前SELINUX模式
setenforce 1
#將selinux臨時這只為enforcing模式
vim
/etc/selinux/config
SELINUX=enforcing
getenforce
enforcing
|
2. 配置SSH訪問
按以下要求配置SSH訪問:
1.用戶能夠從域group3.example.com內的客戶端通過SSH遠程訪問您的兩個虛擬機系統
2.在域my133t.org內的客戶端不能訪問您的兩個虛擬機系統
修改/etc/hosts.allow文件
添加一行 sshd: 172.24.11.
修改/etc/hosts.deny文件
添加一行 sshd: 172.25.0.
兩台都需要配置
添加防火牆策略
firewall-cmd –zone=block –add-source=172.25.11.0/24 –permanent firewall-cmd –reload
兩台都需要配置
3. 自定義用戶環境:
在系統 system1 和 system2 上創建自定義命名名為 qstat 此自定義命令將執行以下命令:
/bin/ps – Ao pid,tt,user,fname,rsz
此命令對系統中所有用戶有效
1
2
3
4
5
|
vim
/etc/bashrc
#重啟保持有效
alias
qstat=’
/bin/ps
–Ao pid,tt,user,fname,rsz’
source
/etc/bashrc
alias
#看是否有qstat
qstat
#執行
|
兩台都要做
4. 配置端口轉發
在系統system1 配置端口轉發,要求如下:
1. 在172.24.11.0/24網絡中的系統,訪問system1的本地端口5423將被轉發到80
2. 此設置必須永久有效
使用圖形化界面進行配置
在CLI中使用firewall-config 開啟圖形化界面
將configuration:下拉菜單調整為permanent
在public區域中的port forward中添加一個策略
systemctl restart firewalld.service 重裝載防火牆策略
5. 配置鏈路聚合
在systeml. group3.example.com和system2. group3.example.com之間按以下要求配置一個鏈路:
1. 此鏈路使用接口eth1和eth2
2. 此鏈路在一個借口失效時仍然能工作
3. 此鏈路在systeml使用下面的地址172.16.3.20/255.255.255.0
4. 此鏈路在system2使用下面的地址172.16.3.25/255.255.255.0
5. 此鏈路在系統重啟之后依然保持正常狀態
如果不記得name如何寫可以在/var/share/doc/team-1.9/example_configs/查看例子。
1
2
3
4
5
6
7
8
|
nmcli connection add con-name team0
type
team ifname team0 config
'{"runner":{"name":"activebackup"}}'
nmcli con modify team0 ipv4.addresses
'172.16.11.25/24'
nmcli connection modify team0 ipv4.method manual
nmcli connection add
type
team-slave con-name team0-p1 ifname eth1 master team0
nmcli connection add
type
team-slave con-name team0-p2 ifname eth2 master team0
nmcli connection up team0
nmcli con up team0-p1
nmcli con up team0-p2
|
6. 配置IPV6地址
在您的考試系統上配置接口eth0 使用下列IPV6地址:
1. system1上的地址應該是2003:acl8::305/64
2. system2上的地址應該是2003:acl8::30a/64
3. 兩個系統必須能與網絡2003:acl8/64內的系統通信
4. 地址必須在重啟后依然生效
5. 兩個系統必須保持當前的IPV4地址並能通信
1
2
3
4
5
6
7
|
nmcli con mod eth0 ipv6.addresses “2003:ac18::305
/64
”
nmcli con mod eth0 ipv6.method manual
systemctl restart network
nmcli con mod eth0 ipv6.addresses “2003:ac18::30a
/64
”
nmcli con mod eth0 ipv6.method manual
systemctl restart network
ping6 2003:ac18::30a
|
7. 配置本地郵件服務
在系統 system1 和 system2 上配置郵件服務,滿足以下要求:
1.這些系統不接受外部發送來的郵件
2.在這些系統上本地發送的任何郵件都會自動路由到rhgls.domain11.example.com
3.從這些系統上發送的郵件顯示來自於rhgls.domain11.example.com
4.您可以通過發送郵件到本地用戶’authur’來測試您的配置,系統rhgls.domain11.example.com
5.已經配置把此用戶的郵件轉到下列URL rhgls.domain11.example.com/received_mail/11
1
2
3
4
5
6
|
postconf -e local_transport=err:XX
vim
/etc/postfix/main
.cf
relayhost=[rhgls.domain11.exmaple.com]
postconf -e myorigin=domain11.example.com
systemctl restart postfix
echo
aaa | mail -S hello dave
|
在瀏覽器中打開rhgls.domain11.example.com/received_mail/11
8.通過SMB共享目錄
在system1上配置SMB服務
您的SMB服務器必須是STAFF工作組一個成員
共享 /common 目錄共享名必須為common
只有domain11.example.com域內的客戶端可以訪問common共享
common必須是可以瀏覽的
用戶andy必須能夠讀取共享中的內容,需要需要的話,驗證密碼是redhat 解法:
system1:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
yum -y
install
samba samba-client
firewall-cmd --add-service=samba --permanent
firewall-cmd --add-service=mountd –permanent
systemctl restart firewalld
vim
/etc/samba/smb
.conf
workgroup = STAFF
[common]
path =
/common
hosts allow = 172.24.11.
browseable =
yes
mkdir
/common
chcon –R –t samba_share_t
/common/
smbpasswd -a andy
systemctl start smb
systemctl
enable
samba
|
system2:
1
|
yum
install
–y cifs-utils samba-client
|
9. 配置多用戶SMB掛載
在systeml共享通過SMB目錄/devops滿足下列要求:
1.共享名為devops
2.共享目錄devops只能被domain11.example.com域中的客戶端使用
3.共享目錄devops必須可以被瀏覽
4.用戶silene必須能以讀的方式訪問此共享,訪問密碼是redhat
5.用戶akira必須能以讀寫的方式訪問此共享,訪問密碼是redhat
6.此共享永久掛載在system2. domain11.example.com上的/mnt/dev用戶,並使用用戶silene作為認證任何用戶可以通過用戶akira來臨時獲取寫的權限 解法:
system1:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
mkdir
/devops
chcon -R -t samba_share_t
/devops/
chmod
o+w
/devops/
vim
/etc/samba/smb
.conf
[devops]
path =
/devops
hosts allow = 172.24.11.
browseable =
yes
writable = no
write list = akira
systemctl restart smb
smbpasswd -a silene
smbpasswd -a akira
|
system2:
1
2
3
4
5
|
mkdir
/mnt/dev
smbclient -L
/system1/
-U silene
vim
/etc/fstab
/system1/devops
/mnt/dev
cifs defaults,multiuser,username=silene,password=redhat,sec=ntlmssp 0 0
df
–hT
|
在system2上切換到akira用戶,進入到/mnt/dev下 查看文件
1
2
3
4
|
su
akira
cd
/mnt/dev
cifscreds add system1
touch
1
|
10. 配置NFS服務
在system1配置NFS服務,要求如下:
1.以只讀的方式共享目錄/public同時只能被domain11.example.com域中的系統
2.以讀寫的方式共享目錄/protected需要通過Kerberos安全加密,您可以使用下面URL提供的密鑰http://host.domain11.example.com/materials/nfs_server.keytab
3.目錄/protected應該包含名為project.擁有人為deepak的子目錄
4.用戶deepak能以讀寫方式訪問/protected/project
system1:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
vim
/etc/exports
/protected
172.24.11.0
/24
(rw,
sync
,sec=krb5p)
/public
172.24.11.0
/24
(ro,
sync
)
wget -O
/etc/krb5
.keytab
vim
/etc/sysconfig/nfs
RPCNFSDARGS=
"-V 4.2 "
systemctl restart nfs
systemctl start nfs-secure-server
systemctl
enable
nfs-secure-server
exportfs –ra
showmount –e
firewall-cmd --add-service=nfs –permanent
firewall-cmd --add-service=rpc-bind –permanent
firewall-cmd --add-service=mountd–permanent
systemc tl restart fiewalld
mkdir
-p
/protected/project
chown
deepak
/protected/project/
ll
/protected/
chcon -R -t public_content_t
/protected/project/
|
11. 掛載一個NFS共享
在system2上掛載一個system1.domain11.example.com的NFS共享,並符合下列要求:
1、/public掛載在下面的目錄上/mnt/nfsmount
2、/protected掛載在下面的目錄上/mnt/nfssecure並使用安全的方式,密鑰下載URL如下:/materials/nfs_client.keytab
3、用戶deepak能夠在/mnt/nfssecure/project上創建文件
4、這些文件系統在系統啟動時自動掛線
system2:
1
2
3
4
5
6
7
8
9
10
|
showmount -e system1
mkdir
-p
/mnt/nfsmount
vim
/etc/fstab
system1:
/public
/mnt/nfsmount
nfs defaults 0 0
mount
–a
mkdir
/mnt/nfssecure
wget -O
/etc/krb5
.keytab
vim
/etc/fstab
system1:
/protected
/mnt/nfssecure
nfs defaults,sec=krb5p,v4.2 0 0 :wq
mount
-a
|
12. 實現一個 web 服務器
在 system1 上配置一個站點 http://systeml. domain11.example.com/ 執行下述步驟:
1、 從 http://. domain11.example.com/materials/station.html
2、 下載文件,並且將文件重名為 index.html 不要修改此文件的內容
3、 將文件 index.html 拷貝到您的 web服務器的 DocumentRoot 目錄下
4、 來自於 group3.example.com 域的客戶端可以訪問此web服務
5、 來自於 my133t.org域的客戶端拒絕訪問此web服務
1
2
3
4
5
6
7
8
9
10
|
yum groupinstall web\* -y
systemctl start httpd
systemctl
enable
httpd
vim
/etc/httpd/conf/httpd
.conf
/ServerName
ServerName server1.domain11.example.com:80
systemctl restart httpd
wget -O index.html
firewall-config 然后
systemctl restart firewalld
|
13. 配置安全web服務
為站點http://systeml.domain11.example.com配置TLS加密一個已簽名證書從http: //host.domain11.example.com/materials/system1.crt獲取 此證書的密鑰從http://host.domain11.example.com/materials/system1.key獲取 此證書的簽名授權信息從http://host.domain11.example.com/materials/domain11.crt獲取
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<virtualhost *:80>
documentroot
/var/www/html
servername system1.domain11.example.com
<
/virtualhost
>
<virtualhost *:443>
documentroot
/var/www/html
servername system1.domain11.example.com
SSLEngine on
SSLCertificateFile
/etc/pki/tls/certs/server1
.crt
SSLCertificateKeyFile
/etc/pki/tls/private/server1
.key
SSLCertificateChainFile
/etc/pki/tls/certs/domain11
.crt
<virtualhost>
systemctl restart httpd
firewall-cmd --add-service=https –permanent
systemctl restart firewalld
|
14:配置虛擬主機
在system1 上擴展您的web服務器,為站點創建一個虛擬主機,然后執行下述步驟:
1.設置DocumentRoot為/var/www/virtual
2.從 http://rhgls.domain11.example.com/materials/www.html
3.下載文件重名為index.html 不要對文件index.html 中的內容做任何修改
4.將文件index.html 放到虛擬主機的DocumentRoot的目錄下
5.確保andy用戶能夠在/var/www/virtual目錄下創建文件
注意:原始站點http://systeml.domian11.example.com/ 必須仍然能夠訪問,名稱服務器domain11.example.com提供對主機名www.domain11.example.com的域名解析。
1
2
3
4
5
6
7
8
9
10
|
mkdir
–p
/var/www/
virtual
cd
/var/www/
virtual
wget –O index.html vim
/etc/httpd/conf/httpd
.conf
<virtualhost *:80>
documentroot
/var/www/virtual
servername www.domain11.example.com
<
/virtualhost
>
setfacl -m u:andy:rwx
/var/www/virtual
su
andy
touch
/var/www/virtual/11
.html
|
15. 配置web內容的訪問
在您的system1 上的web服務器的DocumentRoot目錄下 創建一個名為private的目錄,要求如下:
1.從http://rhgls.domain11.example.com/materials/private.html 下載一個文件副本到這個目錄,並且重命名為index.html.
2.不要對這個文件的內容做任何修改
3.從system1 上,任何人都可以瀏覽private的內容,但是從其它系統不能訪問這個目錄的內容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
mkdir
/var/www/virtual/private
mkdir
/var/www/html/private
cd
/var/www/virtual/private
wget -O index.html http:
//rhgls
.domain11.example.com
/materials/private
.html
cd
/var/www/html/private
wget -O index.html http:
//rhgls
.domain11.example.com
/materials/private
.html <Directory
"/var/www/html/private"
>
AllowOverride none
Require all denied
Require
local
<
/Directory
>
<Directory
"/var/www/virtual/private"
>
AllowOverride none
Require
local
Require all denied
<
/Directory
>
|
16,實現動態WEB 內容
在 system1 上配置提供動態web內容,要求如下:
1、 動態內容由名為 dynamic.domain11.example.com 的虛擬主機提供
2、 虛擬主機偵聽在端口 8909
3、 從 .domain11.example.com/materials/webapp.wsgi 下載一個腳本,然后放在適當的位置,無論如何不要求修改此文件的內容
4、 客戶端訪問 http:// dynamic.domain11example.com:8909/ 時,應該接收到動態生成的web頁面
5、 此 http:// dynamic.domain11.example.com:8909/ 必須能被 domain11.example.com 域內的所有系統訪問
1
2
3
4
5
6
7
8
9
10
11
12
13
|
yum -y
install
mod_wsgi
vim
/etc/httpd/conf/httpd
.conf
Listen 80
Listen 8909
<virtualhost *:8909>
servername dynamic.domain11.example.com
WSGIScriptAlias /
/var/www/html/webapp
.wsgi
#注意大小寫
<
/virtualhost
>
cd
/var/www/html
wget http:
//rhgls
.domain11.example.com
/materials/webapp
.wsgi
systemctl restart firewalld
semanage port -a -t http_port_t -p tcp 8909
systemctl restart httpd
|
17. 創建一個腳本
在system1上創建一個名為/root/foo.sh的腳本,讓其提供下列特性:
1. 當運行/root/foo.sh redhat,輸出為fedora
2. 當運行/root/foo.sh fedora,輸出為redhat
3. 當沒有任何參數或者參數不是redhat或者fedora時,其錯誤輸出產生以下的信息:/root/foo.sh redhat:fedora
1
2
3
4
5
6
7
8
9
10
11
12
|
vim foo.sh
#~/bin/bash
case
$1
in
redhat)
echo
fedora
fedora)
echo
redhat
echo
'root/foo.sh redhat:fedora'
chmod
+x foo.sh
.
/foo
.sh redhat
.
/foo
.sh fedora
.
/foo
.sh 1
|
18. 創建一個添加用戶的腳本
在system1上創建一個腳本,名為/root/mkusers ,此腳本能實現為系統system1創建本地用戶,並且這些用戶的用戶名來自一個包含用戶名列表的文件,同時滿足下列要求:
1. 此腳本要求提供一個參數,此參數就是包含用戶名列表的的文件
2. 如果沒有提供參數,此腳本應該給出下面的提示信息Usage:/root/mkusers然后退出並返回相應的值
3. 如果提供一個不存在的文件名,此腳本應該給出下面的提示信息Input file not found 然后退出並返回相應的值
4. 創建的用戶登錄shell為/bin/false
5. 此腳本不需要為用戶設置密碼
6. 您可以從下面的URL中獲取用戶名列表作為測試用http://rhgls. domain11.example.com/materials/ userlist
1
2
3
4
5
6
7
8
9
10
11
12
13
|
vim mkusers.sh
#注意空格
#! /bin/bash
if
[ $
# -eq 0 ];then
echo
'Usage:/root/mkusers'
exit
1
if
[ ! -f $1 ];
then
echo
'Input file not found'
while
read
line
useradd
-s
/bin/false
$line
done
< $1
chmod
+x mkusers.sh
wget http:
//rhgls
.domain11.example.com
/materials/userlist
.
/mkusers
.sh userlist
|
id 用戶名 查看用戶是否添加
然后測試文件不存在和沒有輸入參數的情況是否符合題目要求
19. 配置ISCSI服務端
配置system1提供一個ISCSI 服務磁iqn.2014-09.com.example.domain11:system1並符合下列要求:
1. 服務端口為3260
2. 使用iscsi_store作其后端卷 其大小為3G
3. 此服務職能被system2.domian11.example.com訪問 解法:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
fdisk
/dev/sda
partprobe
/dev/sda
yum
install
-y targetcli\*
targetcli
cd
backstores/
block/ create block1
/dev/sda3
cd
/iscsi
create iqn.2014-09.com.example.domain11:system1
cd
iqn.2014-09.com.example.domain11:system1/
cd
tpg1/
acls/ create iqn.2014-09.com.example.domain11:system luns/ create
/backstores/block/block1
portals/ create system1.domain11.example.com
systemctl start target
systemctl
enable
target
firewall-config
systecmctl restart firewalld
|
20. 配置ISCISI的客戶端
配置system2使其能鏈接在system1上提供的 iqn.2014-09.com.example.domain11:system1並符合以下要求:
1. ISCISI設備在系統啟動的期間自動加載
2. 塊設備ISCISI上包含一個大小為2100MIB的分區,並格式化為ext4
3. 此分區掛載在/mnt/data上 同時在系統啟動的期間自動掛載
1
2
3
4
5
6
7
8
9
10
11
12
|
yum
install
-y iscsi-initiator-utils.i686
vim
/etc/iscsi/initiatorname
.iscsi
InitiatorName=iqn.2014-09.com.example.domain11:system
systemctl start iscsid
systemctl is-active iscsid
iscsiadm --mode discoverydb --
type
sendtargets --portal 172.24.11.10 –discover iscsiadm --mode node --targetname iqn.2014-09.com.example.domain11:system1 --portal 172.24.11.10:3260 –login
fdisk
–l
fdisk
/dev/sdb
mkfs.ext4
/dev/sdb1
partprobe
mkdir
/mnt/data
vim
/etc/fstab
/dev/sdb1
/mnt/data
ext4 _netdev 0 0
|
21. 配置一個數據庫
在 system1上創建一個Maria DB數據庫,名為Contacts,並符合以下條件:
1、 數據庫應該包含來自數據庫復制的內容,復制文件的URL為
http://rhgls.domain11.example.com/materials/users.mdb
2、 數據庫只能被 localhost 訪問
3、 除了root用戶,此數據庫只能被用戶Luigi查詢,此用戶密碼為 redhat
4、 root 用戶的密碼為 redhat,同時不允許空密碼登錄
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
yum
install
-y mariadb*
systemctl start mariadb
systemctl
enable
mariadb
wget http:
//rhgls
.domain11.example.com
/materials/users
.mdb
mysql
create database Contacts;
show databases;
use Contacts
source
/users
.mdb
show tables;
grant
select
on Contacts .* to Luigi@
'localhost'
identified by
'redhat'
;
exit
mysqladmin -uroot -p password
'redhat'
#兩個回車
mysql -uroot –p
#密碼輸入redhat
mysql -uLuigi –p
#密碼輸入redhat
|
22. 數據庫查詢
在系統 system1 上使用數據庫 Contacts ,並使用相應的SQL 查詢以回答下列問題:
1、 密碼是 tangerine 的人的名字?
2、 有多少人的姓名是 John 同時居住在 Santa Clara ?
1
2
3
4
5
6
7
|
mysql –uroot –p
show tables;
#查看表結構
desc 表名;
#查看表字段
select
bid,password from pass where password=
'tangerine'
;
#查密碼的ID號
select
* from name where aid=
'3'
;
#通過密碼id找名字
select
* from name where firstname=
'John'
;
#查找同名的人
select
* from loc where loction=
'Santa Clara'
;
#查找住在同一城市的人
|