Configure the NFS server on CentOS 5

Source: Internet
Author: User

I. Environment preparation

The full name of NFS isNEtworkFIleSYstem is a Network File System. Generally, it is used to share directories between two Linux/Unix servers. What we need to do today is to share directories between two servers with CentOS 5.6 installed.

Operating System: CentOS 5.6 64-bit)

Server IP Address: 192.168.1.1

Client IP Address: 192.168.0.2


Ii. Install the NFS service

1. on the server side, check whether the required software portmap is named rpcbind after CentOS 6) and nfs-utils are installed:

[root@server ~]# rpm -qa | egrep 'nfs|portmap'portmap-4.0-65.2.2.1nfs-utils-1.0.9-50.el5nfs-utils-lib-1.0.8-7.6.el5

If no software is installed, you can use the installation disc or yum to install the corresponding software.


2. Check whether portmap has been installed on the client.


Iii. Server Configuration

The NFS configuration file is located in/etc/exports. It records the NFS service shared directory, shared objects, and permissions. The basic format is as follows:

<Shared directory> [client 1 option access permission, user ing, others)] [client 2 Option access permission, user ing, others)]

The first field of each line is the directory to be shared; the following field is the client address, which can be:

  • Host with the specified IP Address: 192.168.1.2

  • All hosts in the specified subnet: 192.168.10.0/24

  • Host Name: plutonji.wordpress.com

  • Wildcard Host Name: * .plutonji.cn

  • All Hosts :*


The following options are available:

A. access permission options:
(Ro) read-only
(Rw) read + write
B. User ing options:
All_squash: maps all common users and groups remotely accessed to anonymous users or user groups nfsnobody );
No_all_squash: Use the reverse default setting for the values of no_all_squash and all_squash );
Root_squash: maps root users and groups to anonymous users or user groups by default );
No_root_squash: returns the inverse of rootsquash;
Anonuid = xxx: maps all remotely accessed users to anonymous users, and specifies the user as the local user UID = xxx );
Anongid = xxx: maps all remotely accessed user groups to anonymous user group accounts, and specifies the anonymous user group account as the local user group account GID = xxx );
C. Other options:
Secure: Restrict clients to connect to the nfs server from TCP/IP ports smaller than 1024 by default );
Insecure: allows the client to connect to the server from a TCP/IP Port greater than 1024;
Sync: write data synchronously to the memory buffer and disk, which is less efficient, but can ensure data consistency;
Async: stores data in the memory buffer before writing data to the disk if necessary;
Wdelay: Check whether there are related write operations. If yes, execute these write operations together, which can improve the efficiency by default );
No_wdelay: if there is a write operation, it will be executed immediately and should be used with sync;
Subtree: If the output directory is a sub-directory, the nfs server checks the permissions of its parent directory (default );
No_subtree: even if the output directory is a sub-directory, the nfs server does not check the permissions of its parent directory, which improves efficiency;

Now, we need to share the/home/plutonji directory to 192.168.1.2, And the access permission is read-only, so that we can use vi to edit this file for the first time:

[root@server ~]# vi /etc/exports/home/plutonji [192.168.1.2/32(ro)]


4. Start the NFS service

After configuring NFS on the server end, you can start the NFS service!

1. The sequence of precautions for starting portmap and nfs services cannot be incorrect ):

[Root @ server ~] #/Etc/init. d/portmap start portmap: [OK] [root @ server ~] #/Etc/init. d/nfs start NFS service: [OK] disable NFS quota: [OK] start NFS daemon: [OK] start NFS mountd: [OK]

2. Set automatic start upon startup:

[root@server ~]# chkconfig --level 35 portmap on[root@server ~]# chkconfig --level 35 nfs on


V. Client mounting

1. Start the portmap service and set automatic start upon startup, as shown in the preceding figure;

2. Mount/home/plutonji on the server to the local/tmp/plutonji.

[root@client]# mkdir /tmp/plutonji[root@client]# mount 192.168.1.1:/home/plutonji /tmp/plutonji

3. Verify that the mounting is successful:

[root@client ~]# mount | grep nfssunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)192.168.1.1:/home/plutonji on /tmp/plutonji type nfs (rw,addr=192.168.1.1)sh

It indicates that the mounting is successful.

4. Set automatic mounting to add the second line at the end of/etc/fstab ):

[root@client ~]vi /etc/fstab192.168.1.1:/home/plutonji  /tmp/plutonji  nfs  defaults  0  0


In this way, a basic NFS service is configured.

This article is from the "curl nest" blog, please be sure to keep this source http://plutonji.blog.51cto.com/3882205/1301051

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.