搭建NFS服务
搭建NFS服务
1. 保证两台主机能够相互通信
[root@localhost ~]# ping 10.10.10.111
PING 10.10.10.111 (10.10.10.111) 56(84) bytes of data.
64 bytes from 10.10.10.111: icmp_seq=1 ttl=64 time=0.258 ms
64 bytes from 10.10.10.111: icmp_seq=2 ttl=64 time=1.57 ms
64 bytes from 10.10.10.111: icmp_seq=3 ttl=64 time=0.262 ms
2.配置yum源
[root@localhost ~]# cat /etc/yum.repos.d/local.repo
[centos]
name=centos
baseurl=file:///media
gpgcheck=0
enabled=1
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: centos
Cleaning up list of fastest mirrors
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
centos | 3.6 kB 00:00:00
(1/2): centos/group_gz | 166 kB 00:00:00
(2/2): centos/primary_db | 3.1 MB 00:00:00
repo id repo name status
centos centos 4,021
repolist: 4,021
3.安装rpcbind和nfs-utils
[root@localhost ~]# yum -y install rpcbind nfs-utils
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package rpcbind-0.2.0-47.el7.x86_64 already installed and latest version
Package 1:nfs-utils-1.3.0-0.61.el7.x86_64 already installed and latest version
Nothing to do
4.在/opt下创建wenhan文件夹并在里面创建一个测试文件
[root@localhost ~]# mkdir -p /opt/wenhan/
[root@localhost ~]# cd /opt/wenhan/
[root@localhost wenhan]# touch wenhan
[root@localhost wenhan]# ls
wenhan
5.关闭防火墙和selinux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# setenforce 0
[root@localhost ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=diasbled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
6.进入配置文件写入以下信息
[root@localhost ~]# cat /etc/exports
/opt/wenhan 10.10.10.0/24(ro,sync)
7.重启nfs服务
[root@localhost ~]# systemctl restart nfs
[root@localhost ~]# systemctl enable nfs
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
8.到client客户端进行挂载
[root@localhost ~]# mount -t nfs 10.10.10.123:/opt/wenhan /mnt/
[root@localhost ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs17G 4.5G 13G 27% /
devtmpfs devtmpfs 974M 0 974M 0% /dev
tmpfstmpfs 991M 0 991M 0% /dev/shm
tmpfstmpfs 991M 11M 981M 2% /run
tmpfstmpfs 991M 0 991M 0% /sys/fs/cgroup
/dev/sda1xfs 1014M 166M 849M 17% /boot
tmpfstmpfs 199M 4.0K 199M 1% /run/user/42
tmpfstmpfs 199M 20K 199M 1% /run/user/0
/dev/sr0 iso9660 4.3G 4.3G 0 100% /run/media/root/CentOS 7 x86_64
10.10.10.123:/opt/wenhan nfs4 17G 4.5G 13G 27% /mnt
[root@localhost ~]# cd /mnt/
[root@localhost mnt]# ls
wenhan
本文来自博客园,作者:Cloudservice,转载请注明原文链接:https://www.cnblogs.com/whwh/p/16147828.html,只要学不死,就往死里学!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律