RHCE

远程虚拟机:
[tom@server ~]$ ssh root@system1 -X
[tom@server ~]$ ssh root@system2 -X

配置YUM源:
[root@system1 ~]# cd /etc/yum.repos.d/
[root@system1 yum.repos.d]# vim aa.repo
[aa]
name=aa
baseurl=ftp://server.rhce.cc/dvd
enabled=1
gpgcheck=0

[root@system1 yum.repos.d]# yum clean all
[root@system1 yum.repos.d]# yum list
[root@system1 yum.repos.d]# scp aa.repo system2:/etc/yum.repos.d/

[root@system2 ~]# yum clean all
[root@system2 ~]# yum list

1.配置SELinux
SELinux必须在两个系统system1和system2中运行于Enforcing模式
[root@system1 ~]# vim /etc/selinux/config
SELINUX=enforcing
两台上都要配置:

2.配置SSH访问
按以下要求配置SSH访问:
用户能够从域rhce.cc内的客户端通过SSH远程访问您的两个虚拟机系统
在域my133t.org内的客户端不能访问您的两个虚拟机系统
[root@system1 ~]# host rhce.cc
rhce.cc has address 192.168.122.0
[root@system1 ~]# vim /etc/hosts.allow 允许
sshd : 192.168.122.0/255.255.255.0 最后一行添加
[root@system1 ~]# vim /etc/hosts.deny 拒绝
sshd : .my133t.org 最后一行添加
[root@system1 ~]# scp /etc/hosts.allow /etc/hosts.deny system2:/etc/

3.自定义用户环境
在系统system1和system2上创建自定义命令名为qstat此自定义命令将执行以下命令:
/bin/ps-Aopid,tt,user,fname,rsz
此命令对系统中所有用户有效
[root@system1 ~]# /bin/ps -Aopid,tt,user,fname,rsz
[root@system1 ~]# vim /etc/bashrc
alias qstat=’/bin/ps -Aopid,tt,user,fname,rsz’ 最后一行添加
[root@system1 ~]# source /etc/bashrc
[root@system1 ~]# qstat
两台上都要配置:

4.配置端口转发
在系统system1配置端口转发,要求如下:
在192.168.122.0/24网络中的系统,访问system1的本地端口5423将被转发到80此设置必须永久有效
找模板内容:
[tom@server ~]$ vim aa.txt
[tom@server ~]$ man -k firewall
firewalld.richlanguage (5) - Rich Language Documentation
[tom@server ~]$ man firewalld.richlanguage
/EXAMPLES 搜索
关注Example 3和Example 5
复制Example 5里的rule family=“ipv6” source address=“1:2:3:4:6::” forward-port to-addr=“1::2:3:4:7” to-port=“4012” protocol=“tcp” port="4011"到aa.txt更改,更改好了再复制到system1命令行中
更改后‘rule family=“ipv4” source address=“192.168.122.0/24” forward-port to-port=“80” protocol=“tcp” port=“5423”’ --permanent
[root@system1 ~]# firewall-cmd --add-rich-rule ‘rule family=“ipv4” source address=“192.168.122.0/24” forward-port to-port=“80” protocol=“tcp” port=“5423”’
[root@system1 ~]# firewall-cmd --add-rich-rule ‘rule family=“ipv4” source address=“192.168.122.0/24” forward-port to-port=“80” protocol=“tcp” port=“5423”’ --permanent

5.配置聚合链路
在system1.rhce.cc和system2.rhce.cc之间按以下要求配置一个链路:
此链路使用接口eth1和eth2
此链路在一个接口失效时仍然能工作
此链路在system1使用下面的地址172.16.11.25/255.255.255.0
此链路在system2使用下面的地址172.16.11.35/255.255.255.0
此链路在系统重启之后依然保持正常状态
[root@system1 ~]# cd /usr/share/doc/teamd-1.9/example_ifcfgs/1/
[root@system1 1]# cp * /etc/sysconfig/network-scripts/
[root@system1 1]# cd /etc/sysconfig/network-scripts/
[root@system1 network-scripts]# vim 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@system1 network-scripts]# vim ifcfg-eth1
DEVICE=“eth1”
NAME=eth1
DEVICETYPE=“TeamPort”
ONBOOT=“yes”
TEAM_MASTER=“team_test0”

[root@system1 network-scripts]# vim ifcfg-eth2
DEVICE=“eth2”
NAME=eth2
DEVICETYPE=“TeamPort”
ONBOOT=“yes”
TEAM_MASTER=“team_test0”

[root@system1 network-scripts]# systemctl restart network
[root@system1 network-scripts]# scp ifcfg-team_test0 ifcfg-eth1 ifcfg-eth2 system2:/etc/sysconfig/network-scripts/
切换到system2上
[root@system2 ~]# cd /etc/sysconfig/network-scripts/
[root@system2 network-scripts]# vim ifcfg-team_test0
DEVICE=“team_test0”
NAME=team_test0
DEVICETYPE=“Team”
ONBOOT=“yes”
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR=172.16.11.35
TEAM_CONFIG=’{“runner”: {“name”: “activebackup”}}’

[root@system2 network-scripts]# systemctl restart network
[root@system2 network-scripts]teamdctl team_test0 state 可以查看他的状态
测试:
[root@system2 network-scripts]# ping 172.16.11.35
[root@system2 network-scripts]# ping 172.16.11.25
[root@system1 network-scripts]# ping 172.16.11.25
[root@system1 network-scripts]# ping 172.16.11.35

