RH135测试答案!

题目:

1.请设定您虚拟机server 和 client 的基本信息要求如下

@@@@在server主机中:@@@@
*建立sshd服务的秘钥认证,认证用户为root,
秘钥下载地址为http://172.25.254.250/exam/id_rsa.pub

*设定root用户密码为westos

*IPADDRESS=172.25.254.129
GATEWAY=172.25.254.250
DNS=172.25.254.250

*搭建本地软件仓库并可以使直连网络主机使用仓库地址 http://172.25.254.129/rhel8

*在主机中添加两块硬盘要求如下
vdb 5G
vdc 5G

@@@@在client主机中:@@@@

*建立sshd服务的秘钥认证,认证用户为root,
秘钥下载地址为http://172.25.254.250/exam/id_rsa.pub

*设定root用户密码为westos

*IPADDRESS=172.25.254.229
GATEWAY=172.25.254.250
DNS=172.25.254.250

*搭建本地软件仓库并可以使直连网络主机使用仓库地址 http://172.25.254.129/rhel8

2.在vdb中建立分区并完成以下要求
*新建分区/dev/vdb1,大小为500M,并把设备做为swap分区激活

*新建分区/dev/vdb2,大小100M,并把设备挂载到/westos_pub目录中
设定/westos_pub目录对所有人可写,确保westos用户只能使用50M的数据空间

*新建lvm设备,组名称为westos_vg,pe大小为2M,在westos_vg中建立westos_datal逻辑卷
把逻辑卷挂载到/westos/westoslv中

注意:以上操作确保在开机时仍然生效

3.开启系统中的selinux并设定默认状态为强制模式

4.部署ftp服务可以实现匿名用户的上传功能

5.部署apache要求如下
*设定apache的默认发布目录为/westos/html并确保默认发布内容和下列文件一致
http://172.25.254.250/exam/index_default

*设定虚拟主机bbs.westos.com 确保当前主机中的解析成立,默认发布页面内容和下列文件一致
http://172.25.254.250/exam/index_bbs

6.配置 iSCSI 服务:
*在 server129 上安装服务端程序,设置开机自启,防火墙允许此服务

*在vdb磁盘上分一个1G大小的LVM分区,用以创建逻辑卷组iSCSI_vg和一个100M大小的逻辑卷disk1_lv

*使用 disk1_lv 作为 iSCSI 的后端存储名称为 server129.disk1

*定义IQN为 iqn.2020-04.com.westos:server129

*设置ACL允许initiator name为iqn.2020-04.com.westos:client229的客户端可以连接
程序监听172.25.254.129的3260端口

*client安装客户端程序,连接server129的iSCSI目标资源到本地
用以创建一个xfs文件系统,并开机自动挂载到/iscsidisk

7.配置 Mariadb 数据库服务:
*在 server129上安装 mariadb 数据库,开机自启动,防火墙允许此服务。
给数据库设置 root 管理员密码为 westos
限制 root 用户只能从localhost 登录,移除匿名用户,删除 test 库。

*创建一个名为 redhat 的库,并从备份文件中恢复数据到此数据库,
备份文件的位置在:
http://classroom.example.com/pub/materials/mariadb/mariadb.dump 。

*创建数据库用户 mary ,对 redhat 数据库具有查询、插入、更新、删除权限
密码为 mary_passwd
natasha 用户可以从 client129上登录数据库,
对 redhat 库拥有查询权限,密码为natasha_passwd 。

  1. 配 SMB 服务:
    *在 server129 上配置 smb 共享服务,要求开机自启,防火墙允许此服务。
    *创建共享目录为 /smbshare ,共享名为 smbshare ,
    marketing 组成员可以读写此共享
    不属于marketing 组的人只能读。

*创建 samba-only 用户 brian 和 rob
其中 brian 用户属于marketing 组,用户密码都是 westos。

  • 在 client129 上建立挂载点 /mnt/multiuser 目录
    开机自动挂载server129 上的 smbshare 共享
    激活 smb 多用户挂载支持。

答案

做完之后自己reboot重启后服务要都自动开机自启,才算成功!

