首页 > 代码库 > CentOS6.5 NFS挂载

CentOS6.5 NFS挂载

1、创建NFS服务端

2、Linux客户端挂载Linux的NFS

3、Windows客户端挂载Linux的NFS

 

配置NFS服务端

查看是否有nfs-utils rpcbind服务

[root@nfsserver mnt]# rpm -qa nfs-utils rpcbind

[root@nfsserver mnt]#

此处显示没有安装nfs、rpcbind

两种安装方式

 yum install "NFS file server" -y

yum install nfs-utils portmap rpcbind -y

 

配置开机启动并查看是否生效

chkconfig rpcbind on
chkconfig nfs rpcbind

chkconfig --list rpcbind

rpcbind         0:off   1:off   2:on    3:on    4:on    5:on    6:off

chkconfig --list nfs

nfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off

 

rpcbind         0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@nfsserver mnt]# chkconfig --list nfs
nfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off

查看对应的接口进程是否启动

[root@Donglq ~]# rpcinfo -p localhost

 

配置/etc/exports文件

[root@nfsserver mnt]# cat /etc/exports
###shared data for bbs by oldboy at 20160920
/data 192.168.0.0/24(rw,sync)

用reload平滑重启nfs服务

[root@Donglq ~]# /etc/init.d/nfs reload

本机查看NFS是否共享成功

[root@Donglq ~]# showmount -e localhost
Export list for localhost:
/data 192.168.0.252/24

显示以上结果证明NFS在server端已经配置成功

 

Linux客户端挂载Linux的NFS

在客户端查看NFS192.168.0.252是否能查询到

[[root@Donglq ~]# showmount -e 192.168.0.252
Export list for 192.168.0.252:
/data 192.168.0.252/24

上面结果是我配置好的

注:如果show不出来如上结果,查询物理是否连通

将NFS服务器192.168.0.252共享的/data数据共享到本地/mnt上

[root@Donglq ~]# mount -t nfs 192.168.0.252:/data /mnt

查看共享

[root@Donglq ~]#df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/sda2             11G  1.1G  8.5G  11% /
tmpfs                1.9G     0  1.9G   0% /dev/shm
/dev/sda1            190M   47M  134M  26% /boot
192.168.0.252:/data  274G   29G  232G  11% /mnt

进入/mnt查看共享的文件

[[root@Donglq ~]#cd /mnt
[root@Donglq mnt]# ll -li
total 28915320
13107203 -rwxr-xr-x 1 nobody nobody          3 Sep 20 10:49 12.txt
13107202 drwxr-xr-x 2 root   root         4096 Sep 20 10:27 {1-5}
13107205 -rw-r--r-- 1 root   root            0 Sep 20 10:31 1.txt
13107204 drwxr-xr-x 2 root   root         4096 Sep 20 10:30 5
13107206 -rwxr-xr-x 1 nobody nobody 3420557312 Aug 16  2011 cn_windows_7_ultimate_with_sp1_x64_dvd_u_677408.iso

 

Windows客户端挂载Linux的NFS

已win7系统为例 开始->控制面板->程序和功能->打开或关闭windows功能->NFS服务器->NFS客户端

win+r >cmd

mount 192.168.0.252:/data G:
G: 现已成功连接到 192.168.0.252:/data

命令已成功完成。

解释: 

mount,是指令

192.168.1.10你的linux主机IP

/data你的共享目录

G:你挂载的网络文件盘--注意,可能会与你的其他盘冲突,你可以随意更改

本文出自 “董利强” 博客,请务必保留此出处http://6207422.blog.51cto.com/6197422/1854911

CentOS6.5 NFS挂载