6.配置IPv6地址
在您的考试系统上配置接口eth0使用下列IPv6地址:
system1上的地址应该是200e:ac18::e0a/64
system2上的地址应该是200e:ac18::e14/64
两个系统必须能与网络200e:ac18/64内的系统通信。
地址必须在重启后依旧生效。
两个系统必须保持当前的IPv4地址并能通信。
[root@system1 ~]# nmcli connection
名称 UUID 类型 设备
eth2 3a73717e-65ab-93e8-b518-24f5af32dc0d 802-3-ethernet eth2
eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 802-3-ethernet eth1
eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0
team_test0 896aa503-a13e-af5b-99fd-1be653c9e5bd team team_test0
[root@system1 ~]# nmcli connection modify eth0 ipv6.method auto
[root@system1 ~]# nmcli connection modify eth0 ipv6.addresses 200e:ac18::e0a/64
[root@system1 ~]# nmcli connection modify eth0 ipv6.method manual
[root@system1 ~]# systemctl restart network

[root@system2 ~]# nmcli connection
名称 UUID 类型 设备
eth2 3a73717e-65ab-93e8-b518-24f5af32dc0d 802-3-ethernet eth2
eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 802-3-ethernet eth1
eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0
team_test0 896aa503-a13e-af5b-99fd-1be653c9e5bd team team_test0
[root@system2 ~]# nmcli connection modify eth0 ipv6.method auto
[root@system2 ~]# nmcli connection modify eth0 ipv6.addresses 200e:ac18::e14/64
[root@system2 ~]# nmcli connection modify eth0 ipv6.method manual
[root@system2 ~]# systemctl restart network
测试:
[root@system2 ~]# ping6 200e:ac18::e14
[root@system2 ~]# ping6 200e:ac18::e0a
[root@system1 ~]# ping6 200e:ac18::e14
[root@system1 ~]# ping6 200e:ac18::e0a

7.配置本地邮件服务
在系统system1和system2上配置邮件服务,满足以下要求:
这些系统不接收外部发送来的邮件
在这些系统上本地发送的任何邮件都会自动路由到rhgls.rhce.cc
从这些系统上发送的邮件显示来自于rhce.cc
您可以通过发送邮件到本地用户’dave’来测试您的配置,系统rhgls.rhce.cc已经配置把此用户的邮件转到下列URL http://rhgls.rhce.cc/received_mail/11
[root@system1 ~]# firewall-cmd --add-service=smtp
[root@system1 ~]# firewall-cmd --add-service=smtp --permanent

[root@system2 ~]# firewall-cmd --add-service=smtp
[root@system2 ~]# firewall-cmd --add-service=smtp --permanent

[root@system1 ~]# cd /etc/postfix/
[root@system1 postfix]# vim main.cf
#mydestination = m y h o s t n a m e , l o c a l h o s t . myhostname, localhost. myhostname,localhost.mydomain, localhost
mydestination =
#relayhost = [an.ip.add.ress]
relayhost = [rhgls.rhce.cc]
#myorigin = $mydomain
myorigin = rhce.cc

[root@system1 postfix]# systemctl restart postfix
打开server
主机浏览器测试:http://rhgls.rhce.cc/received_mail/11
[root@system1 postfix]# yum install mailx -y
[root@system1 postfix]# echo aaaaaaa | mailx -s ‘aaaaaa’ dave
打开浏览器再测试:收到aaa就行

[root@system1 postfix]# scp main.cf system2:/etc/postfix/
[root@system2 ~]# systemctl restart postfix
[root@system2 ~]# yum install mailx -y
[root@system2 ~]# echo bbbbbb | mail -s ‘bbbbbbbbbb’ dave
打开浏览器测试:收到bbb就行

8.通过SMB共享目录
在system1上配置SMB服务
您的SMB服务器必须是STAFF工作组的一个成员
共享/common目录共享名必须为common
只有rhce.cc域内的客户端可以访问common共享
common必须是可以浏览的
用户andy必须能够读取共享中的内容,如果需要的话,验证的密码是redhat
[root@system1 ~]# yum install samba -y
[root@system1 ~]# cd /etc/samba/
[root@system1 samba]# vim smb.conf
workgroup = STAFF
[root@system1 samba]# mkdir /common
[root@system1 samba]# chcon -R -t samba_share_t /common/
[root@system1 samba]# vim smb.conf 最后一行添加
[common]
path = /common
hosts allow = 192.168.122.0/24

[root@system1 samba]# firewall-cmd --add-service=samba
[root@system1 samba]# firewall-cmd --add-service=samba --permanent
[root@system1 samba]# id andy
id: andy: no such user
[root@system1 samba]# useradd andy
[root@system1 samba]# echo redhat | passwd --stdin andy
[root@system1 samba]# yum whatprovides */smbpasswd
samba-client-4.1.1-31.el7.x86_64 : Samba client programs
[root@system1 samba]# yum install samba-client -y
[root@system1 samba]# pdbedit -L
[root@system1 samba]# smbpasswd -a andy
New SMB password:
Retype new SMB password:
Added user andy.
[root@system1 samba]# systemctl start smb
[root@system1 samba]# systemctl enable smb

[root@system2 ~]# yum install samba-client -y
[root@system2 ~]# smbclient -L //system1 -U andy%redhat
Domain=[STAFF] OS=[Unix] Server=[Samba 4.1.1]

Sharename Type Comment


common          Disk      

IPC$ IPC IPC Service (Samba Server Version 4.1.1)
andy Disk Home Directories
Domain=[STAFF] OS=[Unix] Server=[Samba 4.1.1]

Server Comment


Workgroup Master


[root@system2 ~]# smbclient //system1/common -U andy%redhat
Domain=[STAFF] OS=[Unix] Server=[Samba 4.1.1]
smb: > quit

9.配置多用户SMB挂载
在system1共享通过SMB目录/miscellaneous满足以下要求:
共享名为miscellaneous
共享目录miscellaneous只能被rhce.cc域中的客户端使用
共享目录miscellaneous必须可以被浏览
用户silene必须能以读的方式访问此共享,访问密码是redhat
用户akira必须能以读写的方式访问此共享,访问密码是redhat
此共享永久挂载在system2.rhce.cc上的/mnt/multi目录,并使用用户silene作为认
证任何用户可以通过用户akira来临时获取写的权限
[root@system1 ~]# cd /etc/samba/
[root@system1 samba]# mkdir /miscellaneous
[root@system1 samba]# chcon -R -t samba_share_t /miscellaneous/
[root@system1 samba]# vim smb.conf 最后一行添加
[miscellaneous]
path = /miscellaneous
hosts allow = 192.168.122.0/24
writable = no
write list = akira

[root@system1 samba]# chmod o+w /miscellaneous/
[root@system1 samba]# id silene
id: silene: no such user
[root@system1 samba]# id akira
id: akira: no such user
[root@system1 samba]# useradd silene
[root@system1 samba]# useradd akira
[root@system1 samba]# echo redhat | passwd --stdin akira
[root@system1 samba]# echo redhat | passwd --stdin silene
[root@system1 samba]# smbpasswd -a silene
New SMB password:redhat
Retype new SMB password:
Added user silene.
[root@system1 samba]# smbpasswd -a akira
New SMB password:redhat
Retype new SMB password:
Added user akira.
[root@system1 samba]# systemctl restart smb

[root@system2 ~]# smbclient //system1/miscellaneous -U silene%redhat
Domain=[STAFF] OS=[Unix] Server=[Samba 4.1.1]
smb: > mkdir aa
NT_STATUS_MEDIA_WRITE_PROTECTED making remote directory \aa
smb: > quit
[root@system2 ~]# smbclient //system1/miscellaneous -U akira%redhat
Domain=[STAFF] OS=[Unix] Server=[Samba 4.1.1]
smb: > mkdir bb
smb: > quit

[root@system2 ~]# mkdir /mnt/multi
[root@system2 ~]# smbclient -L //system1 -U andy%redhat
Domain=[STAFF] OS=[Unix] Server=[Samba 4.1.1]

Sharename Type Comment


common          Disk      
miscellaneous   Disk      

IPC$ IPC IPC Service (Samba Server Version 4.1.1)
andy Disk Home Directories
Domain=[STAFF] OS=[Unix] Server=[Samba 4.1.1]

Server Comment


Workgroup Master


[root@system2 ~]# vim /etc/fstab
//system1/miscellaneous /mnt/multi cifs defaults,username=silene,password=redhat,multiuser,sec=ntlmssp 0 0
[root@system2 ~]# yum install cifs-u* -y
[root@system2 ~]# mount -a
[root@system2 ~]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/vda1 xfs 3.9G 1.2G 2.8G 31% /
devtmpfs devtmpfs 492M 0 492M 0% /dev
tmpfs tmpfs 498M 0 498M 0% /dev/shm
tmpfs tmpfs 498M 6.6M 491M 2% /run
tmpfs tmpfs 498M 0 498M 0% /sys/fs/cgroup
/dev/mapper/vg0-vo xfs 189M 9.8M 179M 6% /home
//system1/miscellaneous cifs 3.9G 1.3G 2.7G 32% /mnt/multi

测试:
[root@system2 ~]# useradd tom1
[root@system2 ~]# useradd tom2
[root@system2 ~]# useradd tom3
[root@system2 ~]# su - tom1
[tom1@system2 ~]$ cd /mnt/multi
[tom1@system2 multi]$ ls
ls: 正在读取目录.: 权限不够
[tom1@system2 multi]$ cifscreds add system1 -u silene
Password: redhat
[tom1@system2 multi]$ ls
bb
[tom1@system2 multi]$ touch ssss
touch: 无法创建"ssss": 权限不够
[tom1@system2 multi]$ exit
登出
[root@system2 ~]# su - tom2
[tom2@system2 ~]$ cd /mnt/multi
[tom2@system2 multi]$ ls
ls: 正在读取目录.: 权限不够
[tom2@system2 multi]$ cifscreds add system1 -u akira
Password:
[tom2@system2 multi]$ mkdir bbb
[tom2@system2 multi]$ ls
bb bbb
[tom2@system2 multi]$ exit
登出

