First, the environment introduction:
Server: CentOS 192.168.1.225
Client: CentOS 192.168.1.226
Second, installation:
Installation Configuration for NFS:
CentOS 5:
Yum-y Install Nfs-utils Portmap
CentOS 6 (in CentOS 6.3, the Portmap service is the responsibility of Rpcbind):
Yum-y Install Nfs-utils Rpcbind
Third, server-side configuration:
1. Create a shared directory:
[Email protected]/]# mkdir/usr/local/test
2. NFS File configuration:
[Email protected]/]# vi/etc/exports #增加一行:/usr/local/test/192.168.1.226 (Rw,no_root_squash,no_all_squash,sync)
: x save exit;
To make the configuration effective:
[Email protected]/]# Exportfs-r
Note: Configuration file Description:
/usr/local/test/is a shared directory, using an absolute path.
192.168.1.226 (Rw,no_root_squash,no_all_squash,sync) is the client's address and permissions, the address can be a network segment, an IP address or a domain name, the domain name supports wildcard characters, such as: *. Youxia.com, there is no space between the address and permission, the permission description:
Rw:read-write, can read and write;
Ro:read-only, read-only;
Sync: The file is written to both the hard disk and memory;
Async: Files are staged in memory instead of directly to memory;
No_root_squash:nfs the client connects to the server, if root is used, it also has root access to the directory shared by the server. Obviously it's not safe to turn it on.
Root_squash:nfs the client connects to the server, if root is used, then the directory shared by the server, with anonymous user rights, usually he will use nobody or nfsnobody identity;
All_squash: Regardless of which user is used by the NFS client to connect to the server, the directory shared by the server has anonymous user rights;
Anonuid: The UID value of the anonymous user, usually nobody or nfsnobody, can be set at this point;
Anongid: The GID value of the anonymous user.
3. Start:
CENTOS6:
[[Email protected]/]# service Rpcbind start
starting rpcbind: [ ok ][[email protected ] /]# service nfs startstarting nfs services: [ OK ]Starting NFS quotas: [ OK ]Starting NFS mountd: [ ok ]stopping rpc idmapd: [ OK ]Starting rpc idmapd: [ OK ]Starting NFS daemon: [ ok ][ [email protected] /]#
CentOS 5
[[Email protected]/]# service Portmap start[[email protected]/]# service NFS Start[[email protected]/]#
Iv. Client Mount:
1. Create a directory to mount:
[Email protected] ~]# Mkdir/usr/local/test[[email protected] ~]#
2. Test mount:
[[email protected] ~]# showmount-e 192.168.1.225Export list for 192.168.1.225:/usr/local/test 192.168.1.226[[email Protected] ~]#
If shown: RPC mount export:RPC:Unable to receive; errno = No route to host, you need to shut down the firewall on the server (verbose later).
3. Mount:
[Email protected] ~]# mount-t NFS 192.168.1.225:/usr/local/test/usr/local/test
[Email protected] ~]# mount/dev/mapper/volgroup-lv_root on/type ext4 (rw) proc On/proc type proc (rw) SYSFS On/sys type SYSFS (rw) devpts on/dev/pts type devpts (rw,gid=5,mode=620) Tmpfs on/dev/shm type TMPFS (rw)/dev/sda1 on/boot type Ext4 (rw) None On/proc/sys/fs/binfmt_misc type Binfmt_misc (rw) sunrpc on/var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) nfsd on/ PROC/FS/NFSD type NFSD (rw) 192.168.1.225:/usr/local/test On/usr/local/test type NFS (rw,vers=4,addr=192.168.1.225, clientaddr=192.168.1.226) [[email protected] ~]#
If the message is displayed, the Mount succeeds!
4. Test:
The client generates a file:
[[email protected]/]# Cd/usr/local/test/[[email protected] test]# echo "Hello NFS Test" >>test[[email protected] te st]# lltotal 4-rw-r--r--1 root root 9 13:24 test[[email protected] test]#
Service-side check:
[Email protected]/]# cd/usr/local/test/[[email protected] test]# lltotal 4-rw-r--r--1 root root Apr 9 13:24 test[[ Email protected] test]#
Mount success!
CENTOS5 6 Mount MAC host ox system FreeBSD