Linux settings NFS shared directory __linux

Source: Internet
Author: User
First, see if NFS is installed (Portmap is used for RPC transmissions)
# rpm-q Nfs-utils Portmap
Nfs-utils-1.0.9-47.el5_5
portmap-4.0-65.2.2.1
Second, the configuration
1. Configuration file
# Vi/etc/exports
Configuration instance:
1)/nfs/public 192.168.16.0/24 (rw,async) * (RO)
Shared Directory Client 1 Client 2
The Nfs/public shared directory is available for all clients in the subnet 192.168.16.0/24 to read and write, and clients on other networks can only have read operation permissions.
2)/home/test 192.168.0.0/24 (Rw,no_root_squash,async)
No_root_squash: Does not say that the root user and the owning user group are mapped to an anonymous user or user group, the default root is the nfsnobody that is mapped to an anonymous user, all even if the RW Write permission is enabled, the client is unable to write, this does not map to an anonymous user, Also retains the original user rights to be able to read and write, because usually is logged in with the root user.
Note: When the passenger plane has permission to write, also depends on the directory for the user has no open Write permission

III. Maintenance of NFS
Format:
EXPORTFS option Parameters
-A: All directories set in the output/etc/exports
-R: Re-read the settings in the/etc/exports file and takes effect immediately without restarting the NFS service.
-U: Stop outputting a directory
-V: Displays the directory on the screen when the directory is output.
1. After modifying the vi/etc/exports, do not restart the service, use the command output to share the directory directly
# EXPORTFS-RV
2. Stop outputting all shared directories
# EXPORTFS-AUV
Iv. Start and stop NFS services
1. Start NFS Service
In order for NFS to work properly, you need to start both the Portmap and NFS directories, and Portmap must be started before NFS.
#/etc/init.d/portmap Start
#/etc/init.d/nfs Start
2. Stop NFS Services
Before stopping an NFS server, you need to stop the NFS service before stopping the Portmap service. If there are other services in the system that need to be portmap, you can stop the Portmap service.
/etc/init.d/nfs stop
/etc/init.d/portmap stop
3. Self-starter NFS Service
Chkconfig--level Portmap on
Chkconfig--level NFS On
Five, test
1. Check the output directory for the options used
In the/etc/exports configuration file, even if only one or two options are set, there are actually a lot of candidates in the actual output directory. By looking at the/var/lib/nfs/etab file, you know what the options are when you actually output the directory.
2. Test NFS Output directory status using Showmount
Format:
Showmount parameter option NFS server name or address
-A: Displays all client hosts for the specified NFS server and the directories they are connected to
-D: Displays all shared directories that have been connected by clients in the specified NFS server
-E: Displays shared directories for all outputs on the specified NFS server
(1) View shared directories for all outputs
# SHOWMOUNT-E
(2) display all the output directories that are mounted
# showmount-d
Vi. Client usage Configuration for NFS
1. View NFS Server information
On the client side, to see which shared directories are on Server for NFS, you can use the Showmount command.
# SHOWMOUNT-E 192.168.0.51
If an error message occurs, first check to see if the server NFS and Portmap services are started. And see if it was blocked by a firewall.
2. Mount a shared directory on an NFS server
# mount-t NFS 192.168.0.51:/home/test/mnt/
-T: Specifies the file type of the mounted Device (NFS is a network file system)
192.168.0.51:NFS Server IP Address
Shared directory for/HOME/TEST:NFS servers
/mnt/: Mounted in a local directory
3. Uninstall NFS
You can uninstall the directory with the Umount command when you do not use the NFS directory
Note: When a client is connecting to an NFS server, you should shut down the Portmap and NFS services when you want to turn off Server for NFS, otherwise it will take a long time to shut down normally. If Portmap and NFS cannot be turned off, the process is killed directly. You can also use the EXPORTMAP-AUV command to stop all output directories in the current host and then shut down.

4. Automatically connect to NFS server at startup
To first automatically connect to the shared directory on the NFS server at startup, edit the/etc/fstab file. Add in File
192.168.0.51:/home/test/mnt NFS Defaults 0 0
Shared directory for 192.168.0.51:/HOME/TEST:NFS servers
/MNT: Native Mount Directory

-------------------------------------------------
Common parameters for CP command at copy
Cp-a-v/mnt/home/
-A This option is usually used when copying directories. It retains the link, file attributes, and recursively copies the directory, which is equal to the combination of the DPR option.
The-V or –verbose displays the instruction execution process.
-v< Backup mode > or –version-control=< backup method > Back up the destination file with the "-B" parameter, the end of the backup file is added with a backup string, which can be changed not only with the "-S" parameter, but also with "-V" parameter specifies different backup methods, a backup string is also generated at the end of a different word.
-I and F options, in contrast, will be prompted to confirm the user before overwriting the target file. When you answer y, the target file is overwritten and is an interactive copy.

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.