10.配置NFS服务
在system1配置NFS服务,要求如下:
以只读的方式共享目录/public同时只能被rhce.cc域中的系统访问
以读写的方式共享目录/protected能被rhce.cc域中的系统访问
访问/protected需要通过Kerberos安全加密,您可以使用下面URL提供的密钥
http://host.rhce.cc/materials/nfs_server.keytab.
目录/protected应该包含名为confidential拥有人为ldapuser11的子目录
用户ldapuser11能以读写方式访问/protected/confidential
[root@system1 ~]# systemctl start nfs-server
[root@system1 ~]# systemctl enable nfs-server
[root@system1 ~]# firewall-cmd --add-rich-rule ‘rule family=“ipv4” source address=“192.168.122.0/24” service name=“nfs” accept’
[root@system1 ~]# firewall-cmd --add-rich-rule ‘rule family=“ipv4” source address=“192.168.122.0/24” service name=“nfs” accept’ --permanent
[root@system1 ~]# firewall-cmd --add-rich-rule ‘rule family=“ipv4” source address=“192.168.122.0/24” service name=“rpc-bind” accept’
[root@system1 ~]# firewall-cmd --add-rich-rule ‘rule family=“ipv4” source address=“192.168.122.0/24” service name=“rpc-bind” accept’ --permanent
[root@system1 ~]# firewall-cmd --add-rich-rule ‘rule family=“ipv4” source address=“192.168.122.0/24” service name=“mountd” accept’
[root@system1 ~]# firewall-cmd --add-rich-rule ‘rule family=“ipv4” source address=“192.168.122.0/24” service name=“mountd” accept’ --permanent
[root@system1 ~]# mkdir /public
[root@system1 ~]# vim /etc/exports
/public *(ro,sync)
[root@system1 ~]# exportfs -arv
exporting *:/public

测试:
[root@system2 ~]# showmount -e system1
Export list for system1:
/public *
[root@system2 ~]# mount system1:/public /mnt/
[root@system2 ~]# umount /mnt/

回到system1上
[root@system1 ~]# mkdir /protected
[root@system1 ~]# vim /etc/exports
/public *(ro,sync)
/protected *(rw,sync) 添加这一行
[root@system1 ~]# exportfs -arv
exporting *:/protected
exporting *:/public
[root@system1 ~]# wget -O /etc/krb5.keytab http://host.rhce.cc/materials/nfs_server.keytab
[root@system1 ~]# vim /etc/exports
/public *(ro,sync)
/protected *(rw,sync,sec=krb5p) 后面添加sec=krb5p

[root@system1 ~]# vim /etc/sysconfig/nfs
RPCNFSDARGS="-V 4.2" 强制使用4.2版本
[root@system1 ~]# chcon -R -t public_content_t /protected/ 把他的上下文改一下
[root@system1 ~]# mkdir /protected/confidential
[root@system1 ~]# chcon -R -t public_content_t /protected/
[root@system1 ~]# chown ldapuser11 /protected/confidential/
[root@system1 ~]# systemctl restart nfs-server.service
[root@system1 ~]# systemctl restart nfs-secure.service
[root@system1 ~]# systemctl enable nfs-secure.service

11.挂载一个NFS共享
在system2上挂载一个来自system1.rhce.cc的NFS共享,并符合下列要求:
/public挂载在下面的目录上/mnt/nfsmount
/protected挂载在下面的目录上/mnt/nfssecure并使用安全的方式,密钥下载URL如
下:http://host.rhce.cc/materials/nfs_client.keytab.
用户ldapusre11能够在/mnt/nfssecure/confidential上创建文件
这些文件系统在系统启动时自动挂载
[root@system2 ~]# showmount -e system1
Export list for system1:
/protected *
/public *
[root@system2 ~]# mkdir /mnt/nfsmount
[root@system2 ~]# vim /etc/fstab
system1.rhce.cc:/public /mnt/nfsmount nfs defaults 0 0
[root@system2 ~]# mount -a
[root@system2 ~]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/vda1 xfs 3.9G 1.2G 2.8G 31% /
devtmpfs devtmpfs 492M 0 492M 0% /dev
tmpfs tmpfs 498M 0 498M 0% /dev/shm
tmpfs tmpfs 498M 6.6M 491M 2% /run
tmpfs tmpfs 498M 0 498M 0% /sys/fs/cgroup
/dev/mapper/vg0-vo xfs 189M 9.9M 179M 6% /home
//system1/miscellaneous cifs 3.9G 1.3G 2.7G 32% /mnt/multi
system1.rhce.cc:/public nfs4 3.9G 1.3G 2.7G 32% /mnt/nfsmount
[root@system2 ~]# mkdir /mnt/nfssecure
[root@system2 ~]# wget -O /etc/krb5.keytab http://host.rhce.cc/materials/nfs_client.keytab
[root@system2 ~]# systemctl restart nfs-secure.service
[root@system2 ~]# systemctl enable nfs-secure.service
[root@system2 ~]# vim /etc/fstab
system1.rhce.cc:/protected /mnt/nfssecure nfs defaults,v4.2,sec=krb5p 0 0
[root@system2 ~]# mount -a
mount.nfs: access denied by server while mounting system1.rhce.cc:/protected 报错,绝决被访问

[tom@server 桌面]$ reboot 重启主机,虚拟机会出现这个问题,考试的时候不会

[root@system1 ~]# systemctl restart nfs-server
[root@system1 ~]# systemctl restart nfs-secure-server
[root@system1 ~]# systemctl enable nfs-secure-server

[root@system2 ~]# systemctl restart nfs-server
[root@system2 ~]# systemctl restart nfs-secure-server
[root@system2 ~]# systemctl enable nfs-secure-server

[root@system2 ~]# mount -a
[root@system2 ~]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/vda1 xfs 3.9G 1.3G 2.7G 32% /
devtmpfs devtmpfs 492M 0 492M 0% /dev
tmpfs tmpfs 498M 0 498M 0% /dev/shm
tmpfs tmpfs 498M 6.6M 491M 2% /run
tmpfs tmpfs 498M 0 498M 0% /sys/fs/cgroup
/dev/mapper/vg0-vo xfs 189M 9.9M 179M 6% /home
//system1/miscellaneous cifs 3.9G 1.5G 2.5G 39% /mnt/multi
system1.rhce.cc:/public nfs4 3.9G 1.5G 2.5G 39% /mnt/nfsmount
system1.rhce.cc:/protected nfs4 3.9G 1.5G 2.5G 39% /mnt/nfssecure

