NFS Server Building Essentials

Source: Internet
Author: User
Tags root access

Linux NFSServer(file sharing)

NFS Main application scenario is in the production environment, hundreds of servers in order to achieve data synchronization or file sharing, will take advantage of NFS, a shared LAN

1.1.Overview

RPC Main program:rpcbind rpcbind.i686 port:111

NFS Main program:nfs-utils nfs-utils.i686 port:2049

File Share RPC.NFSD

Permission Settings rpc.mountd

file lock RPC.LOCKD

file Consistency rpc.statd

default Port 111 2049

RPC Remote Procedure Call

1.2.Install the software:

Yum Install Rpcbind-y

Yum Install Nfs-utils-y

1.3.Services and Ports

Service autofs Restart

Service NFS Restart

Service rpcbind Restart

centos5.x 's Services

/etc/init.d/portmap Restart;

/etc/init.d/nfs Restart;

centos6.x 's Services

/etc/init.d/rpcbind restart\

/etc/init.d/nfs restart

1.4.configuration file

Vi/etc/sysconfig/nfs

# mainly for three programs set Port rpc.mountd RPC.LOCKD rpc.statd

#LOCKDARG =

# TCP Port RPC.LOCKD should listen on.

lockd_tcpport=4000

# UDP Port RPC.LOCKD should listen on.

lockd_udpport=4000

# Optional arguments passed to Rpc.mountd.See Rpc.mountd (8)

#RPCMOUNTDOPTS = ""

# Port RPC.MOUNTD should listen on.

mountd_port=4001

#

# Optional arguments passed to Rpc.statd.See rpc.statd (8)

#STATDARG = ""

# Port RPC.STATD should listen on.

statd_port=4002

# outgoing port statd should used. Thedefault is Port

# is random

#STATD_OUTGOING_PORT =2020

Rpcinfo-plocalhost # querying RPC assigned Ports

1.5.configuration of the firewall:

Iptables-i INPUT 1-p TCP--dport 111-jaccept

Iptables-i INPUT 1-p UDP--dport 111-jaccept

Iptables-i INPUT 1-p TCP--dport 2049-jaccept

Iptables-i INPUT 1-p UDP--dport 2049-jaccept

Iptables-i INPUT 1-p TCP--dport4000:4002-j ACCEPT

Iptables-i INPUT 1-p UDP--dport4000:4002-j ACCEPT

Service Iptables Save

1.6.NfsConfiguration

Configuration steps:

1. set /etc/exports 's shared directory /xx 192.168.1.0/24 (rw,sync)

2. Restart Service Services rpcbind Restart service NFS Restart

3. Client Access showmount-e192.168.1.100 query sharing is successful

4. Mount Mount

Vi/etc/exports

............................................................................

shared directory Range ( attribute 1, property 2, property 3)

/xx 192.168.1.0/24 (Rw,sync, "Root_squash")

...........................................................................

Property list:

# ro Read-only access

# RW read/write access

# Sync All data written to share on request

# hide does not share its subdirectories in the NFS shared directory

# No_hide subdirectories for shared NFS directories

# Root_squash is the root access to the shared folder that the client uses as root to convert

# no Root_squash is the right to cancel conversion

# All_squash Convert all user rights to Nfsnobody

# No_all_squash reserved UID and GID for shared files (default)

# anonuid=1000,anongid=1000 Specifies the user converted to UID

# vi/var/lib/nfs/etab Query default Some of the options

# Exportfs-arv all shared re-mounts

# Exportfs-au Cancel all shares

# represents the entire network segment, if you want to represent a host, to the operator mask number 32

1.7.Client Access

Client to install Nfs-utils

SHOWMOUNT-E 192.168.1.250

# Query which shares shared by the 1.250 server

Mount–t NFS 192.168.1.250:/xx/bb

# mount the shared folder on the server to the BB folder in the native root directory

1.8.Auto Mount automatically mount when using mount points

Automatically mounts when using external devices, such as CD-ROM mount points, does not mount when idle

1. first write to mount directory file,

Vi/etc/auto.master

# This file is primarily about modifying files for external devices that need to be mounted

#

/misc/etc/auto.misc

/mnt/etc/auto.misc #/mnt represents all subfolders under the MNT directory

/-/etc/auto.misc #/- represents all subfolders under the root directory

#

Vi/etc/auto.misc

# This directory modifies the external load point

#

# a Automounter map and it has thefollowing format

# key [-mount-options-separated-by-comma]location

# Details May is found in the AutoFS (5) manpage

Cd-fstype=iso9660,ro,nosuid,nodev:/dev/cdrom

