NFS Server Setup in Ubuntu environment

Source: Internet
Author: User

See the bird's private dishes on the NFS introduction, just want to try a demo. It seems that the steps are simple.

1. Background nouns.

NFS (Network File System)

function: Let all unix-like machines share each other's files over the network

Limitations: File permissions issues. The client and server side must have the same account to access certain directories or files.

RPC (Remote Procedure Call)

Role: Specify the port number for each NFS feature and notify the client that the client can connect to the correct port.

When the server starts NFS, it randomly selects several ports and actively registers with RPC, so RPC can know the NFS function for each port.

So before you start NFS, you start RPC, otherwise NFS cannot register with RPC.

2. Server-side configuration

1) Download software

#sudo apt-get Install Rpcbind nfs-kernel-server

2) Create a shared directory

#sudo Mkdir/home/user/nfstest

#sudo chmod 777/home/user/nfstest

3) Modify the configuration file

#sudo Vim/etc/exports

/home/user/nfstest localhost (rw,sync,no_root_squash)

The localhost surface only allows native access, this field can be an IP address. You can also use regular expressions to represent them.

RW Represents a can read and write permissions. RO represents only readable permissions.

Sync the data is synchronously written to memory and hard disk. Async represents that data is staged in memory rather than directly to the hard disk.

the difference between No_root_squash and Root_squash is that when a client user is rooted, the permissions to access the system are different. When the client uses the NFS system's account as root, Root_squash compresses the user to Nfsnobody, and No_root_squash continues to remain rooted.

All_root_squash will compress all the users to Nfsnobody.

4) Restart Service

#sudo/etc/init.d/rpcbind Restart

#sudo/etc/init.d/nfs-kernel-server Restart

* Stopping NFS Kernel daemon   ... do. * unexporting directories for NFS Kernel daemon ...   ... done. * Exporting directories for NFS kernel daemon...exportfs:/etc/exports [1]: Neither ' subtree_check ' or ' No_subtree_check ' Specified for export "Localhost:/home/user/nfstest".  Assuming default behaviour (' No_subtree_check ').  Note:this default has changed since Nfs-utils version 1.0.x   ... done. * Starting NFS Kernel daemon ... done   .

You can see that the NFS kernel daemon started successfully. Fail is displayed if it is unsuccessful.

5) test Server

#showmount-E
Export list for hostname:
/home/user/nfstest localhost
Description server-side build OK.

3. Client Configuration

1) Download software

#sudo apt-get Install Rpcbind Nfs-common

2) Mounting files

#mkdir/home/user/mnt

#chmod 777 /home/user/mnt

#mount-T NFS localhost:/home/user/nfstest /home/user/mnt

MOUNT-T NFS Server name/IP address: Server shared directory local mount directory

3) Client Testing

#cd/home/user/mnt

#touch testfile

You'll see that/home/user/nfstest and /home/user/mnt have testfile files below, indicating that the test was successful.

4. Lifting the Mount

#sudo umount/home/user/mnt

NFS Server Setup in Ubuntu environment

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.