第一题111111111111111111111111111111111111111
<1><1><1><1><1><1><1><1><1>v<1><1>v<1><1><1>
cd /root/.ssh
wget http://172.25.254.250/exam/id_rsa.pub /root/.ssh
ssh-keygen
ssh-copy-id -i /root/.ssh/id_rsa.pub root@172.25.254.230
ssh -l root 172.25.254.230 :不需要密码!
echo westos | passwd --stdin root
<2><2><2><2><2><2><2><2><2><2><2><2><2><2><2>
vim /etc/sysconfig/network-scripts/if–
IPADDRESS=172.25.254.130
GATEWAY=172.25.254.250
DNS=172.25.254.250
<3><3><3><3><3><3><3><3><3><3><3><3><3><3>
df
mount /dev/sr0 /westos
dnf install httpd.x86_64

firewall-cmd --permanent --add-service=http
firewall-cmd --reload
umount /westos
mkdir -p /westos/html/rhel8
chcon -Rt httpd_sys_content_t /westos/html
semanage fcontext -a -t httpd_sys_content_t ‘/westos/html(/.*)?’
ls -Zd /westos/html

mount /dev/sr0 /westos/html/rhel8
开机自欺:
vim /etc/fstab
/dev/sr0 /westos/html/rhel8 iso9660 defaults 0 0

vim /etc/yum.repos.d/westos.repo
[AppStream]
baseurl = http://172.25.254.130/rhel8/AppStream
enabled = 1
gpgcheck = 0
name = AppStream
[BaseOS]
baseurl = http://172.25.254.130/rhel8/BaseOS
enabled = 1
gpgcheck = 0
name = BaseOS

vim /etc/httpd/conf/httpd.conf
122 : DocumentRoot “/westos/html”
127 : <Directory “/westos/html”>
134 :<Directory “/westos/html”>

systemctl restart httpd

**http://172.25.254.130/rhel8/-------->可以访问到镜像资源

在229上执行一样的操作!!
vim /etc/yum.repos.d/westos.repo
[AppStream]
baseurl = http://172.25.254.130/rhel8/AppStream
enabled = 1
gpgcheck = 0
name = AppStream
[BaseOS]
baseurl = http://172.25.254.130/rhel8/BaseOS
enabled = 1
gpgcheck = 0
name = BaseOS

wget http://172.25.254.250/exam/id_rsa.pub /root/.ssh
cd /root/.ssh
ssh-keygen
ssh-copy-id -i /root/.ssh/id_rsa.pub root@172.25.254.130
ssh -l root 172.25.254.130
echo westos | passwd --stdin root

vim /etc/sysconfig/network-scripts/if–
IPADDRESS=172.25.254.230
GATEWAY=172.25.254.250
DNS=172.25.254.250

在真机上执行
cd /var/lib/libvirt/images/

qemu-img create -f qcow2 westosa1_disk.qcow2 5G -o lazy_refcounts=off
qemu-img create -f qcow2 westosa2_disk.qcow2 5G -o lazy_refcounts=off
然后virt-manager 选择灯泡 添加硬盘!!

在129上
fdisk -l 可以看到 vdb vdc!!

第二题2222222222222222222222222222222222222222222222
<1><1><1><1><1><1><1><1><1><1><1><1><1><1><1><1><1><1>
fdisk /dev/vdb n p enter enter +500M p wq

fdisk /dev/vdb n p enter enter +100M p wq
fdisk /dev/vdb
t 1 l
(82 Linux swap !这个看自己查到的是多少号1) p wq

mkswap /dev/vdb1
swapon /dev/vdb1

mkfs.xfs /dev/vdb2
mkdir /westos_pub/
mount -o usrquota /dev/vdb2 /westos_pub/
chmod 777 /westos_pub/
quotaon -uv /dev/vdb2

edquota --user westos

/dev/vdb2 51200 0 51200 1 0 0

测试:
su - westos
dd if=/dev/zero of=/westos_pub/westosfile1 bs=1M count=60
然后汇报错! error writing ‘/westos_pub/westosfile1’: Disk quota exceeded
<2><2><2><2><2><2><2><2><2><2><2><2><2><2><2><2><2><2><2>
mkdir /westos/westoslv -p
fdisk /dev/vdb n p 3 enter +1G p t 8e wq
pvcreate /dev/vdb3
vgcreate -s 2M westos_vg /dev/vdb3
lvcreate -L 300M -n westos_datal westos_vg
mkfs.xfs /dev/westos_vg/westos_datal
mount /dev/westos_vg/westos_datal /westos/westoslv/
检查重启!!!

