搭建主从DNS、nfs、nginx

devtools/2025/3/22 16:54:06/

任务需求:

客户端通过访问 www.nihao.com 后,能够通过 dns 域名解析,访问到 nginx 服务中由 nfs 共享的首页文件,内容为:Very good, you have successfully set up the system. 各个主机能够实现时间同步,并且都开启防火墙来保证服务安装。

主机规划:

作用系统IP主机名软件
web 服务器redhat9.5192.168.72.8webnginx
nfs 服务器redhat9.5192.168.72.9nfsnfs-utils
DNS 主服务器redhat9.5192.168.72.18dns1bind
DNS 从服务器redhat9.5192.168.72.28dns2bind
客户端redhat9.5192.168.72.7clientbind-utils

一、修改IP地址和主机名:

web服务器

[root@localhost ~]# hostnamectl hostname web
[root@localhost ~]# nmcli c modify ens160 ipv4.method manual ipv4.addresses 192.168.72.8/24 ipv4.gateway 192.168.72.2 ipv4.dns 223.5.5.5 connection.autoconnect yes
[root@localhost ~]# nmcli c up ens160

nfs服务器

[root@localhost ~]# hostnamectl hostname nfs
[root@localhost ~]# nmcli connection modify ens160 ipv4.addresses 192.168.72.9/24 ipv4.gateway 192.168.72.2 ipv4.dns 223.5.5.5 ipv4.method manual connection.autoconnect yes
[root@localhost ~]# nmcli connection up ens160 

DNS主服务器

[root@localhost ~]# hostnamectl hostname dns1
[root@localhost ~]# nmcli c modify ens160 ipv4.method manual ipv4.addresses 192.168.72.18/24 ipv4.gateway 192.168.72.2 ipv4.dns 223.5.5.5 connection.autoconnect yes
[root@localhost ~]# nmcli c up ens160

DNS从服务器

[root@localhost ~]# hostnamectl hostname dns2
[root@localhost ~]# nmcli c modify ens160 ipv4.method manual ipv4.addresses 192.168.72.28/24 ipv4.gateway 192.168.72.2 ipv4.dns 223.5.5.5 connection.autoconnect yes
[root@localhost ~]# nmcli c up ens160

客户端: 

[root@localhost ~]# hostnamectl hostname client
[root@localhost ~]# nmcli c modify ens160 ipv4.method manual ipv4.addresses 192.168.72.7/24 ipv4.gateway 192.168.72.2 ipv4.dns "192.168.72.18 192.168.72.28" connection.autoconnect yes
[root@localhost ~]# nmcli c up ens160

二、配置nfs服务器

下载nfs服务:

[root@nfs ~]# dnf install nfs-utils -y

放行http、nfs服务,关闭selinux。 

[root@nfs ~]# setenforce 0
[root@nfs ~]# firewall-cmd --permanent --add-service=http
[root@nfs ~]# firewall-cmd --permanent --add-service=nfs
[root@nfs ~]# firewall-cmd --reload 

创建文件并共享给nginx服务器

[root@nfs ~]# mkdir /nfs/data -p
[root@nfs ~]# vim /etc/exports
[root@nfs ~]# cat /etc/exports
/nfs/data 192.168.72.8(rw)

启动服务检查是否暴露,并给/nfs添加写的权限

[root@nfs ~]# systemctl restart nfs-server.service 
[root@nfs ~]# showmount -e 192.168.72.9
[root@nfs ~]# chmod o+w /nfs/ -R

三、配置Web服务

下载nginx、nfs服务

[root@web ~]# dnf install nginx -y
[root@web ~]# dnf install nfs-utils -y

放行http,nfs服务 关闭selinux

[root@web ~]#firewall-cmd --permanent --add-service=http
[root@web ~]#firewall-cmd --reload 
[root@web ~]#firewall-cmd --permanent --add-service=nfs
[root@web ~]#firewall-cmd --reload 
[root@web ~]# setenforce 0

创建一个nihao.conf的配置文件,写入www.nihao.com的配置服务

[root@web conf.d]# cat nihao.conf 
server{server_name	www.nihao.com ;root	/var/www/nihao;
}

挂载到nfs,并创建页面内容

[root@web conf.d]# mount -t nfs 192.168.72.9:/nfs/data /var/www/
[root@web conf.d]# mkdir -p /var/www/nihao
[root@web conf.d]# echo " Very good, you have successfully set up the system. " > /var/www/nihao/index.html

四、DNS主服务器配置 

安装DNS服务

[root@dns1 ~]# dnf install bind -y

