First, the environment introduction:
Server: CentOS 192.168.1.225
Client: CentOS 192.168.1.226
Second, installation:
Installation Configuration for NFS:
CentOS 5:
1 |
Yum-y Install Nfs-utils Portmap |
CentOS 6 (in CentOS 6.5, Portmap service is responsible for Rpcbind):
1 |
Yum-y Install Nfs-utils Rpcbind |
third, server-side configuration:
1. Create a shared directory:
1 |
[Root@centos2/] # Mkdir/usr/local/test |
2, NFS File configuration:
1 2 3 |
[Root@centos2/] # Vi/etc/exports #增加一行:/usr/local/test/192.168.1.226 (Rw,no_root_squash,no_all_squash, Sync) |
Save exit;
Make configuration effective:
1 |
[Root@centos2/] # 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) for the client's address and permissions, the address can be a network segment, an IP address or a domain name, the domain name support wildcard characters, such as: *. Youxia.com, there is no space between the address and the permission, the permission description:
Rw:read-write, can read and write;
Ro:read-only, read only;
Sync: Files are written to both hard disk and memory;
Async: Files are temporarily stored in memory, rather than written directly to memory;
When No_root_squash:nfs client connects to the server, if root is used, then the directory shared by the server also has root privileges. Obviously it's not safe to open this.
When Root_squash:nfs client connects to the server, if root is used, then the directory shared by the server has anonymous user rights, usually he will use nobody or nfsnobody identity;
All_squash: No matter what user the NFS client connects to the server, it has anonymous user rights to the directory shared by the server;
Anonuid: The UID value of an anonymous user, usually a nobody or nfsnobody, where you can set it yourself;
Anongid: The GID value of the anonymous user.
3, Start:
CENTOS6: