File Server-NFS

Source: Internet
Author: User

Network FileSystem (NFS): a Network file system, mainly used to access the file system on a remote host.

1. Install the nfs server

#1. Check Software Installation

[Root @ jiang ~] # Rpm-qa | grep rpcbind

[Root @ jiang ~] # Rpm-qa | grep nfs

#2. install required software

[Root @ zhu ~] # Yum-y install rpcbind nfs-utils

Rpcbind: rpc program software. Before CentOS5, the software name is portmap, and centos6 uses rpcbind.

Nfs-utils: software required for the nfs service


2. Start nfs

[Root @ zhu ~] # Service rpcbind start

Starting rpcbind: [OK]

[Root @ zhu ~] # Service nfs start

Start the NFS service: [OK]

Start NFS mountd: [OK]

Start the NFS daemon: [OK]

Starting RPC idmapd: [OK]


3. Configure the nfs server. The main nfs configuration file is/etc/exports. If the file does not exist, you must manually create it.

/Etc/exports file configuration Syntax:

[Root @ zhu ~] # Cat/etc/exports

/Root/mypython * (rw, no_root_squash) www.jiang.com (ro, no_root_squash)

/Root/mysource 192.168.56.102 (rw, no_root_squash)

######################################## ###########

#1. in the unit of behavior, the first part of each line is the shared directory, followed by the host that allows access to this directory and the access permission.

#2. The host that can be accessed can be an IP address or domain name, which can be written as follows:

192.168.56.102 (rw, no_root_squash)

192.168.56. * (rw, no_root_squash)

* (Rw, no_root_squash)

192.168.56.0/24 (rw, no_root_squash)

#3. The host should be followed by the corresponding permissions. Do not have spaces between the host and.


Permission type:

# The permissions are as follows:

Rw: read/write

Ro: Read-Only

Sync: data is synchronized to the memory and hard disk,

Async: data is first stored in the memory,

Root_squash: When nfs is used, if the user is root, the permission is compressed. That is, the root user's file group and major on nfs are changed to nfsnobody.

No_root_squash: When nfs is used, if the user is root, no permission compression is performed, that is, the root user's file group and owner created on nfs are still root (insecure, not recommended)

Insecure: allows the client to connect to the NFS server from a TCP/IP Port greater than 1024

Secure: Restrict clients to connect to the NFS server only from TCP/IP ports smaller than 1024 (default)


# This is a common permission, and other permissions can be viewed by man exportfs.

Permission summary:

[Root @ zhu ~] # Cat/etc/exports

/Root/mypython * (rw, no_root_squash)

/Root/mysource 192.168.56.102 (rw)

/Tmp * (rw)


1. For the/tmp directory on the nfs server.

[Root @ jiang ~] # Mount-t nfs 192.168.56.101:/tmp // root/zhuzhu/

[Root @ jiang ~] # Cd zhuzhu/

[Root @ jiang zhuzhu] # ll

Total usage 0

[Root @ jiang zhuzhu] # touch zhu.txt

[Root @ jiang zhuzhu] # ll

Total usage 0

-Rw-r --. 1 nfsnobody 0 March 27 2014 zhu.txt

[Root @ jiang zhuzhu] # su zhu

[Zhu @ jiang zhuzhu] $ mkdir zhu

[Zhu @ jiang zhuzhu] $ ll

Total usage 4

Drwxrwxr-x. 2 nobody 4096 2014 zhu

-Rw-r --. 1 nfsnobody 0 March 27 2014 zhu.txt

#1. When a root user is used, the root user will create an nfsnobody file owner because the default permission is root_squash.

When a zhu user is used, the file owner is nobody because there are no zhu users on the nfs server.

#2. If the/tmp directory has no write permission on zhu users, zhu users on the client cannot write even if the write permission is enabled in the/etc/exports file.


###############

Software optional for nfs clients

Yum-y install nfs-utils rpcbind


######################################## ##

# Instructions related to nfs servers:

After the/etc/exports file is modified again, you do not need to restart the nfs server. You can use the exportfs command to manage it.

Exportfs [-avru]

-A: unmount or mount all the content in the/etc/exports file. It is usually used in combination with-r or-u.

-R: Remount the content in the/etc/exports file.

-U: unmount a directory

-V: displays the shared directory on the screen.

#1. Remount the settings in/etc/exports

[Root @ zhu ~] # Exportfs-arv

Exporting 192.168.56.102:/root/mysource

Exporting *:/tmp

Exporting *:/root/mypython

The shared directory on the nfs server can be mounted on the client.

[Root @ jiang ~] # Mount-t nfs 192.168.56.101:/tmp/zhuzhu

#2. unmount all content in the/etc/exports file

[Root @ zhu ~] # Exportfs-au

At this time, the client cannot be mounted successfully.

[Root @ jiang ~] # Mount-t nfs 192.168.56.101:/tmp/zhuzhu

Mount. nfs: access denied by server while mounting 192.168.56.101:/tmp/

[Root @ zhu ~] # Exportfs-ar # reload on the server

# In this case, the client can be mounted successfully.

[Root @ jiang ~] # Mount-t nfs 192.168.56.101:/tmp/zhuzhu

#3. The-v parameter can also be used to view the default permissions of shared directories.

[Root @ zhu ~] # Exportfs-v

/Root/mysource 192.168.56.102 (rw, wdelay, root_squash, no_subtree_check)

/Root/mypython <world> (rw, wdelay, no_root_squash, no_subtree_check)

/Tmp <world> (rw, wdelay, root_squash, no_subtree_check)


The showmount command can be used to view information shared by the nfs server on the client.

Showmount [-adehv] [host]

-E: displays the directories shared by the nfs server.

[Root @ zhu ~] # Showmount-e localhost # The host address is localhost. Therefore, run

Export list for localhost:

/Tmp *

/Root/mypython *

/Root/mysource 192.168.56.102

[Root @ jiang ~] # Showmount-e 192.168.56.101 # view the directory shared by the machine 192.168.56.101 on the client side

Export list for 192.168.56.101:

/Tmp *

/Root/mypython *

/Root/mysource 192.168.56.102

Install NFS server in Ubuntu 12.04

Install and configure the NFS server to share the Ubuntu 12.04 and ARM files.

Build an nfs server in Ubuntu

File Server NFS configuration details

Build an NFS Network File System server in Ubuntu

Heartbeat_ldirector + LB + NFS for HA, LB, and file sharing

How to Configure NFS server in CentOS 5.5

Install and use NFS in Ubuntu 12.10

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.