修改主配置文件

[root@dns1 ~]# cat /etc/named.conf 
options {listen-on port 53 { 192.168.72.18; };directory 	"/var/named";
};zone "nihao.com" IN {type master;file "nihao.com";
};

 配置区域数据文件

[root@DNS-one ~]# cat /var/named/nihao.com 
$TTL 1D
@	IN	SOA	@	admin.nihao.com. (0	1	1	1	1)IN	NS	ns1IN	NS	ns2
ns1	IN	A	192.168.72.18
ns2	IN	A	192.168.72.28
www	IN	A	192.168.72.8

放行dns服务关闭selinux,启动服务

[root@dns1 ~]# setenforce 0
[root@dns1 ~]# firewall-cmd --permanent --add-service=dns
[root@dns1 ~]# firewall-cmd --reload
[root@dns1 ~]# systemctl restart named

五、DNS从服务器配置

 安装DNS服务

[root@dns2 ~]# dnf install bind -y

修改主配置文件

[root@dns2 ~]# cat /etc/named.conf 
options {listen-on port 53 { 192.168.72.28; };directory 	"/var/named";
};zone "nihao.com" IN {type slave;masters { 192.168.72.18; };file "slaves/nihao.com";
};

放行防火墙,关闭selinux,开启服务

[root@dns2 ~]# firewall-cmd --permanent --add-service=dns
[root@dns2 ~]# firewall-cmd --reload
[root@dns2 ~]# setenforce 0
[root@dns2 ~]# systemclt restart named


http://www.ppmy.cn/devtools/169195.html

相关文章

多模态大模型:将音频向量化

将音频向量化是将音频数据转化为适合机器学习算法处理的向量表示的过程。这个过程通常涉及从原始音频信号中提取特征,并将这些特征转化为数字向量。以下是几种常见的音频向量化方法: 1. 梅尔频率倒谱系数 (MFCC) 概念:MFCC 是一种常用的音频特征提取方法,特别是在语音识别…

深度学习评价指标(混淆矩阵、精确率、召回率、F1 score...)

混淆矩阵 混淆矩阵(Confusion Matrix)是在机器学习领域中用来评估分类算法性能的一种矩阵。它是一个二维矩阵,用于比较模型预测结果和实际标签之间的差异。混淆矩阵的行表示实际类别,列表示预测类别,矩阵的每个元素表…

前端面试:[React] scheduler 调度机制原理?

React Scheduler 是 React 16.8 引入的一种调度机制,旨在对高效渲染和复杂应用程序的性能进行优化。它允许 React 在空闲时间进行渲染,优先处理对用户体验最为重要的任务。以下是 Scheduler 调度机制的原理,以及它在实际工作中如何帮助管理渲…

工业数据驱动智能维护的深度调研报告

工业数据驱动智能维护的深度调研报告 一、工业数据现状与核心挑战 工业领域数据具有高价值但利用率低的特点。据统计,企业仅采集了56%的可用数据,剩余44%的振动、扭矩、PLC实时数据等未被有效采集。数据分散在PLC、SCADA、DCS等系统中,形成孤…

前端导出Excel终极方案:纯前端实现表格数据导出(兼容主流浏览器)

引言 在Web开发中,导出Excel功能是常见需求。传统方案通常需要后端配合生成文件,但今天我们将介绍一种纯前端实现方案,通过HTML模板Base64编码实现Excel导出,无需依赖后端服务。本文将详细解析代码实现原理,并提供可直…

go~协程阻塞分析

错误示例 type chanData struct {result stringerror error }func Biz1() {t : time.NewTimer(time.Second * 10)ctx : context.Background()ch : make(chan chanData)go doChan(ctx, ch)fmt.Println("Biz1 begin")for {select {case <-t.C:fmt.Println("B…

$.ajax的contentType设置及对应后端数据获取方式

在使用 jQuery 的 $.ajax 方法进行 HTTP 请求时&#xff0c;contentType 参数用于指定发送到服务器的数据的编码类型。常见的 contentType 设置包括 application/json 和 application/x-www-form-urlencoded; charsetUTF-8。以下是对这两种 contentType 的详细对比和说明&#…

网络编程之解除udp判断客户端是否断开

思路&#xff1a;每几秒发送一条不显示的信息&#xff0c;客户端断开则不再发送信息&#xff0c;超时则表示客户端断开连接。&#xff08;心跳包&#xff09; 服务器 #include <head.h>#define MAX_CLIENTS 100 // 最大支持100个客户端 #define TIMEOUT 5 // 5秒…