Linux Data Backup (NFS mapping method)

Source: Internet
Author: User
Tags parent directory nfsd

Environment: Red Hat 4.8.3-9 (host) IP address: 192.168.1.1

Ubuntu 4.8.4-2 (slave) IP address: 192.168.1.2

Purpose: To back up the slave data to the host, because the slave space is small, choose the method of using NFS network disk mapping to complete


NFS is the abbreviation for the network file system

Host


Installing NFS Services

nfs-utils-*: Includes basic NFS commands and monitoring programs

portmap-*: Support for secure NFS RPC service (the service renamed Rpcbind)

#查看是否已安装该服务 [[email protected]/]# rpm-qa|grep nfs[[email protected]/]# rpm-qa|grep portmap# install NFS service with installation package on CD [email prot Ected]/]# Yum install-y nfs-utils-*

Note: The Portmap package was not installed, but the Yum List command was not found, and it was confirmed that the service name was changed to Rpcbind.


NFS System Daemon

NFSD: It is the basic NFS daemon, the main function is to manage whether the client can log on to the server;

MOUNTD: It is the RPC installation daemon, and the primary function is to manage the NFS file system. After the client has successfully logged on to the NFS server through NFSD, it must also authenticate with the file usage permissions before using the files provided by the NFS service. It reads the NFS configuration file/etc/exports to compare client permissions.

Portmap: The main function is to do port mapping work. When a client attempts to connect and use a service provided by the RPC server, such as an NFS service, PORTMAP provides the managed port to the client, which enables the client to request services from the server through that port.


Server for NFS Configuration

/etc/exports Primary configuration file for NFS services

/USR/SBIN/EXPORTFS Management commands for NFS services

View commands for/usr/sbin/showmount clients

/var/lib/nfs/etab record full permission SetPoint for NFS-shared directory

/var/lib/nfs/xtab Logging of client information that has been logged on


The NFS service configuration file is/etc/exports, which is the primary NFS configuration file, but the system does not have a default value, so this file does not necessarily exist, it may be created manually using Vim, and then write the configuration content in the file.

/etc/exports File Content format:

< output directory > [Client 1 options (access rights, user mappings, others)] [Client 2 options (access rights, user mappings, others)]

A. Output directory:

The output directory is the directory that the NFS system needs to share with the client;

B. Client:

A client is a computer in the network that can access this NFS output directory

Common ways for clients to specify

Specify the IP address of the host: 192.168.0.200

Specify all hosts in the subnet: 192.168.0.0/24 192.168.0.0/255.255.255.0

Host of the specified domain name: david.bsmart.cn

Specify all hosts in the domain: *.bsmart.cn

All hosts: *

C. Options:

option to set the access permissions, user mappings, and so on for the output directory.

There are 3 main types of NFS options:

Access Permissions Options

Set output Directory read-only: RO

Set output directory Read/write: RW

User mapping Options

All_squash: Maps all normal users and groups that are accessed remotely to anonymous users or user groups (Nfsnobody);

No_all_squash: Reverse with All_squash (default setting);

Root_squash: The root user and the owning group are mapped to anonymous users or groups of users (default setting);

No_root_squash: Reverse with Rootsquash;

ANONUID=XXX: Maps All remote access users to anonymous users and specifies that the user is a local user (uid=xxx);

ANONGID=XXX: Maps All remote Access user groups to anonymous user group accounts and specifies that the anonymous user group account is a local user group account (GID=XXX);

Other options

Secure: Restrict clients from connecting to Server for NFS (default setting) only from TCP/IP ports less than 1024;

Insecure: Allow clients to connect to the server from TCP/IP ports greater than 1024;

Sync: It is inefficient to write data synchronously to memory buffer and disk, but it can guarantee the consistency of data;

Async: Save the data in the memory buffer first, and write to disk if necessary;

Wdelay: Check if there is a related write operation, if any, then perform these writes together, which can improve the efficiency (default setting);

No_wdelay: If a write operation is performed immediately, it should be used in conjunction with sync;

Subtree: If the output directory is a subdirectory, the NFS server will check the permissions of its parent directory (default setting);

No_subtree: Even if the output directory is a subdirectory, the NFS server does not check the permissions of its parent directory, which can improve efficiency;

Simple example:

/home/locoldir 192.168.1.0/24 (rw)

Server for NFS start and stop


After you have configured the exports file correctly, you can start the NFS server.

1. Start the NFS server

In order for the NFS server to function properly, you need to start the Rpcbind and NFS two services, and Rpcbind must start before NFS

[[email protected]/] #service rpcbind Restart[[email protected]/] #service NFS Restart

"Slave Machine"

Launch the mount command to mount the server directory locally for access

Mount-a 192.16.1.1:/test/test1

[Email protected]:/opt/backup# mount-a 192.16.1.1:/test/test1mount:wrong fs type, bad option, bad superblock on 192.  16.1.1:/test, missing codepage or helper program, or other error (for several filesystems (e.g. NFS, CIFS)       Might need a/sbin/mount.<type> helper program) in some cases useful info are found in Syslog-try DMESG | Tail or so

Report above error after execution, error cause not installed Nfs-common service


This article is from "Grace's Technology den" blog, please keep this source http://jimann.blog.51cto.com/3295893/1918945

Linux Data Backup (NFS mapping method)

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.