Linux NFS File Server installation and configuration

Source: Internet
Author: User
Tags server installation and configuration nfsd

1. Scene

An organization needs to configure the NFS server for synchronizing picture files.

Host Name: nfs.local,test.local

IP address: 192.168.3.15, 192.168.3.18


2. Experimental environment

2.1. Operating system

# Cat/etc/redhat-release

Red Hat Enterprise Linux Server release 6.5 (Santiago)

# uname-a

Linux localhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Sun Nov 22:19:54 EST x86_64 x86_64 x86_64 gnu/linux


2.2. Basic Server Configuration

Modify the IP address. (Note: Configured according to your implementation environment)

# Vi/etc/sysconfig/network-scripts/ifcfg-eth0

Device=eth0

Type=ethernet

Onboot=yes

Nm_controlled=yes

Bootproto=static

ipaddr=192.168.3.15

netmask=255.255.255.0

gateway=192.168.3.1

Modify Host Name

# vi/etc/sysconfig/network

Networking=yes

#HOSTNAME =localhost.localdomain

Hostname=nfs.local

# Service Network Restart


To facilitate experimentation, shut down the firewall.

# Service Iptables Stop

# chkconfig Iptables off


Also turn off SELinux.

# Vi/etc/sysconfig/selinux

# This file controls the state of the SELinux on the system.

# selinux= can take one of these three values:

# Enforcing-selinux security policy is enforced.

# Permissive-selinux Prints warnings instead of enforcing.

# disabled-no SELinux policy is loaded.

#SELINUX =enforcing

selinux=Disabled

# selinuxtype= can take one of these the values:

# targeted-targeted processes is protected,

# Mls-multi level Security protection.

selinuxtype=targeted

Restart to take effect.

Reboot or Init 6


3. Server for NFS installation and configuration

3.1. Installing the NFS server component

3.1.1. Installing via Yum

Use YUM to resolve package dependencies.


# yum-y Install Nfs-utils

It's easy to install.


3.2. Start the NFS service

NFS relies on the Rpcbind service, which is set to start automatically

# Chkconfig Rpcbind on

# Chkconfig NFS On

# service Rpcbind Start

# Service NFS Start

Starting NFS services: [OK]

Starting NFS quotas: [OK]

Starting NFS mountd: [OK]

Starting NFS daemon: [OK]

In the log file/var/log/messages, you will see the following information:

RPC.MOUNTD[1797]: Version 1.2.3 Starting

Kernel:nfsd:using/var/lib/nfs/v4recovery as the NFSV4 state

Recovery Directory

Kernel:NFSD:starting 90-second grace period


3.3. Configuring Server for NFS (192.168.3.15)

View the currently shared NFS information

# showmount-e localhost

Export list for localhost: blank no output


Configuring Export Files

# Vi/etc/exports

Add the following and note that there are no spaces between the commas in the options!

/home/tomcat/image/webapps/static/resources * (Rw,no_root_squash,no_all_squash,sync)


Save exit

Exportfs-r//re-mount settings in/etc/exports

Service Rpcbind Restart
Service NFS Restart


3.3.1. Server-side Authentication for NFS sharing:

[Email protected] ~]# SHOWMOUNT-E

Export list for Localhost.localdomain:

/home/tomcat/image/webapps/static/resources *


Note: Normal can display the above settings of the shared directory, if the following error is reported:

Clnt_create:RPC:Program not registered

Description Rpcbind Service and NFS service boot sequence is not right, they both stop, restart, start the Rpcbind service and then start the NFS service;


3.4. Configuring the NFS Client (192.168.3.18)

The NFS client also needs to install the Nfs-utils package.

# yum-y Install Nfs-utils

[Email protected] ~]# showmount-e 192.168.3.15

Export list for 192.168.3.15:

/home/tomcat/image/webapps/static/resources *


3.5. Client base Configuration

Modify the IP address. (Note: Configured according to your implementation environment)

# Vi/etc/sysconfig/network-scripts/ifcfg-eth0

Device=eth0

Type=ethernet

Onboot=yes

Nm_controlled=yes

Bootproto=static

ipaddr=192.168.3.18

netmask=255.255.255.0

gateway=192.168.3.1

Modify Host Name

# vi/etc/sysconfig/network

Networking=yes

#HOSTNAME =localhost.localdomain

Hostname=test.local

# Service Network Restart


In order to facilitate the experiment, the firewall, SELinux shut down.


3.6. Start the service

Start the Rpcbind service, set it to start automatically

# Chkconfig Rpcbind on

# service Rpcbind Start

Client Rpcbind service must be started, NFS can not be started


3.7. Set Startup Auto Mount (192.168.3.18)

[Email protected] ~]# Vi/etc/fstab

New

192.168.3.15:/home/tomcat/image/webapps/static/resources/home/tomcat/image/webapps/static/resources NFS Def Aults 0 0


## /etc/fstab# created by anaconda on fri dec 16 15:54:15  2016## accessible filesystems, by reference, are maintained under  '/ Dev/disk ' # see man pages fstab (5),  findfs (8),  mount (8)  and/or blkid (8)  for more info#/dev/mapper/VolGroup-lv_root /                        ext4     defaults        1 1uuid= 78193f8b-3efc-4c29-bbaf-2d0b1613d69f /boot                    ext4    defaults         1 2/dev/mapper/VolGroup-lv_home /home                    ext4    defaults         1 2/dev/mapper/VolGroup-lv_swap swap                     swap    defaults         0 0tmpfs                    /dev/shm                 tmpfs   defaults         0 0devpts                   /dev/pts                 devpts  gid=5,mode=620  0 0sysfs                    /sys                     sysfs    defaults        0 0proc                     /proc                    proc     defaults        0 0192.168.3.15:/home/tomcat/ image/webapps/static/resources /home/tomcat/image/webapps/static/resources            nfs     defaults         0 0


Four. Knowledge expansion

Exports command:

The parameters are described below.
(1)-A: all mounts (or uninstalls) the settings in the/etc/exports file.
(2)-R: Re-mount the settings in/etc/exports, and also update the contents of/etc/exports and/var/lib/nfs/xtab synchronously.
(3)-U: Uninstalls a directory.
(4)-V: Displays the shared directory on the screen at export.



/etc/exports File Content format:

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

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;


This article is from "Operation and maintenance record Mei Ling" blog, please be sure to keep this source http://meiling.blog.51cto.com/6220221/1911807

Linux NFS File Server installation and configuration

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.