NFS服务器安装与使用

来源:互联网 发布:calibre mac 编辑:程序博客网 时间:2024/06/10 12:01

NFS的安装

  NFS(Network File System,网络文件系统)是一种将远程主机上的分区(目录)经网络挂在到本地的一种机制,通过对网络文件系统的支持,用户可以在本地系统上像操作本地分区一样来对远程主机的共享分区(目录)进行操作,类似于windows的共享目录。

查看安装版本
[root@localhost Server]# rpm -q nfs-utils-1.0.9-24.el5.i386.rpm 
package nfs-utils-1.0.9-24.el5.i386.rpm is not installed

没有安装,从光盘中找到相应的RPM安装包并安装
[root@localhost Server]# rpm -ivh  nfs-utils-1.0.9-24.el5.i386.rpm 
warning: nfs-utils-1.0.9-24.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
        package nfs-utils-1.0.9-24.el5 is already installed

NFS配置,加入允许其他计算机访问的目录和访问权限
[root@localhost Server]# vi /etc/exports


  /home     192.168.1.*(rw,sync,no_root_squash)

1、home:允许其它计算机访问的目录

2、192.168.1.*:被允许访问该目录的客户端IP地址

3、Rw:可读可写

4、no_boot_squash:表示客户端root用户对该目录具备写权限

启动NFS服务器

[root@localhost Server]# /etc/init.d/nfs start
Starting NFS services:  exportfs: /etc/exports:1: unknown keyword "no_boot_squash"
                                                                          [FAILED]
Starting NFS quotas:                                         [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                        [  OK  ]

重启NFS服务器
[root@localhost Server]# /etc/init.d/nfs restart
Shutting down NFS mountd:                              [  OK  ]
Shutting down NFS daemon:                             [  OK  ]
Shutting down NFS quotas:                               [ OK  ]
Shutting down NFS services:                             [FAILED]
Starting NFS services:  exportfs: /etc/exports:1: unknown keyword "no_boot_squash"
                                                                         [FAILED]
Starting NFS quotas:                                        [  OK  ]
Starting NFS daemon:                                      [  OK  ]
Starting NFS mountd:                                       [  OK  ]

最后,使用mount命令来挂载NFS服务器上的共享目录

#mount -t  nfs servername:/shared_dir /localdir
例如:

#mount -t  nfs 10.168.1.100:/home  /mnt/nfs

注意:如果是第一次安装并在主机上自己挂载自己,则最好将共享的文件放在 /home 中,并且在 /mnt 目录下建立文件夹 /nfs,

例如

[root@localhost Server]#mkdir /home/hugh

[root@localhost Server]#chmod 744 /home/hugh

[root@localhost Server]#mkdir /mnt/nfs

再次NFS配置,加入允许其他计算机访问的目录和访问权限

[root@localhost Server]# vi /etc/exports

  /home     192.168.1.*(rw,sync,no_root_squash)

重启NFS服务器
[root@localhost Server]# /etc/init.d/nfs restart
Shutting down NFS mountd:                              [  OK  ]
Shutting down NFS daemon:                             [  OK  ]
Shutting down NFS quotas:                               [ OK  ]
Shutting down NFS services:                             OK  ]
Starting NFS services                                        OK  ]
Starting NFS quotas:                                         [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                        [  OK  ]

#mount -t  nfs 10.168.1.100:/home/hugh  /mnt/nfs

原创粉丝点击