NFS搭建
2018-08-17 09:31:57来源:博客园 阅读 ()
一、环境
nfsserver01:192.168.127.100 centos7.3
nfsclient01:192.168.127.101 centos7.3
二、NFS原理
三、安装测试
1、nfsserver安装
[root@nfsserver01 ~]# yum install rpcbind nfs-utils -y
[root@nfsserver01 ~]# mkdir /Share
[root@nfsserver01 ~]# chmod 755 /Share
[root@nfsserver01 ~]# ll -d /Share
drwxr-xr-x. 2 root root 6 8月 16 10:42 /Share
[root@nfsserver01 ~]# mkdir /Share
[root@nfsserver01 ~]# chmod 755 /Share
[root@nfsserver01 ~]# ll -d /Share
drwxr-xr-x. 2 root root 6 8月 16 10:42 /Share
[root@nfsserver01 ~]# vim /etc/exports
#######shared for test by suffergtf at 2018-8-16######
/Share 192.168.127.0/24(rw,sync)
[root@nfsserver01 ~]# systemctl start rpcbind
[root@nfsserver01 ~]# systemctl enable rpcbind
[root@nfsserver01 ~]# netstat -lntup|grep rpcbind
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 10432/rpcbind
tcp6 0 0 :::111 :::* LISTEN 10432/rpcbind
udp 0 0 0.0.0.0:855 0.0.0.0:* 10432/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 10432/rpcbind
udp6 0 0 :::855 :::* 10432/rpcbind
udp6 0 0 :::111 :::* 10432/rpcbind
[root@nfsserver01 ~]# rpcinfo -p localhost
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
[root@nfsserver01 ~]# systemctl start nfs
[root@nfsserver01 ~]# systemctl enable nfs
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
[root@nfsserver01 ~]# rpcinfo -p localhost
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 40390 status
100024 1 tcp 56253 status
100005 1 udp 20048 mountd
100005 1 tcp 20048 mountd
100005 2 udp 20048 mountd
100005 2 tcp 20048 mountd
100005 3 udp 20048 mountd
100005 3 tcp 20048 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 50142 nlockmgr
100021 3 udp 50142 nlockmgr
100021 4 udp 50142 nlockmgr
100021 1 tcp 32899 nlockmgr
100021 3 tcp 32899 nlockmgr
100021 4 tcp 32899 nlockmgr
[root@nfsserver01 ~]# showmount -e localhost
Export list for localhost:
/Share 192.168.127.0/24
2、nfsclient安装
[root@nfsclient01 ~]# yum install rpcbind nfs-utils -y #nfs-utils可不安装
[root@nfsclient01 ~]# systemctl start rpcbind
[root@nfsclient01 ~]# systemctl enable rpcbind
3、测试连接
[root@nfsclient01 ~]# showmount -e 192.168.127.100 clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host) ##关闭server,client端防火墙和selinux
######nfsserver端
[root@nfsserver01 ~]# systemctl stop firewalld
[root@nfsserver01 ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@nfsserver01 ~]# vim /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=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
######nfsclient端同上
[root@nfsclient01 ~]# showmount -e 192.168.127.100
Export list for 192.168.127.100:
/Share 192.168.127.0/24
[root@nfsclient01 ~]# mount -t nfs 192.168.127.100:/Share /mnt
[root@nfsclient01 mnt]# echo 'mount -t nfs 192.168.127.100:/Share /mnt' >>/etc/profile
[root@nfsclient01 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda3 18G 1.2G 17G 7% /
devtmpfs 227M 0 227M 0% /dev
tmpfs 237M 0 237M 0% /dev/shm
tmpfs 237M 4.6M 232M 2% /run
tmpfs 237M 0 237M 0% /sys/fs/cgroup
/dev/sda1 97M 89M 8.6M 92% /boot
tmpfs 48M 0 48M 0% /run/user/0
192.168.127.100:/Share 18G 1.2G 17G 7% /mnt
[root@nfsclient01 mnt]# touch 1.test
touch: 无法创建"1.test": 权限不够
[root@nfsserver01 ~]# cat /var/lib/nfs/etab ######查看默认共享参数
/Share 192.168.127.0/24(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,no_all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=65534,anongid=65534,sec=sys,secure,root_squash,no_all_squash)
[root@nfsserver01 ~]# ll /Share/ -d
drwxr-xr-x. 2 root root 6 8月 16 10:42 /Share/ ###共享文件属主为root,挂载的客户端root用户,被转换成nfsnobody用户,所以没有权限
[root@nfsserver01 ~]# chown nfsnobody.nfsnobody /Share
[root@nfsserver01 ~]# ll /Share/ -d
drwxr-xr-x. 2 nfsnobody nfsnobody 6 8月 16 10:42 /Share/
[root@nfsclient01 mnt]# touch 1.test
[root@nfsclient01 mnt]# ll /mnt/
总用量 0
-rw-r--r--. 1 nfsnobody nfsnobody 0 8月 16 11:22 1.test
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:nginx反向代理
- linux修改环境变量分析 2020-06-05
- LVS负载分担(NAT模式)基础搭建 2020-06-01
- ubuntu18.04.4 配置 NFS 服务器 2020-05-31
- postfix&dovecot搭建邮件服务器 2020-05-30
- 在树莓派里搭建 Lighttpd 服务器 2020-05-27
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash