【RHCE】综合实验0710综合实验

题目:

主服务器192.168.244.130

防火墙允许服务的放行:

selinux放行

复制代码
[root@localhost ~]# ll -Z /nfs/rhce
总用量 4
-rw-r--r--. 1 root   root   unconfined_u:object_r:default_t:s0 8  7月 10 16:52 index.html
-rw-r--r--. 1 nobody nobody system_u:object_r:default_t:s0     0  7月 11 19:55 test
[root@localhost ~]# ll -Z /var/www
总用量 0
drwxr-xr-x. 2 root root system_u:object_r:httpd_sys_script_exec_t:s0 23  7月  4 16:50 cgi-bin
drwxr-xr-x. 2 root root system_u:object_r:httpd_sys_content_t:s0     24  7月  3 12:04 html
[root@localhost ~]# chcon -t httpd_sys_content_t /nfs/rhce
 -R
[root@localhost ~]# ll -Z /nfs/rhce
总用量 4
-rw-r--r--. 1 root   root   unconfined_u:object_r:httpd_sys_content_t:s0 8  7月 10 16:52 index.html
-rw-r--r--. 1 nobody nobody system_u:object_r:httpd_sys_content_t:s0     0  7月 11 19:55 test
[root@localhost ~]# setenforce 1

编辑配置文件:(httpd的配置,利于域名访问与web内容的访问)

复制代码
<directory /nfs/rhce>
allowoverride none
require granted
</directory>

<virtualhost 192.168.244.130>
documentroot /nfs/rhce
servername www.rhce.com
</virtualhost>

部署web服务在/nfs/rhce中,并且/nfs/rhce为共享目录及文件

复制代码
[root@localhost /]# mkdir nfs
[root@localhost /]# ll
drwxr-xr-x.   2 root    root       6  7月 10 16:41 nfs
[root@localhost /]# cd nfs/
[root@localhost nfs]# mkdir rhce
[root@localhost nfs]# echo i am ok > index.html
[root@localhost nfs]# cat index.html
i am ok

配置主服务器的主配置文件(此步骤为主从服务器的文件共享查看路径的连接/nfs)

重启服务并测试是否成功

复制代码
[root@localhost ~]# systemctl restart nfs-server
[root@localhost ~]# systemctl restart rpcbind
[root@localhost ~]# showmount -e 192.168.244.130
Export list for 192.168.244.130:
/nfs/rhce 12.168.244.137
[root@localhost ~]# 

配置本地解析地址:

复制代码
[root@localhost conf.d]# vim /etc/hosts
192.168.244.130 www.rhce.com
[root@localhost conf.d]# curl www.rhce.com
i am ok

配置主服务器的dns

cd /etc/named.conf主配置文件

复制代码
options {
	listen-on port 53 { 192.168.244.130; };
	directory		"/var/named";
};
zone "rhce.com" IN {
	type master;
	file "named.rhce";
};

区域文件:cd /var/named/named.rhce,在重启服务

复制代码
$TTL 1D
@       IN SOA  @ admin.rhce.com. ( 
                        0
                        1
                        1
                        1
                        1)
        NS      ns.rhce.com.
ns      A       192.168.244.130
www     A       192.168.244.130
ftp     CNAME   www

重启服务:systemctl restart named

测试dns实现:dig -t A www.rhce.com

从服务器(192.168.244.137)

防火墙打开,允许放行

复制代码
[root@openEuler ~]# firewall-cmd --permanent --add-service=dns
success
[root@openEuler ~]# firewall-cmd --permanent --add-service=http
success
[root@openEuler ~]# firewall-cmd --permanent --add-service=nfs
success
[root@openEuler ~]# firewall-cmd --permanent --add-service=rpc-bind
success
[root@openEuler ~]# firewall-cmd --permanent --add-service=mountd
success
[root@openEuler ~]# firewall-cmd --reload
success
[root@openEuler ~]# firewall-cmd --list-service
dhcpv6-client dns http mdns mountd nfs rpc-bind ssh

开启selinux:setsebool -P httpd_use_nfs 1

设置dns的配置文件,在重启服务

复制代码
[root@openEuler ~]# cat /etc/named.conf 
options {
listen-on port 53 { 192.168.244.137; };
	directory	"/var/named";
};
zone "rhce.com" IN {
	type slave;
	masters{ 192.168.244.130; };
	file "slaves/named.rhce";
};
[root@openEuler ~]# systemctl restart named