开机时仍然生效!!
vim /etc/fstab----->永久挂载文件
/dev/westos_vg/westos_datal /westos/westoslv xfs defaults 0 0
/dev/vdb2 /westos_pub xfs defaults,usrquota 0 0
/dev/vdb1 swap swap defaults 0 0

mount -a

第三题3333333333333333333333333333333333333333333333333333333
vim /etc/sysconfig/selinux

7: SELINUX=enforcing
第四题4444444444444444444444444444444444444444444444444444444

dnf install lftp -y
dnf install vsftpd.x86_64
systemctl enable --now vsftpd

semanage fcontext -a -t public_content_rw_t ‘/var/ftp/pub(/.*)?’
restorecon -RvvF /var/ftp/pub/
ls -Zd /var/ftp/pub/

getsebool -a | grep ftp
setsebool -P ftpd_anon_write on -P
vim /etc/vsftpd/vsftpd.conf
12 : anonymous_enable=YES
29 : anon_upload_enable=YES

systemctl restart vsftpd
chmod 775 /var/ftp/pub
chgrp ftp /var/ftp/pub
lftp 172.25.254.130
cd pub put /etc/passwd 可以成功上传!

第五题555555555555555555555555555555555555555555555555555555555
cd /westos/html
vim index.html

在该文件查看:
http://172.25.254.250/exam/index_default
应该是default page

vim /etc/httpd/conf/httpd.conf
前面修改过!!


122 DocumentRoot “/westos/html”

127 <Directory “/westos/html”>
128 AllowOverride None
129 # Allow open access:
130 Require all granted


ls -Zd /westos/html
cat /westos/html/index.html
systemctl restart httpd

访问:
http://172.25.254.130/
default page

<2><2><2><2><2><2><2><2><2><2><2><2><2><2><2><2><2><2><2>

mkdir -p /westos/bbs.com/html
ls -Zd /westos/bbs.com/html
chcon -Rt httpd_sys_content_t /westos/bbs.com/html/
ls -Zd /westos/bbs.com/html/

vim /westos/bbs.com/html/index.html

bbs page

cd /etc/httpd/conf.d
vim vhost.conf


DocumentRoot "/westos/html" CustomLog logs/default.log combined

<VirtualHost *:80>
ServerName bbs.westos.com
DocumentRoot “/westos/bbs.com/html”
CustomLog logs/bbs.log combined

<Directory /westos/bbs.com/html>
AllowOverride none
Require all granted


systemctl restart httpd

在真机和虚拟机都作:
vim /etc/hosts
172.25.254.130 bbs.westos.com
访问 bbs.westos.com

第六题66666666666666666666666666666666666666666666666666
dnf install targetcli -y

firewall-cmd --permanent --add-service=iscsi-target
firewall-cmd --reload
firewall-cmd --add-port=3260/tcp --permanent
firewall-cmd --reload

systemctl enable --now target
systemctl enable --now iscsi
systemctl enable --now iscsid

fdisk /dev/vdb
n enter enter +1G p wq
fdisk -l

fdisk /dev/vdb
t 4 l 8e p wq

pvcreate /dev/vdb4
vgcreate ISCSI_vg /dev/vdb4
lvcreate -L 100M -n disk1_lv ISCSI_vg

mkfs.xfs /dev/ISCSI_vg/disk1_lv
targetcli

backstores/block create server130.disk1 /dev/ISCSI_vg/disk1_lv

iscsi/ create iqn.2020-04.com.westos:server130
iscsi/iqn.2020-04.com.westos:server130/tpg1/luns create /backstores/block/server130.disk1

iscsi/iqn.2020-04.com.westos:server130/tpg1/acls create iqn.2020-04.com.westos:westoskey

程序监听
cd iscsi/iqn.2020-04.com.westos:server101/tpg1/portals/
delete 0.0.0.0 3260
cd …
cd …
cd …
cd …
scsi/iqn.2020-04.com.westos:server130/tpg1/portals/ create 172.25.254.130 3260
exit

systemctl enable --now iscsid
systemctl enable --now iscsi

打开230主机:
systemctl enable --now iscsi

systemctl enable --now iscsid
dnf install iscsi-initiator-utils -y
vim /etc/iscsi/initiatorname.iscsi
iqn.2020-04.com.westos:westoskey

systemctl restart iscsid

systemctl restart iscsi
iscsiadm -m discovery -t st -p 172.25.254.130