[root@system1 ~]# ssh ldapuser11@system2.rhce.cc
-bash-4.2$ cd /mnt/nfssecure/confidential/
-bash-4.2$ touch aaa
-bash-4.2$ ls
aaa
-bash-4.2$ exit
登出

12.配置web站点
system1上配置一个站点http://system1.rhce.cc然后执行下述步骤:
从http://rhgls.rhce.cc/materials/station.html
下载文件,并且将文件重命名为index.html不要修改此文件的内容
将文件index.html拷贝到您的web服务器的DocumentRoot目录下
来自于rhce.cc域的客户端可以访问此Web服务
来自于my133t.org域的客户端拒绝访问此Web服务
[root@system1 ~]# yum groupinstall web* -y
[root@system1 ~]# systemctl restart httpd
[root@system1 ~]# systemctl enable httpd
[root@system1 ~]# cd /etc/httpd/conf/
[root@system1 conf]# vim httpd.conf
ServerName system1.rhce.cc:80
[root@system1 conf]# wget -O /var/www/html/index.html http://rhgls.rhce.cc/materials/station.html
[root@system1 conf]# firewall-cmd --add-rich-rule ‘rule family=“ipv4” source address=“192.168.122.0/24” service name=“http” accept’
[root@system1 conf]# firewall-cmd --add-rich-rule ‘rule family=“ipv4” source address=“192.168.122.0/24” service name=“http” accept’ --permanent
[root@system1 conf]# systemctl restart httpd
打开浏览器输入:system1.rhce.cc访问:会显示station
重启服务器之后,不知道服务有没有启动:
[root@system1 conf]# ping system1.rhce.cc 通就行
[root@system1 conf]# vim /etc/hosts
192.168.122.100 system1.rhce.cc

13.配置安全web服务
为站点http://system1.rhce.cc配置TLS加密一个已签名证书从http://host.rhce.cc/materials/system1.crt
获取此证书的密钥从http://host.rhce.cc/materials/system1.key获取,此证书的签名授权信息从http://host.rhce.cc/materials/domain11.crt获取
[root@system1 conf]# wget http://host.rhce.cc/materials/system1.crt
[root@system1 conf]# wget http://host.rhce.cc/materials/system1.key
[root@system1 conf]# wget http://host.rhce.cc/materials/domain11.crt
再打开一个终端方便配置:
[tom@server 桌面]$ ssh root@system1
[root@system1 ~]# cd /etc/httpd/conf.d/
[root@system1 conf.d]# vim ssl.conf
SSLCertificateFile /etc/httpd/conf/system1.crt
SSLCertificateKeyFile /etc/httpd/conf/system1.key
SSLCertificateChainFile /etc/httpd/conf/domain11.crt
[root@system1 conf.d]# systemctl restart httpd
打开浏览器:现在输入https://system1.rhce.cc/会显示无法连接,那就配置防火墙。
[root@system1 conf]# firewall-cmd --add-rich-rule ‘rule family=“ipv4” source address=“192.168.122.0/24” service name=“https” accept’
[root@system1 conf]# firewall-cmd --add-rich-rule ‘rule family=“ipv4” source address=“192.168.122.0/24” service name=“https” accept’ --permanent
再打开浏览器访问:https://system1.rhce.cc就可以访问了

14.配置虚拟主机
在system1上扩展您的web服务器,为站点http://www…rhce.cc创建一个虚拟主机,然后执行下述步骤:
设置DocumentRoot为/var/www/virtual
从http://rhgls.rhce.cc/materials/www.html
下载文件并重命名为index.html不要对文件index.html的内容做任何修改
将文件index.html放到虚拟主机的DocumentRoot目录下
确保andy用户能够在/var/www/virtual目录下创建文件
注意:原始站点http://system1.rhce.cc必须仍然能够访问,名称服务器rhce.cc提供对主机名www.rhce.cc的域名解析
[root@system1 conf.d]# ping www.rhce.cc 先ping一下看清楚地址是什么
[root@system1 conf.d]# vim /etc/hosts
192.168.122.100 www.rhce.cc
[root@system1 conf.d]# mkdir /var/www/virtual
[root@system1 conf.d]# wget -O /var/www/virtual/index.html http://rhgls.rhce.cc/materials/www.html
[root@system1 conf.d]# setfacl -m u:andy:rwx /var/www/virtual/
[root@system1 conf.d]# cp /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf vhost.conf
[root@system1 conf.d]# vim vhost.conf

[root@system1 conf.d]# systemctl restart httpd

电脑测试:一下网站能不访问,能访问就可以
https://system1.rhce.cc/
http://www.rhce.cc/
http://system1.rhce.cc/

