server端(需要共享的服务器): 127.0.0.1(服务端IP) client端: 127.0.0.2(客户端IP)
上传nfs包到server:
解压并安装nfs:
unzip nfs.zip cd /nfs rpm -ivh *.rpm --force --nodeps
创建共享文件夹
mkdir -p /data/img/ #创建指定uid和gid的用户: groupadd -g 1012 user1 useradd -u 1012 -g user1 user1
编辑配置文件
vi /etc/exports /data/img/ 127.0.0.2(客户端IP)(rw,no_root_squash,sync)
加载配置文件
exportfs -arv
为rpcbind和nfs做开机启动
systemctl enable rpcbind.service systemctl enable nfs-server.service
rpcbind和nfs启动
systemctl start rpcbind.service systemctl start nfs-server.service
修改指定端口: vi /etc/sysconfig/nfs RQUOTAD_PORT=30101 LOCKD_TCPPORT=30102 LOCKD_UDPPORT=30102 MOUNTD_PORT=30103 STATD_PORT=30104
vi /etc/modprobe.d/lockd.conf options lockd nlm_tcpport=30102 options lockd nlm_udpport=30102
重启相关服务
systemctl restart nfs-config systemctl restart nfs-idmap systemctl restart nfs-lock systemctl restart nfs-server
查看端口使用情况:
rpcinfo -p program vers proto port service 100000 4 tcp 111 portmapper 100000 3 tcp 111 portmapper 100000 2 tcp 111 portmapper 100000 4 udp 111 portmapper 100000 3 udp 111 portmapper 100000 2 udp 111 portmapper 100024 1 udp 30104 status 100024 1 tcp 30104 status 100005 1 udp 30103 mountd 100005 1 tcp 30103 mountd 100005 2 udp 30103 mountd 100005 2 tcp 30103 mountd 100005 3 udp 30103 mountd 100005 3 tcp 30103 mountd 100003 3 tcp 2049 nfs 100003 4 tcp 2049 nfs 100227 3 tcp 2049 nfs_acl 100003 3 udp 2049 nfs 100003 4 udp 2049 nfs 100227 3 udp 2049 nfs_acl 100021 1 udp 30102 nlockmgr 100021 3 udp 30102 nlockmgr 100021 4 udp 30102 nlockmgr 100021 1 tcp 30102 nlockmgr 100021 3 tcp 30102 nlockmgr 100021 4 tcp 30102 nlockmgr
防火墙开启端口;
firewall-cmd --zone=public --add-port=30101/tcp --permanent firewall-cmd --zone=public --add-port=30104/tcp --permanent firewall-cmd --zone=public --add-port=30103/tcp --permanent firewall-cmd --zone=public --add-port=30102/tcp --permanent
client端:
上传nfs包到client:
解压并安装nfs:
unzip nfs.zip cd nfs rpm -ivh *.rpm --force --nodeps
创建共享文件夹
mkdir -p /data/img/
#创建指定uid和gid的用户: groupadd -g 1012 user1 useradd -u 1012 -g user1 user1
为rpcbind和nfs做开机启动
systemctl enable rpcbind.service systemctl enable nfs-server.service
rpcbind和nfs启动
systemctl start rpcbind.service systemctl start nfs-server.service
修改指定端口: vi /etc/sysconfig/nfs RQUOTAD_PORT=30101 LOCKD_TCPPORT=30102 LOCKD_UDPPORT=30102 MOUNTD_PORT=30103 STATD_PORT=30104
vi /etc/modprobe.d/lockd.conf options lockd nlm_tcpport=30102 options lockd nlm_udpport=30102
重启相关服务
systemctl restart nfs-config systemctl restart nfs-idmap systemctl restart nfs-lock systemctl restart nfs-server
查看端口使用情况:
rpcinfo -p program vers proto port service 100000 4 tcp 111 portmapper 100000 3 tcp 111 portmapper 100000 2 tcp 111 portmapper 100000 4 udp 111 portmapper 100000 3 udp 111 portmapper 100000 2 udp 111 portmapper 100024 1 udp 30104 status 100024 1 tcp 30104 status 100005 1 udp 30103 mountd 100005 1 tcp 30103 mountd 100005 2 udp 30103 mountd 100005 2 tcp 30103 mountd 100005 3 udp 30103 mountd 100005 3 tcp 30103 mountd 100003 3 tcp 2049 nfs 100003 4 tcp 2049 nfs 100227 3 tcp 2049 nfs_acl 100003 3 udp 2049 nfs 100003 4 udp 2049 nfs 100227 3 udp 2049 nfs_acl 100021 1 udp 30102 nlockmgr 100021 3 udp 30102 nlockmgr 100021 4 udp 30102 nlockmgr 100021 1 tcp 30102 nlockmgr 100021 3 tcp 30102 nlockmgr 100021 4 tcp 30102 nlockmgr
挂载:(/image/bx/bxftp/image/)
mount -t nfs -o rw 127.0.0.1(服务端IP):/data/img/ /data/img/
防火墙开启端口;
firewall-cmd --zone=public --add-port=111/tcp --permanent firewall-cmd --zone=public --add-port=30104/tcp --permanent firewall-cmd --zone=public --add-port=30103/tcp --permanent firewall-cmd --zone=public --add-port=30102/tcp --permanent firewall-cmd --zone=public --add-port=2049/tcp --permanent
|