CentOS 7 搭建 NFS 服务

2019-01-11  本文已影响0人  Abbott思宇

[TOC]

参考资料

将图片服务和应用服务分离
大型网站架构 图片服务器分离
Nginx服务器上搭建图片缓存服务的基本配置解析
CentOS7 minimal nfs 服务器、客户端和 win7 nfs 客户端
centos7 下nfs的配置
CentOS 7.3 配置NFS

网络拓扑结构

安装配置 nfs 服务

# 包含 nfs 和 rpcbind
yum install -y nfs-utils
/opt/data/dev.reading.zt *(rw,sync,no_root_squash)

# 设置开机启动 rpcbing,nfs
systemctl enable rpcbind
systemctl enable nfs

# 启动 rpcbing,nfs 服务
systemctl start rpcbind
systemctl start nfs

# 防火墙配置
firewall-cmd --permanent --add-service nfs
firewall-cmd --reload

编辑/etc/exports配置文件 vi /etc/exports

/opt/data/dev.reading.zt *(rw,sync,no_root_squash)

使配置文件生效 exportfs -r

查看 nfs 挂载 showmount -e

nfs 服务端配置 自动化执行脚本

vi /opt/nfs-service-conf.sh

#!/bin/bash

# 包含 nfs 和 rpcbind
yum install -y nfs-utils

# 设置开机启动 rpcbing,nfs
systemctl enable rpcbind
systemctl enable nfs

# 启动 rpcbing,nfs 服务
systemctl start rpcbind
systemctl start nfs

# 防火墙配置
firewall-cmd --permanent --add-service nfs
firewall-cmd --reload

folder=/opt/data/dev.reading.zt
# 创建路径
mkdir -p ${folder}
# 在 NFS 服务中添加目录,配置文件 /etc/exports
echo "${folder} *(rw,sync,no_root_squash)">>/etc/exports

# 使配置文件生效
exportfs -r

赋予可执行权限,并运行

# 赋予可执行权限
chmod +x /opt/nfs-service-conf.sh

# 执行
. /opt/nfs-service-conf.sh

安装配置 nfs 客户端

yum install -y nfs-utils

# 设置开机启动
systemctl enable rpcbind

# 启动 rpcbing 服务
systemctl start rpcbind

创建要挂载的目录 mkdir /opt/mnt

设置开机自动挂载, vi /etc/fstab

192.168.0.12:/opt/data/dev.reading.zt /opt/mnt nfs defaults 0 0
上一篇 下一篇

猜你喜欢

热点阅读