15.配置web内容的访问
在您的system1上的web服务器的DocumentRoot目录下创建一个名为secret的目录,要求如下:
从http://rhgls.rhce.cc/materials/private.html下载一个文件副本到这个目录,并且重命名为index.html。
不要对这个文件的内容做任何修改。
从system1上,任何人都可以浏览secret的内容,但是从其它系统不能访问这个目
录的内容
[root@system1 conf]# mkdir /var/www/html/secret /var/www/virtual/secret
[root@system1 conf]# wget -O /var/www/html/secret/index.html http://rhgls.rhce.cc/materials/private.html
[root@system1 conf]# wget -O /var/www/virtual/secret/index.html http://rhgls.rhce.cc/materials/private.html
[root@system1 conf]# vim /etc/httpd/conf/httpd.conf
[root@system1 conf]# cd /etc/httpd/conf.d/
[root@system1 conf.d]# vim vhost.conf
<Directory “/var/www/html/secret”>
AllowOverride None
Require local

<Directory “/var/www/virltual/secret”>
AllowOverride None
Require local

[root@system1 conf.d]# systemctl restart httpd

只允许本机访问
[root@system1 conf.d]# curl -s www.rhce.cc/secret/
private
[root@system1 conf.d]# curl -s system1.rhce.cc/secret/
private

16.实现动态Web内容
在system1上配置提供动态Web内容,要求如下:
动态内容由名为dynamic.rhce.cc的虚拟主机提供
虚拟主机侦听在端口8998
从http://rhgls.rhce.cc/materials/webapp.wsgi下载一个脚本,然后放在适当的位置,无
论如何不要求修改此文件的内容
客户端访问http://dynamic.rhce.cc:8998/时应该接收到动态生成的web页面
此http://dynamic.rhce.cc:8998/必须能被rhce.cc域内的所有系统访问
[root@system1 ~]# ping dynamic.rhce.cc
PING dynamic.rhce.cc (192.168.122.100) 56(84) bytes of data.
64 bytes from system1.rhce.cc (192.168.122.100): icmp_seq=1 ttl=64 time=0.188 ms
[root@system1 ~]# vim /etc/hosts
192.168.122.100 dynamic.rhce.cc dynamic
[root@system1 ~]# firewall-cmd --add-rich-rule ‘rule family=“ipv4” source address=“192.168.122.0/24” port port=“8998” protocol=“tcp” accept’
[root@system1 ~]# firewall-cmd --add-rich-rule ‘rule family=“ipv4” source address=“192.168.122.0/24” port port=“8998” protocol=“tcp” accept’ --permanent
[root@system1 ~]# vim /etc/httpd/conf/httpd.conf
Listen 80
Listen 8998 添加这行
[root@system1 ~]# vim /etc/httpd/conf.d/vhost.conf

17.创建一个脚本
在system1上创建一个名为/root/script的脚本,让其提供下列特性:
当运行/root/scriptfoo,输出为bar
当运行/root/scriptbar,输出为foo
当没有任何参数或者参数不是foo或者bar时,其错误输出产生以下的信息:/root/scriptfoo|bar
[root@system1 ~]# vim script
#!/bin/bash

case $1 in
foo)
echo bar
;;
bar)
echo foo
;;
*)
echo ‘/root/script foo|bar’;;
esac
[root@system1 ~]# chmod +x script
[root@system1 ~]# ./script foo
bar
[root@system1 ~]# ./script bar
foo
[root@system1 ~]# ./script
/root/script foo|bar

18.创建一个添加用户的脚本
在system1上创建一个脚本,名为/root/mkusers,此脚本能实现为系统system1创建本地用户并且这些用户的用户名来自一个包含用户名列表的文件。同时满足下列要求:
此脚本要求提供一个参数,此参数就是包含用户名列表的文件
如果没有提供参数,此脚本应该给出下面的提示信息Usage:/root/mkusers然后退出并
返回相应的值
如果提供一个不存在的文件名,此脚本应该给出下面的提示信息Inputfilenotfound然后退出并返回相应的值
创建的用户登录shell为/bin/false
此脚本不需要为用户设置密码
您可以从下面的URL获取用户名列表作为测试用http://rhgls.rhce.cc/materials/userlist
[root@system1 ~]# vim mkusers
#!/bin/bash

