(在安装Linux Centos 的时候,一般都会配置安装到 NFS服务)
一、环境介绍:
服务器:centos 192.168.70.129
客户端:centos 192.168.70.130
二、NFS配置
vi /etc/exports 加入允许被其他计算机访问的目录和访问权限
如: /home/wwwroot 192.168.70.130(rw,sync,no_root_squash) 这些地址可以访问/home/wwwroot,()内表示权限限制
ro/rw: 只读/可读可写
sync:同步写磁盘(允许修改)
no_root_squash:表示客户端root用户对该目录具有写权限
一般只改目录和IP,权限部分不做修改
三、使用NFS
1、当编辑完配置文件/etc/exports后,就该启动NFS服务了。启动方法为:
2、[root @localhost ~]# service portmap start; service nfs start (在服务器终端,启动NFS服务进程)
NFS是依托portmap的,所以首先要启动portmap,然后启动NFS才能是刚才的配置生效。启动完NFS后,就该使用NFS服务了。
3、[root @localhost ~]# showmount -e 192.168.70.129 (在客户服务器终端;192.168.70.129 为服务器IP地址)
Export list for 192.168.70.129:
/home/wwwroot 192.168.70.130
4、[root @localhost wwwroot]# mount -t nfs 192.168.70.129:/home/wwwroot /home/wwwroot (在客户端挂载-> 将服务器端的 /home/wwwroot 挂载到 客户端 的 /home/wwwroot 目录下)
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
none on /proc/fs/vmblock/mountPoint type vmblock (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
192.168.70.129:/home/wwwroot on /home/wwwroot type nfs (rw,addr=192.168.70.129)
四、解除挂载:
[root @localhost ~]# umount /home/wwwroot
[root @localhost ~]# mount
转载于:https://my.oschina.net/u/231017/blog/122881