How to build an NFS server

Source: Internet
Author: User
To complete the final configuration of the NIS server, you must also configure the NFS server. NFS: The network file system is mainly a file sharing method between Linux hosts. by sharing the shared directory of the NFS server, the client only needs to mount the shared directory to its local system so that the client can access the NFS server like accessing local files.

To complete the final configuration of the NIS server, you must also configure the NFS server.

NFS, Network File System

This is mainly a file sharing method between Linux hosts. by sharing the shared directory of the NFS server

You only need to mount the shared directory to your local system, so that the client can access

Ask about the shared resources on the NFS server.

Install the NFS service:
Host IP: 192.168.3.155
Software required: nfs-utils and portmap:
[Root @ rhel ~] # Rpm-qa | grep nfs
System-config-nfs-1.2.8-1
Nfs-utils-lib-1.0.6-3
Nfs-utils-1.0.6-70.EL4
The NFS service package has been installed on the host. Generally, the portmap package has been installed along with the system.


Configure the NFS configuration file


The NFS service configuration file is the/etc/exports file. This file is an empty file by default and needs to be edited by yourself:
The NIS server is output to the/home directory of the shared server. enter the following content:
[Root @ rhel ~] # Vi/etc/exports
The following content is added:
/Home 192.168.3.0/24 (rw, sync, no_root_squash)

/Home: indicates the directory to be shared.
192.168.3.0/24
(Rw, async, no_root_squash): permission.
Rw: indicates that this directory can be read and written.
Sync: indicates synchronization.
Ro; indicates read-only

After the configuration is complete, start the NFS service:
[Root @ rhel ~] # Service nfs restart
Shutting down NFSmountd: [FAILED]
Shutting down NFSdaemon: [FAILED]
Shutting down NFSquotas: [FAILED]
Shutting down NFSservices: [OK]
Starting NFSservices: [OK]
Starting NFSquotas: [OK]
Starting NFSdaemon: [OK]
Starting NFSmountd: [OK]

Enable NFS upon startup:
[Root @ rhel ~] # Chkconfig -- level 35 nfs on
[Root @ rhel ~] # Chkconfig -- list nfs
Nfs 0: off 1: off 2: off 3: on 4: off 5: on 6: off

Run the following command to view the shared directory on the NFS server:

[Root @ rhel ~] # Showmount-e 192.168.3.155
Export list for 192.168.3.155:
/Home 192.168.3.0/24

-------------------------
NFS client configuration:

NFS Client: 192.168.3.160

First, check whether the current host allows mounting shared directories:

[Root @ linux5 ~] # Showmount-e 192.168.3.155
Export list for 192.168.3.155:
/Home 192.168.3.0/24

The result is that it can be mounted.

Now mount the shared directory/home to the local/home. It is easy for NIS users to log on to their home directories.

Run the following command:

[Root @ linux5 ~] # Mount-t nfs 192.168.3.155:/home // home
After mounting, check whether the shared directory of the NFS server is mounted.

[Root @ linux5 ~] # Mount | grep home
/Dev/sda2 on/home type ext3 (rw)
192.168.3.155:/home/on/home type nfs (rw, addr = 192.168.3.155)
The system prompts that the mounting is successful.


As a result, such a command is executed every time the client is started, we can write this command


In the following file:
Add the mount-t nfs 192.168.3.155:/home // home statement to the end of/etc/rc. d/rc. local.

However, you can also use the following method:
Add the following content to/etc/fstab to enable automatic mounting:
Vi/etc/fstab

LABEL = // ext3 defaults 1 1
LABEL =/home ext3 defaults 1 2
LABEL =/boot ext3 defaults 1 2
Tmpfs/dev/shm tmpfs defaults 0 0
Devpts/dev/pts devpts gid = 5, mode = 620 0 0
Sysfs/sys sysfs defaults 0 0
Proc/proc defaults 0 0
LABEL = SWAP-sda3 swap defaults 0 0
192.168.3.155:/home // home nfs defaules 0 0

Add the last line, and the shared directory of the NFS server will be automatically mounted after startup.

We continue to operate the NIS service. We use user1 users to log on to the NIS client (192.168.3.160 ).

Log on to user1 on the NIS server (192.168.3.155,
Login as: user1
User1@192.168.3.160's password:
Last login: Wed Apr 16 04:31:28 2008 from 192.168.3.170
[User1 @ linux5 ~] $

Check that the user user1 is logged on to the host (192.168.3.160, client) of Linux5.

Recorded.

NFS mounting is successful.

The NIS service is also successful.

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.