if [ $# -eq 0 ]; then
echo “Usage: /root/mkusers”
exit 1
fi

if [ ! -f $1 ]; then
echo “Input file not found”
exit 1
fi

while read aa
do
useradd -s /bin/false $aa
done <$1
[root@system1 ~]# wget http://rhgls.rhce.cc/materials/userlist
[root@system1 ~]# cat userlist 这里是还没创建的
lisi
wangw
zhaos
liun
[root@system1 ~]# chmod +x mkusers
[root@system1 ~]# ./mkusers
Usage: /root/mkusers
[root@system1 ~]# ./mkusers afafaf
Input file not found
[root@system1 ~]# ./mkusers userlist
[root@system1 ~]# id wangw
uid=1715(wangw) gid=1715(wangw) 组=1715(wangw)
[root@system1 ~]# id lisi
uid=1714(lisi) gid=1714(lisi) 组=1714(lisi)
[root@system1 ~]# id zhaos
uid=1716(zhaos) gid=1716(zhaos) 组=1716(zhaos)
[root@system1 ~]# id liun
uid=1717(liun) gid=1717(liun) 组=1717(liun)

19.配置iSCSI服务端
配置system1提供一个iSCSI服务磁盘名为iqn.2014-09.com.example.domain11:system1,并符合下列要求:
服务端口为3260
使用iscsivol作其后端卷其大小为3G
此服务只能被system2.rhce.cc访问
[root@system1 ~]# yum install target* -y
[root@system1 ~]# systemctl start target
[root@system1 ~]# systemctl enable target
[root@system1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 8G 0 disk
├─vda1 253:1 0 3.9G 0 part /
├─vda2 253:2 0 512M 0 part [SWAP]
└─vda3 253:3 0 196M 0 part
└─vg0-vo 252:0 0 192M 0 lvm /home
[root@system1 ~]# fdisk /dev/vda
命令(输入 m 获取帮助):p
设备 Boot Start End Blocks Id System
/dev/vda1 * 2048 8194047 4096000 83 Linux
/dev/vda2 8194048 9242623 524288 82 Linux swap / Solaris
/dev/vda3 9242624 9644031 200704 8e Linux LVM
命令(输入 m 获取帮助):n
Partition type:
p primary (3 primary, 0 extended, 1 free)
e extended
Select (default e): p
已选择分区 4
起始 扇区 (9644032-16777215,默认为 9644032):
将使用默认值 9644032
Last 扇区, +扇区 or +size{K,M,G} (9644032-16777215,默认为 16777215):+3G
分区 4 已设置为 Linux 类型,大小设为 3 GiB

命令(输入 m 获取帮助):w
[root@system1 ~]# partprobe /dev/vda
[root@system1 ~]# targetcli
/> ls /
/> /backstores/block create iscsi_vol /dev/vda4
/> ls
o- / … […]
o- backstores … […]
| o- block … [Storage Objects: 1]
| | o- iscsi_vol … [/dev/vda4 (3.0GiB) write-thru deactivated]
| o- fileio … [Storage Objects: 0]
| o- pscsi … [Storage Objects: 0]
| o- ramdisk … [Storage Objects: 0]
o- iscsi … [Targets: 0]
o- loopback … [Targets: 0]
/> /iscsi create iqn.2014-09.com.example.domain11:system1
/> cd /iscsi/iqn.2014-09.com.example.domain11:system1/tpg1/
/iscsi/iqn.20…:system1/tpg1> acls/ create iqn.2014-09.com.example.domain11:xx 名字随便写一个
/iscsi/iqn.20…:system1/tpg1> luns/ create /backstores/block/iscsi_vol
/iscsi/iqn.20…:system1/tpg1> ls /
/iscsi/iqn.20…:system1/tpg1> portals/ create 0.0.0.0 3260
/iscsi/iqn.20…:system1/tpg1> ls /
o- / … […]
o- backstores … […]
| o- block … [Storage Objects: 1]
| | o- iscsi_vol … [/dev/vda4 (3.0GiB) write-thru activated]
| o- fileio … [Storage Objects: 0]
| o- pscsi … [Storage Objects: 0]
| o- ramdisk … [Storage Objects: 0]
o- iscsi … [Targets: 1]
| o- iqn.2014-09.com.example.domain11:system1 … [TPGs: 1]
| o- tpg1 … [no-gen-acls, no-auth]
| o- acls … [ACLs: 1]
| | o- iqn.2014-09.com.example.domain11:xx … [Mapped LUNs: 1]
| | o- mapped_lun0 … [lun0 block/iscsi_vol (rw)]
| o- luns … [LUNs: 1]
| | o- lun0 … [block/iscsi_vol (/dev/vda4)]
| o- portals … [Portals: 1]
| o- 0.0.0.0:3260 … [OK]
o- loopback … [Targets: 0]
/iscsi/iqn.20…:system1/tpg1> exit
[root@system1 ~]# firewall-cmd --add-rich-rule ‘rule family=“ipv4” source address=“192.168.122.200/24” port port=“3260” protocol=“tcp” accept’
[root@system1 ~]# firewall-cmd --add-rich-rule ‘rule family=“ipv4” source address=“192.168.122.200/24” port port=“3260” protocol=“tcp” accept’ --permanent
[root@system1 ~]# systemctl restart firewalld.service

20.配置iSCSI的客户端
配置system2使其能连接在system1的上提供的iqn.2014-09.com.example.domain11:system1并符合以下要求:
iSCSI设备在系统启动的期间自动加载
块设备iSCSI上包含一个大小为1700MiB的分区,并格式化为xfs
此分区挂载在/mnt/data上同时在系统启动的期间自动挂载
[root@system2 ~]# yum install iscsi* -y
[root@system2 ~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2014-09.com.example.domain11:xx
[root@system2 ~]# systemctl start iscsid
[root@system2 ~]# systemctl enable iscsid
[root@system2 ~]# iscsiadm -m discovery -t st -p system1.rhce.cc -l
192.168.122.100:3260,1 iqn.2014-09.com.example.domain11:system1
Logging in to [iface: default, target: iqn.2014-09.com.example.domain11:system1, portal: 192.168.122.100,3260] (multiple)
Login to [iface: default, target: iqn.2014-09.com.example.domain11:system1, portal: 192.168.122.100,3260] successful.
[root@system2 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 3G 0 disk
vda 253:0 0 8G 0 disk
├─vda1 253:1 0 3.9G 0 part /
├─vda2 253:2 0 512M 0 part [SWAP]
└─vda3 253:3 0 196M 0 part
└─vg0-vo 252:0 0 192M 0 lvm /home
[root@system2 ~]# fdisk /dev/sda
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认 1):
起始 扇区 (8192-6291455,默认为 8192):
将使用默认值 8192
Last 扇区, +扇区 or +size{K,M,G} (8192-6291455,默认为 6291455):+1700M
分区 1 已设置为 Linux 类型,大小设为 1.7 GiB

命令(输入 m 获取帮助):w
[root@system2 ~]# mkfs.xfs /dev/sda1
[root@system2 ~]# vim /etc/fstab
/dev/sda1 /mnt/data xfs defaults,_netdev 0 0
[root@system2 ~]# mkdir /mnt/data
[root@system2 ~]# mount -a
[root@system2 ~]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/vda1 xfs 3.9G 1.3G 2.7G 32% /
devtmpfs devtmpfs 492M 0 492M 0% /dev
tmpfs tmpfs 498M 0 498M 0% /dev/shm
tmpfs tmpfs 498M 6.6M 491M 2% /run
tmpfs tmpfs 498M 0 498M 0% /sys/fs/cgroup
/dev/mapper/vg0-vo xfs 189M 9.9M 179M 6% /home
//system1/miscellaneous cifs 3.9G 1.6G 2.4G 39% /mnt/multi
system1.rhce.cc:/public nfs4 3.9G 1.6G 2.4G 39% /mnt/nfsmount
system1.rhce.cc:/protected nfs4 3.9G 1.6G 2.4G 39% /mnt/nfssecure
/dev/sda1 xfs 1.7G 33M 1.7G 2% /mnt/data

21.配置一个数据库
在system1上创建一个MariaDB数据库,名为Contacts,并符合以下条件:
数据库应该包含来自数据库复制的内容,复制文件的URL为http://rhgls.rhce.cc/materials/users.mdb。
数据库只能被localhost访问。
除了root用户,此数据库只能被用户Luigi查询。此用户密码为redhat。
root用户的密码为redhat,同时不允许空密码登录。
[root@system2 ~]# yum install mariadb-server mariadb -y
[root@system2 ~]# systemctl start mariadb
[root@system2 ~]# systemctl enable mariadb
[root@system2 ~]# mysql
MariaDB [(none)]> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
±-------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> create database Contacts;
MariaDB [(none)]> quit
[root@system2 ~]# wget http://rhgls.rhce.cc/materials/users.mdb
[root@system2 ~]# mysql
MariaDB [Contacts]> source /root/users.mdb
MariaDB [Contacts]> show tables;
±-------------------+
| Tables_in_Contacts |
±-------------------+
| loc |
| name |
| pass |
±-------------------+
3 rows in set (0.00 sec)

MariaDB [Contacts]> grant select on Contacts.* to Luigi@‘localhost’ identified by ‘redhat’;
MariaDB [Contacts]> set password=password(‘redhat’);
MariaDB [Contacts]> quit

22.数据库查询
在系统system1上使用数据库Contacts,并使用相应的SQL查询以回答下列问题:
密码是tangerine的人的名字?
有多少人的姓名是John同时居住在SantaClara?
[root@system2 ~]# mysql -u root -predhat
MariaDB [(none)]> use Contacts;
MariaDB [Contacts]> show tables;
±-------------------+
| Tables_in_Contacts |
±-------------------+
| loc |
| name |
| pass |
±-------------------+
3 rows in set (0.00 sec)

MariaDB [Contacts]> desc loc;
±--------±------------±-----±----±--------±------+
| Field | Type | Null | Key | Default | Extra |
±--------±------------±-----±----±--------±------+
| cid | int(11) | YES | | NULL | |
| loction | varchar(20) | YES | | NULL | |
±--------±------------±-----±----±--------±------+
2 rows in set (0.00 sec)

MariaDB [Contacts]> desc name;
±----------±------------±-----±----±--------±------+
| Field | Type | Null | Key | Default | Extra |
±----------±------------±-----±----±--------±------+
| aid | int(11) | YES | | NULL | |
| firstname | varchar(10) | YES | | NULL | |
| lastname | varchar(10) | YES | | NULL | |
±----------±------------±-----±----±--------±------+
3 rows in set (0.00 sec)

MariaDB [Contacts]> desc pass;
±---------±------------±-----±----±--------±------+
| Field | Type | Null | Key | Default | Extra |
±---------±------------±-----±----±--------±------+
| bid | int(11) | YES | | NULL | |
| password | varchar(10) | YES | | NULL | |
±---------±------------±-----±----±--------±------+
2 rows in set (0.00 sec)

MariaDB [Contacts]> select * from name join pass where name.aid=pass.bid;
±-----±----------±---------±-----±----------+
| aid | firstname | lastname | bid | password |
±-----±----------±---------±-----±----------+
| 1 | tom | li | 1 | redhat1 |
| 2 | bob | zhao | 2 | redhat2 |
| 4 | John | li | 4 | redhat |
| 5 | John | wang | 5 | redhat |
±-----±----------±---------±-----±----------+
5 rows in set (0.00 sec)

MariaDB [Contacts]> select * from name join pass where name.aid=pass.bid and password=‘tangerine’;
±-----±----------±---------±-----±----------+
| aid | firstname | lastname | bid | password |
±-----±----------±---------±-----±----------+
| 3 | mary | wang | 3 | tangerine |
±-----±----------±---------±-----±----------+
1 row in set (0.00 sec)

MariaDB [Contacts]> select * from name join loc where name.aid=loc.cid and firstname=‘john’ and loction=‘Santa Clara’;
±-----±----------±---------±-----±------------+
| aid | firstname | lastname | cid | loction |
±-----±----------±---------±-----±------------+
| 5 | John | wang | 5 | Santa Clara |
±-----±----------±---------±-----±------------+
1 row in set (0.01 sec)

MariaDB [Contacts]> select count() from name join loc where name.aid=loc.cid and firstname=‘john’ and loction=‘Santa Clara’;
±---------+
| count(
) |
±---------+
| 1 |
±---------+
1 row in set (0.00 sec)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值