Linux CentOS7 install configure NFS Server

今天写一个比较简单的NFS文件传输服务

LinuxSystemVersion:Linux centos7_server 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Server Or Client 都需要安装 NFS-utils

NFS配置服务需记住三点: 共享目录,IP,权限

[root@centos7_server ~]# yum  -y  install  /mnt/Packages/nfs-utils-1.3.0-0.48.el7.x86_64.rpm

[root@centos7_server ~]#  vim  /etc/exports

/nfsshare 127.0.0.1  (rw,sync,root_squash)

温馨提示:

共享目录:共享目录可按照自己的心意去做

IP: 可以设置独立的IP地址:127.0.0.1    Or    127.0.1.0/24 也可是一个网段

权限: ro     只读 

           rw     只写

          sync  同时将数据写入到内存与硬盘

          async  优先将数据保存到内存,然后在写入硬盘。 效率比较高,有可能会丢失数据

          root_squash  以root身份去访问,在NFS服务器映射为匿名用户   

          no_root_squash  以root身份去访问,在NFS服务器映射为root账户

[root@centos7_client ~]# mount -t nfs 127.0.0.1:/nfsshare /share/
mount: wrong fs type, bad option, bad superblock on 10.93.143.5:/nfsshare,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount.<type> helper program)

In some cases useful info is found in syslog - try
dmesg | tail or so.

这时挂载NFS共享目录出现问题,在这个错误当中,小编只看见了NFS这个词,而后在客户端也安装了NFS-Utils,这样就可以挂载了。

重新启动NFS服务器也需要重新启动rpcbind服务:   systemctl  restart  rpcbind             systemctl     restart   nfs

[root@centos7_client ~]# mount -t nfs 10.93.143.5:/nfsshare /share

挂载NFS共享目录时 千万不要漏了 : 这个符号

[root@centos7_client ~]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos-root xfs 17811456 1146548 16664908 7% /
devtmpfs devtmpfs 930876 0 930876 0% /dev
tmpfs tmpfs 941940 0 941940 0% /dev/shm
tmpfs tmpfs 941940 8680 933260 1% /run
tmpfs tmpfs 941940 0 941940 0% /sys/fs/cgroup
/dev/sda1 xfs 1038336 145828 892508 15% /boot
/dev/sr0 iso9660 4414592 4414592 0 100% /mnt
tmpfs tmpfs 188392 0 188392 0% /run/user/0
127.0.0.1:/nfsshare nfs4 17811456 1933568 15877888 11% /share

再来一个大福利, 永久性挂载NFS共享目录, NFS服务器不倒,一直挂载着。。。

[root@centos7_server ~]#  vim  /etc/fstab


#
# /etc/fstab
# Created by anaconda on Mon May 21 06:56:27 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=f4904f42-eea1-4922-b8a8-c290184a3cfa /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
/dev/sr0 /mnt iso9660 defaults 0 0

127.0.0.1:/nfsshare /share nfs defaults 0 0

此博客由Daniu_UnixChina原创博客。

热烈欢迎IT大神前来指点,如有不足之处,请联系在下

Mail:[email protected]  Or  [email protected]

QQ:1958344794   WeChat:A67810086

猜你喜欢

转载自www.cnblogs.com/DaniuUnixChina/p/9298799.html
今日推荐