RHEL6.3 configuration file sharing (1) NFS service

Source: Internet
Author: User

File sharing is one of the most commonly used network applications in an enterprise's internal network. It is easy to set file sharing in Windows. In Linux, two methods are provided to set file sharing: NFS and Samba. File Sharing implemented by the NFS service can only be used between Linux systems, while Samba can achieve mutual access between Windows and Linux systems.

This article will introduce the NFS service.

NFS is a Network File System developed by Sun in 1984. It is mainly used for file sharing between UNIX and Linux systems. It adopts the Client/Server working mode. On the NFS server, it sets a directory as a shared directory, and then the client can mount this directory to a local directory for use.


1. Enable the NFS service
When configuring a Linux server, you must first perform a set of standard procedures.

1) First, check whether the NFS service has been installed. You can use the rpm command to query:

650) this. width = 650; "title =" 001.jpg" src = "http://www.bkjia.com/uploads/allimg/131227/1RA15395-0.jpg"/>

You can find that the NFS service has been installed by default. It doesn't matter if it is not installed. Configure the yum source and run the "yum install nfs-utils" command to install the nfs service.
2) Although the system has installed the NFS service by default, Is it running? The following describes how to use the service command.

650) this. width = 650; "title =" 001.jpg" src = "http://www.bkjia.com/uploads/allimg/131227/1RA11107-1.jpg"/>

We can find that the service is not running, so we can open the service:

650) this. width = 650; "title =" 001.jpg" src = "http://www.bkjia.com/uploads/allimg/131227/1RA1G30-2.jpg"/>

3) do not forget to set Automatic startup for the service at the end:
[Root @ localhost ~] # Chkconfig nfs on

2. Configure the NFS service
In Linux, you can modify the corresponding configuration file to configure various services. The NFS service configuration file is/etc/exports. In the exports file, you can set NFS shared directories, access permissions, and accessible hosts. By default, this file is an empty file with no shared directory configured. This is based on security considerations and will not share any resources even if the system starts the NFS service.
Next we create a/commondirectory and create a test file hello.txt in it.
[Root @ localhost ~] # Mkdir/common
[Root @ localhost ~] # Vim/common/hello.txt
Set the/common directory to share.
Modify the configuration file/etc/exports:
# The vim/etc/exports file is an empty file. We recommend that you use tab to complete the file name)
Add the following line to the file:
/Common 192.168.61.0/255.255.255.0 (ro, sync)
Save and exit.
Configuration File description:
/Common specifies the directory to be shared
192.168.61.0/255.255.255.0 allow access to the shared network segment. If you allow access from all clients, you can use the wildcard "*".
The permission of the ro client to access the shared directory. ro indicates read-only, rw indicates readable and writable.
Sync sets the NFS server to write data to disks synchronously, so that data will not be lost easily. We recommend that you use this option for all NFS shared directories.

After modifying the configuration file, restart the service to take effect:
[Root @ localhost ~] # Service nfs restart

3. Use the NFS service
Next we will first check the configured NFS sharing on the local IP address 192.168.11.61). Here we will use the showmount command to view the sharing.

You can use the showmount command to view NFS sharing information of a specified server. Common options of this command:
-E: displays all output shared directories on the specified NFS server.
For example, run the showmount command on the machine to view NFS sharing:
650) this. width = 650; "title =" 001.jpg" src = "http://www.bkjia.com/uploads/allimg/131227/1RA14357-3.jpg"/>

We can see that we have set the sharing successfully.

Next we will go to another client with the same Linux system installed, and try to see whether NFS sharing information can be found. However, the failure was caused by the firewall on the NFS server. The firewall configuration in Linux is complicated and we will introduce it later. Therefore, we need to disable the firewall in the future server configuration process.

You can use the setup tool to disable the firewall.

650) this. width = 650; "title =" 001.jpg" src = "http://www.bkjia.com/uploads/allimg/131227/1RA1A06-4.jpg"/>

 

After the firewall is disabled, you can view the NFS shared directory on the client.
However, you can only view NFS sharing using the showmount command. to use it, you must also mount it locally. Mount the NFS shared directory on the client to the local/mnt/nfs directory:
[Root @ localhost ~] # Mkdir/mnt/nfs
[Root @ localhost ~] # Mount 192.168.11.61:/common/mnt/nfs
In this way, you only need to access the/mnt/nfs directory to see the content in the shared directory:

[Root @ localhost ~] # Ls/mnt/nfs
Hello.txt
If you want to automatically mount the NFS shared directory at startup, you can modify the/etc/fstab file and add the following line to it:
192.168.11.61:/common/mnt/nfs ults 0 0
Save and exit.

This article is from the "one pot of turbidity wine" blog. For more information, please contact the author!

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.