mount -t nfs -o intr,soft,retry=1 cm3nas1.taobaobackup.com:/vx/tbpe_bak01 /home/admin/data_backup
/home/admin/data_backup 这是本地已经创建好的挂载目录
同时添加到/etc/rc.local
Server端:
1./etc/exports格式:
目录 选项
例:共享/share目录给192.168.0.x的用户
/share 192.168.0.0/24 (rw)
/mnt/sda4/share/a 192.168.23.129(rw)
设置共享目录/mnt/sda4/share/a,仅192.168.23.129主机容许访问此共享目录,具备读写权限
/mnt/sda4/share/b 192.168.23.129(rw) *(ro)
设置共享目录/mnt/sda4/share/b,192.168.23.129能够读写该共享目录,其余主机只能够读取该共享目录
/mnt/sda4/share/c 192.168.23.129(no_root_squash)
设置共享目录/mnt/sda4/share/c,仅192.168.23.129能够访问和读写,root登陆时拥有root权限
/mnt/sda4/share/d 192.168.23.0/24(rw)
设置共享目录/mnt/sda4/share/d,仅有192.168.23.0/24网段的主机才可访问和读写此目录文件
/u01/db3 192.168.92.21(rw,sync,no_root_squash)
选项说明:
权限参数说明以下:
rw:read-write可读写的权限
ro:read-only只读权限
no_root_squash:登入NFS主机使用共享目录的用户,若是是用户root,对于此共享目录具备root权限,不建议使用。
root_squash:登入NFS主机使用共享目录的用户,若是是用户root,此用户权限将被压缩为匿名用户,其UID和GID都会被压缩为nobody(nfsnobody)系统帐号的身份。
all_squash:不论登入NFS的用户身份为什么,其身份都被转换成为匿名用户,即nobody。
Anonuid:anonymous;即nobody,能够自行设定此UID值,但此UID必须存在于/etc/passwd中。
Anongid:同anonuid,变成group ID便可。
sync:数据同步写入到内存与硬盘中
async:数据先暂存于内存中,而非直接写入硬盘
no_root_squash 信任客户端,对应 UID
noaccess 客户端不能使用
2.启动portmap服务:
service portmap start[restart]
3.启动NFS服务:
service nfs start[restart]
Client端:
client 要查看 Server 有提供哪些 NFS 服务,能够使用 showmount 这个指令。
# showmount -e 显示某台主机的/etc/exports所共享的目录数据
# showmount -a 显示当前主机与客户端NFS联机共享状态
1.启动portmap服务:
service portmap start[restart]
2.挂载服务器端的共享目录(假设服务器端192.168.0.1):
mount -t nfs 192.168.0.1:/share /mnt/localshare
若是修改/etc/exports文件以后无需重启nfs,只需从新扫瞄一次文件/etc/exports,而且从新将设定加载便可;
Exportfs:
-a:所有挂载(或卸载)/etc/exports 文件内的设置。
-r:从新挂载/etc/exports里的设置,同时同步更新/etc/exports及/var/lib/nfs/xtab的内容。
-u:卸载某一目录。
-v:在export时,将共享的目录显示在屏幕上。
从新挂载/etc/exports的设置:#exportfs–arv
所有卸载/etc/exports的设置:#exportfs–auv
查用的挂载
服务端:
[root@w017014.isv ~]# cat /etc/exports
/u01 192.168.17.0/24(rw,sync,no_root_squash)
客户端:
mount -t nfs -o noatime,soft,retry=1,intr 172.23.142.9:/nas/tbpe_bak01 /mount_point
mount -t nfs -o rsize=65536,wsize=65536,vers=3,noatime 192.168.50.3:/var/www/html/guoguobang/userres /var/www/html/guoguobang/userres
mount -t nfs -o rsize=65536,wsize=65536,vers=3,noatime 192.168.60.1:/home/admin/nginx/htdocs/p_w_upload /home/admin/nginx/htdocs/p_w_uploadhtml