在测试是否能访问主服务器的文件

复制代码
[root@openEuler ~]# curl www.rhce.com
i am ok

测试dns的成功:

判断是否能从服务器中去访问主服务器的文件

复制代码
[root@openEuler ~]# showmount -e 192.168.244.130
Export list for 192.168.244.130:
/nfs/rhce 12.168.244.137

挂载文件

复制代码
[root@openEuler ~]# mount 192.168.244.130:/nfs/rhce /haha 
[root@openEuler ~]# ll /haha
total 4
-rw-r--r--. 1 root root 8 Jul 10  2024 index.html
[root@openEuler ~]# df -h /haha
Filesystem                 Size  Used Avail Use% Mounted on
192.168.244.130:/nfs/rhce   70G  6.9G   64G  10% /haha
[root@openEuler ~]#

autofs的自动挂载

下载软件包:yum install autofs -y

在他的主配置编辑单独的目录:vim /etc/auto.master

在重启服务:systemctl restart autofs

复制代码
[root@openEuler ~]# ll /haha/
total 0
[root@openEuler ~]# cd /haha
[root@openEuler haha]# ll
total 0
[root@openEuler haha]# cd nfs
[root@openEuler nfs]# ll
total 4
-rw-r--r--. 1 root   root   8 Jul 10  2024 index.html
-rw-r--r--. 1 nobody nobody 0 Jul 11  2024 test

#进入nfs后,此时此刻自动给你挂载了

[root@openEuler nfs]# cd
[root@openEuler ~]# ll /haha
total 0
drwxrwxrwx. 2 root root 36 Jul 11  2024 nfs

[root@openEuler ~]# df -h /haha
Filesystem      Size  Used Avail Use% Mounted on
/etc/auto.nfs      0     0     0    - /haha
[root@openEuler ~]# 

最后关机重启,自动挂载

复制代码
[root@openEuler ~]# cd /haha
[root@openEuler haha]# ll
total 0
[root@openEuler haha]# cd nfs
[root@openEuler nfs]# ll
total 4
-rw-r--r--. 1 root   root   8 Jul 10 16:52 index.html
-rw-r--r--. 1 nobody nobody 0 Jul 11 19:55 test
[root@openEuler nfs]# cd
[root@openEuler ~]# ll /haha
total 0
drwxrwxrwx. 2 root root 36 Jul 11 19:55 nfs
[root@openEuler ~]# df -h
192.168.244.130:/nfs/rhce    70G  6.9G   64G  10% /haha/nfs
[root@openEuler ~]# 

在主从服务器中所有服务要开机自启

复制代码
[root@openEuler haha]# systemctl enable named
[root@openEuler haha]# systemctl enable rpcbind
[root@openEuler haha]# systemctl enable httpd
[root@openEuler haha]# systemctl enable nfs-server
[root@openEuler haha]# 
相关推荐
海拥✘4 小时前
深入理解 IP 地址:概念、分类与日常应用
网络·网络协议·tcp/ip
Miracle&5 小时前
2.TCP深度解析:握手、挥手、状态机、流量与拥塞控制
linux·网络·tcp/ip
专注API从业者5 小时前
Python/Java 代码示例:手把手教程调用 1688 API 获取商品详情实时数据
java·linux·数据库·python
liulilittle5 小时前
IP校验和算法:从网络协议到SIMD深度优化
网络·c++·网络协议·tcp/ip·算法·ip·通信
Ribou5 小时前
Ubuntu 24.04.2安装k8s 1.33.4 配置cilium
linux·ubuntu·kubernetes
c&0xff005 小时前
Flink反压问题
网络·flink
深圳多奥智能一卡(码、脸)通系统6 小时前
基于多奥(DAIC)品牌的IC卡电梯门禁系统(梯控)基础配置清单,整合核心硬件、软件及安全组件,确保系统可独立运行并支持未来扩展
网络
googleccsdn6 小时前
ESNP LAB 笔记:配置MPLS(Part4)
网络·笔记·网络协议
tan180°6 小时前
Boost搜索引擎 网络库与前端(4)
linux·网络·c++·搜索引擎
小小菜鸡ing6 小时前
pymysql
java·服务器·数据库