cdrom-fstype=iso9660:/dev/cdrom

NFS-FSTYPE=NFS,RW 192.168.30.250:/xx

# CD CDROM NFS Rep is a subdirectory, directory that does not exist by itself

#-fstype= Device Type

# behind the Mount device can be a device or a shared folder

# The following entries is samples Topique your imagination

#linux-ro,soft,intr Ftp.example.org:/pub/linux

#boot-fstype=ext2:/dev/hda1

Service AutoFS Stop

Service AutoFS Start

# cannot use Rstart

1.9.WindwosMountLinuxHostNfs

To start the WINDOSNFS Client service:

1. Open or close Windows features->NFS client in Control Panel, programs ,

Tick the NFS client, which opens the Windows NFS Client service.

2.win+r->cmd

Mount 192.168.1.10:/home/ user/share X:

Successfully mount, open my brain, you can see x: Disk in your network location

Explain:

Mount, is the directive

192.168.1.10 your Linux host IP

/home/share your shared directory

X: you mount the network file disk--note that may conflict with your other disk, you can change it arbitrarily

3. Remove the mount:

Directly inside my Computer mouse click Unmap Network drive X:

Or: Win+r->cmd

Input: umountx:

(umount-a cancel all network drives)

Well, enjoy it, and wish you success!

1.10.shared directory permission Instances1

5 accounts share a directory /home/usergroup This directory, this can only be used by the 5 users, the directory has all permissions, other people have no permissions,

need to have SGID permissions, otherwise 5 accounts will be unable to modify each other's data,

Mkdir/home/usergroup

Chgrp Usergroup/home/usergroup

CHOMD 2770/home/usergroup

Ll-d/home/usergroup

Disk quota limits for shared directories

Each user has a quota of 2GB (hard) and 1.8GB (soft),

1.vim/etc/fstab # to set up a boot mount

2. adding userquota,grpquota after RW can also mount-o usrquto,grpquota/dev/sda1/mnt/disk

3.quotacheck-avug making data Files

4.group quotas turned on

5.user quotas turned on

6.edquota-u User1 # configuring quotas for users

7.edquota-p user1 user2 # replication Configuration to other users

8.repquota-au # Query all user quotas with

1.11.Step Essence¡ï ★
  1. Install the software yum install rpcbind nfs*-y

  2. Configure shared vi/etc/export write shared directory format: /mnt 192.168.1.100 (rw)

  3. Restart Services service rpcbind Restart service NFS Restart

  4. turn off firewall or selinux check allocation port rpcinfo-p localhost

  5. Client Install yum Install Nfs-utils–y

  6. Showmount–e 192.18.1.100 Test Results

  7. Mount Mount 192.168.1.100:/mnt/xx on Mount

1.12.Trouble Shooting

Write files to a shared directory

[[Email protected] ~] #touch AA

Touch: Unable to create "AA": Insufficient permissions

Check if the shared directory itself has write access to other

Note: The shared folder client does not allow root permissions by default , which means that the actual use of root also


be changed to Nfsnobody

A case in which an unexpected interrupt was mounted and cannot be manipulated:

Error message:

[Email protected]~]# Mount 192.168.182.128:/mnt/tmp/

Mount.nfs:access denied by server while mounting 192.168.182.128:/mnt

Workaround: This is because authorized access has no permissions in exports , to specify that the network segment or IP has permission to Mount, you can also use * to represent all

/mnt 192.168.1.0/24 (rw) # This Ip segment, or on behalf of all /mnt * (rw)

1.12.1.Limit only1.10host can access, in fact, can not access

/xx 192.168.1.10/32 (Rw,sync) 192.168.1.0/24 (R0,sync)

# If you do not add 192.168.1.0/24 (R0,sync), on behalf of other computers can not mount

1.12.2.background mount, network disconnect auto Mount

mount-0 BG 192.168.1.250:xx/mnt

Error message:

[Email protected] ~]# showmount-e192.168.242.128

Clnt_create:RPC:Program not registered

# The software is not registered because the service did not restart

[Email protected] ~]# showmount-e192.168.242.128

Clnt_create:RPC:Port mapper failure-unable to Receive:errno 113 (No route to host)

# Port connection failed, firewall settings

[Email protected] etc]# showmount-e 192.168.16.170

Clnt_create:RPC:Port Mapper failure-unable to Receive:errno 111 (Connection refused)


This article is from the "Zhongliang Linux Technology blog" blog, make sure to keep this source http://zhongliang.blog.51cto.com/4507905/1878978

NFS Server Building Essentials

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.