This document describes how to set up an NFS server on RHEL 5.4.
Original article: http://wqmsl.blog.51cto.com/847418/360985
Target
1. Set up an NFS server
2. Use a client to access Linux)
3. access through a Windows Client
4. Common commands
Description
192.168.0.2 -- Host Name: nfs. wqmsl. comNFS Server
192.168.0.3 -- Host Name: client.wqmsl.com client
Preparations: Change Host Name (three changes): 1. Change hostname, 2. Change hosts, 3./etc/sysconfig/network
I. achieve the first goal to build an NFS server
The required software packages are as follows:
Nfs-utils-1.0.9-24.el5-the main package for the nfs service, which provides the rpc. nfsd and rpc. mountd daemons and related instruction files.
Portmap-4.0-65.2.2.1 -- rpc main program that records the port ing information for the service.
Common NFS directories
1. the/etc/exports file is the main configuration file of NFS. By default, this file is stored in time and space and needs to be manually added.
2./usr/sbin/exportfs: This is a command to maintain NFS shared resources. Not many of them are used. We generally define them in the configuration file.
3. the/usr/sbin/showmount command is mainly used on the client to view the directory resources shared by NFS.
4./var/lib/nfs/etab (xtab) The etab records the complete permission settings for the directories shared by NFS, And the xtab is the other, record the client data that has been connected to this NFS host.
This configuration file can be divided into three columns
Column 1 ------ write the directory path you want to share
Column 2 ------ write the client description, that is, which clients can use your server
The third column ------ is next to the second column, and the content is shared permissions (rw ro sync)
I shared the/var and/etc directories,
1. NFS does not have strict requirements on client expressions. common expressions can be identified. For example, if an IP address is entered, the IP address ranges from 192.168.0.0/24 to 192.168.0.0/255.255.255.0.
Domain Name: www.wqmsl.com domain: * .wqmsl.com
2. If all IP addresses can be accessed, enter "*".
3. sync: synchronize data written to the memory and hard disk. async: the data will be saved to the memory instead of directly written to the hard disk.
4. Which of the two are better?
If you are an important small file, of course sync, synchronous writing, to avoid file loss
If you have large data volumes, we recommend that you do not write data synchronously.
5. rw: readable and writable
6. ro: Read-only. This is very simple.
Restart the nsf service because nfs is based on the portmap Process.
After OK, you can use the showmount command to check whether the sharing is successful.
Showmount-e is followed by your server IP Address
You can also use showmount-e. This is the default service to view your shared services, provided that the DNS can resolve itself, otherwise it is easy to report errors.
The nfs port is 2049, but it is based on portmap. The portmap port is 111.