NFS is a network File system protocol based on TCP/IP transmission, originally developed by Sun.
With the NFS protocol, clients can access shared resources on a remote server as if they were accessing a local directory.
NFS has excellent support for networked storage devices such as NAS. is also preferred for LVS shared storage.
NFS-related services
Package: Nfs-utils,rpcbind
Configuration file:/etc/exports
Related commands:
Exportfs
Showmount
Rpcinfo
Mount
Basic configuration file;
/etc/exports
/Master (rw) trusty (Rw,no_root_squash)
/projectsproj*.local.domain (rw)
/usr *.local.domain (RO) @trusted (rw)
/home/joepc001 (rw,all_squash,anonuid=150,anongid=100)
/buildbuildhost[0-9].local.domain (rw)
Pre-deployment preparation
Configure the system image to local Yum source, configure Yum file
Environment Introduction:
To clone a virtual machine using the parent disk, the IP is set to: 192.168.100.250 and name the virtual machine as the storage server, using 192.168.100.100 as the client.
1. Install the Nfs-utils, Rcpbind package
[Email protected] ~]# yum-y install nfs-utils rpcbind
[[email protected] ~]# for I in Rpcbind nfs;do chkconfig $i on; Done # #设置为开机启动
2. Setting up a shared directory
[Email protected] ~]# Mkdir/opt/wwwroot
[Email protected] ~]# mkdir-p/var/ftp/pub
[Email protected] ~]# chmod 777/opt/wwwroot # #设置权限
Vi/etc/exports
/opt/wwwroot192.168.100.0/24 (Rw,sync,no_root_squash)
/var/ftp/pub192.168.0.10 (RO) 192.168.0.200 (rw)
3. Start the NFS service program
[[email protected] ~]#/etc/init.d/rpcbind start
[[email protected] ~]#/etc/init.d/nfs start
[Email protected] ~]# NETSTAT-UTPNL |grep rpcbind
[Email protected] ~]# SHOWMOUNT-E # #查看本机共享的目录
4. Client Settings
[Email protected] ~]# yum-y install nfs-utils rpcbind
Chkconfig Rpcbind on
[Email protected] ~]# showmount-e 192.168.100.250
[[email protected] ~]# echo 3 >/proc/sys/vm/drop_caches # #当nfs因为缓存没有及时而导致错, you can use this command
5. Client Mount using NFS Share
[Email protected] ~]# mkdir-p/var/www/html
[email protected] ~]# Mount 192.168.100.250:/opt/wwwroot/var/www/html/
[[email protected] ~]# Mount |grep NFS
[Email protected] ~]# Vi/etc/fstab
192.168.100.250:/opt/wwwroot/var/www/html NFS Defaults,_netdev 0 0
: Wq
[Email protected] ~]# mount-a
[[email protected] ~]# Mount |grep NFS
Verify:
[Email protected] ~]# cd/var/www/html/
[email protected] html]# Touch a.file
[email protected] html]# LL
Switch to 100.250 on authentication:
[Email protected] ~]# ls/opt/wwwroot/
A.file
This article is from the "Lp-linux" blog, make sure to keep this source http://linuxlp.blog.51cto.com/11463376/1773633
Common services for Linux Enterprises---NFS