mount nfs file system

said earlier

How to configure and mount OCFS2 file system

Configure and mount OCFS2 file system using vmware shared disk

Configure and mount OCFS2 file system using DRBD

But in many cases we don't need to use a shared file system. For example, backup, we know that local storage is not safe. Once the hard disk fails, the data and backup will be lost. Generally, it is required to save it in another place, that is, to put the backup in other places or on the host. At this time, as long as the local host can mount The directory of other hosts and read and write on it.

In this case, NFS and CIFS can be used to share and mount locally. SSHFS is an alternative to these protocols

Today I will share how to mount NFS

Date: 2023-05-23

1 Test environment description

Windows 2019: 192.168.55.169 provides nfs storage space win_nfs

almaliux 9.2: 192.168.55.156 provides nfs storage space linux_nfs

oracle linux 7.9: 192.168.55.144/185 client, mount

Windows 11: 192.168.55.146 client mount

2 Install and set up nfs server

2.1 windows setting nfs

Service Manager -> Add Roles and Features -> Server Roles -> Expand "File and Storage Services" -> Expand "File and iSCSI Services" -> Select "File Server" and "NFS Server" -> Next -> Install

Create a new folder win_nfs, right-click win_nfs -> Properties -> NFS Share -> select "Share this folder" Select "Do not verify server" "Allow unmatched user access" "Allow unmatched user unix access (by UID/GID) "Other Default -> Permission to add client ip is read and write by default

2.2 linux configuration nfs

#NFS启动时会随机启动多个端口并向RPC注册.如果要开启防火墙,就要固定NFS端口并加入白名单。此处为方便关闭防火墙
systemctl stop firewalld 
#关闭selinux
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config ; sed -i "s/SELINUX=permissive/SELINUX=disabled/g" /etc/selinux/config
setenforce 0

#安装必须的软件包
yum -y install nfs-utils
systemctl restart rpcbind ; systemctl enable nfs-server --now

#配置nfs服务
mkdir /linux_nfs
chown nobody:nobody /linux_nfs #linux 8 使用 nobody, linux 7 及之前是nfsnobody , chown nfsnobody:nfsnobody /u01/backup
cat > /etc/exports <<EOF
/linux_nfs 192.168.55.144(rw,sync,all_squash)
/linux_nfs 192.168.55.185(rw,sync,all_squash)
/linux_nfs 192.168.55.146(rw,sync,all_squash)
EOF
systemctl restart nfs-server

3 linux client mount

3.1 Linux client installation

yum -y install nfs-utils

3.2 Linux client mounts win_nfs

showmount -e 192.168.55.169 #列出远程共享的目录
mkdir /local_win_nfs
mount -t nfs 192.168.55.169:win_nfs /local_win_nfs
#自动挂载 /etc/fstab 加入后, 重启可以生效, 但手动 mount -a 可以挂载但提示 "fuse: mountpoint is not empty" 未找到解决方法
192.168.55.169:win_nfs /local_win_nfs nfs defaults 0 0

3.3 The linux client mounts linux_nfs

showmount -e 192.168.55.156
mkdir /local_linux_nfs
mount -t nfs 192.168.55.156:linux_nfs /local_linux_nfs
#自动挂载 /etc/fstab 加入后, 重启可以生效, 但手动 mount -a 可以挂载但提示 "fuse: mountpoint is not empty" 未找到解决方法
192.168.55.156:linux_nfs /local_linux_nfs nfs defaults 0 0

4 windows client mount

4.1 Installation

Turn on or off the windows feature, install Service for NFS -> Administrative Tools and Client for NFS

4.2 Windows client mounts win_nfs

mount \\192.168.55.169\win_nfs w:

4.3 Windows client mounts linux_nfs

mount \\192.168.55.156\linux_nfs l:

illustrate

This mount is similar to a network share of nfs, not a shared file system. When multiple nodes mount at the same time and write to the same file, overwriting will occur

If you want to use a shared file system, such as OCFS2, GFS2, GPFS, please refer to my previous article.

Pay attention to anti-loss.

Guess you like

Origin blog.csdn.net/weixin_44496870/article/details/131673870