iscsiadm -m node -T iqn.2020-04.com.westos:server130 -p 172.25.254.130 -l

fdisk -l
fdisk /dev/sda
n p 1 enter enter p wq

fdisk -l
mkfs.xfs /dev/sda1
mkdir /iscsidisk
vim /etc/fstab


/dev/sda1 /iscsidisk xfs defaults,_netdev 0 0


mount -a

第七题77777777777777777777777777777777777777777777777777777777777777777777777
<1><1><1><1><1><1><1>
dnf install mariadb-server -y
systemctl enable --now mariadb
firewall-cmd --permanent --add-service=mysql
mysql_secure_installation
两个enter后安密码:
westos
然后:全按enter

mysql -uroot -p
grant all privileges on . to root@localhost identified by “westos”;
use mysql;
select user, host from user;
delete from user where user=’’;
select user, host from user;
drop database test;

<2><2><2><2><2><2><2><2><2><2><2><2><2><2>
mysql -uroot -pwestos
CREATE DATABASE redhat;
mkdir /westos/html/pub/materials/mariadb -p
mysqldump -uroot -pwestos redhat > /westos/html/pub/materials/mariadb/mariadb.dump
mysql -uroot -pwestos redhat < /westos/html/pub/materials/mariadb/mariadb.dump

在真机:和130s上:
vim /etc/hosts
classroom.example.com
访问:
http://classroom.example.com/pub/materials/mariadb/mariadb.dump
<3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3>

mysql -uroot -pwestos
CREATE USER mary@’%’ identified by ‘mary_passwd’;
SELECT Host,User,Password FROM mysql.user;
GRANT SELECT,INSERT,UPDATE,DELETE on redhat.* to mary@’%’;
show grants for mary@’%’;

CREATE USER natasha@'%' identified by 'natasha_passwd';
SELECT User,Host FROM mysql.user;
GRANT SELECT on redhat.* to natasha@'%';

检查:: !!!
mysql -umary -pmary_passwd

mysql -unatasha -pnatasha_passwd

**开机自欺 数据库!!

第8题888888888888888888888888888888888888888888888888888888888888888888888888
<1><1><1><1><1><1><1><1><1><1><1><1><1><1>
dnf install samba samba-client samba-common -y
systemctl enable --now smb.server
firewall-cmd --permanent --add-service=samba
firewall-cmd --reload

<2><2><2><2><2><2><2><2><2><2><2><2><2><2>
mkdir /smbshare
chcon -t samba_share_t /smbshare/
cp /etc/samba/smb.conf.example /etc/samba/smb.conf
yes
vim /etc/samba/smb.conf


[314] [smbshare]
[315] comment = smb
[316] path = /smbshare
[317] write list = +marketing


systemctl restart smb.service
smbclient -L //172.25.254.130/smbshare
westos
chmod 777 /smbshare
groupadd marketing
useradd -G marketing linux

smbpasswd -a linux
westos
pdbedit -L
开机自动挂载
dnf install autofs -y
systemctl enable --now autofs.service

测试: mount -o username=linux,password=westos //172.25.254.130/smbshare /mnt
df
cd /mnt/
touch westos
ls
<3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3><3>
useradd -s /sbin/nologin brian -M
useradd -s /sbin/nologin rob -M

smbpasswd -a brian
westos
smbpasswd -a rob
westos
pdbedit -L

usermod -G marketing brian
id brian

<4><4><4><4><4><4><4><4><4><4><4><4><4><4><4><4><4>

客户端CLIENT 230:和130都作一下!!

dnf install cifs-utils -y
vim /etc/auto.master
/mnt /etc/auto.cifs

vim /etc/auto.cifs
multiuser -fstype=cifs,credentials=/root/smbauth,multiuser,sec=ntlmssp 😕/172.25.254.130/smbshare

vim /root/smbpass


username=linux
password=westos


vim /etc/fstab

//172.25.254.104/smbshare /mnt/multiuser cifs defaults,credentials=/root/smbpass,multiuser,sec=ntlmssp 0 0

cd
mkdir /mnt/multiuser
umount /mnt
mount -a
df

su - westos
df
cd /mnt/multiuser
ll
ls: cannot open directory ‘.’: Permission denied

cifscreds add -u linux 172.25.254.129

(如果还不行: cifscreds update -u linux 172.25.254.129)

ll

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

dudududu--

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值