About NFS (Network File System) Mounts

NFS mounts work to share a directory between several servers. This has the advantage of saving disk space, as the home directory is only kept on one server, and others can connect to it over the network. When setting up mounts, NFS is most effective for permanent fixtures that should always be accessible.

Setup

An NFS mount is set up between at least two servers. The machine hosting the shared network is called the server, while the ones that connect to it are called ‘clients’.

This tutorial requires 2 servers: one acting as the server and one as the client. We will set up the server machine first, followed by the client. The following IP addresses will refer to each one:

Master: 12.34.56.789

Client: 12.33.44.555

The system should be set up as root. You can access the root user by typing

sudo su

Setting Up the NFS Server

Step One—Download the Required Software

Start off by using apt-get to install the nfs programs.

yum install nfs-utils nfs-utils-lib
 
Subsequently, run several startup scripts for the NFS server:

chkconfig nfs on
service rpcbind start
service nfs start

Step Two—Export the Shared Directory

The next step is to decide which directory we want to share with the client server. The chosen directory should then be added to the /etc/exports file, which specifies both the directory to be shared and the details of how it is shared.

Suppose we wanted to share the directory, /home.

We need to export the directory:

vi /etc/exports

Add the following lines to the bottom of the file, sharing the directory with the client:

/home           12.33.44.555(rw,sync,no_root_squash,no_subtree_check)

These settings accomplish several tasks:

  • rw: This option allows the client server to both read and write within the shared directory
  • sync: Sync confirms requests to the shared directory only once the changes have been committed.
  • no_subtree_check: This option prevents the subtree checking. When a shared directory is the subdirectory of a larger filesystem, nfs performs scans of every directory above it, in order to verify its permissions and details. Disabling the subtree check may increase the reliability of NFS, but reduce security.
  • no_root_squash: This phrase allows root to connect to the designated directory

Once you have entered in the settings for each directory, run the following command to export them:

exportfs -a

Setting Up the NFS Client

Step One—Download the Required Software

Start off by using apt-get to install the nfs programs.

yum install nfs-utils nfs-utils-lib

Step Two—Mount the Directories

Once the programs have been downloaded to the the client server, create the directory that will contain the NFS shared files

mkdir -p /mnt/nfs/home

Then go ahead and mount it

mount 12.34.56.789:/home /mnt/nfs/home

You can use the df -h command to check that the directory has been mounted. You will see it last on the list.

df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda 20G 783M 18G % /
12.34.56.789:/home 20G 785M 18G % /mnt/nfs/home

Additionally, use the mount command to see the entire list of mounted file systems.

mount

Your list should look something like this:

/dev/sda on / type ext4 (rw,errors=remount-ro)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
12.34.56.789:/home on /mnt/nfs/home type nfs (rw,noatime,nolock,bg,nfsvers=,intr,tcp,actimeo=,addr=12.34.56.789)

Testing the NFS Mount

Once you have successfully mounted your NFS directory, you can test that it works by creating a file on the Client and checking its availability on the Server.

Create a file in the directory to try it out:

touch /mnt/nfs/home/example

You should then be able to find the files on the Server in the /home.

ls /home

You can ensure that the mount is always active by adding the directory to the fstab file on the client. This will ensure that the mount starts up after the server reboots.

vi /etc/fstab
12.34.56.789:/home /mnt/nfs/home nfs auto,noatime,nolock,bg,nfsvers=,intr,tcp,actimeo=

You can learn more about the fstab options by typing in:

man nfs

After any subsequent server reboots, you can use a single command to mount directories specified in the fstab file:

mount -a

You can check the mounted directories with the two earlier commands:

df -h
mount

Removing the NFS Mount

Should you decide to remove a directory, you can unmount it using the umount command:

cd
sudo umount /directory name

You can see that the mounts were removed by then looking at the filesystem again.

df -h

You should find your selected mounted directory gone.

转自:https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nfs-mount-on-centos-6

Linux - How To Set Up an NFS Mount on CentOS 6的更多相关文章

  1. OS + RedHat 6.3 x64 NFS / mount.nfs: access denied by server while mounting

    s Linux mount/unmount命令(转) https://www.cnblogs.com/xd502djj/p/3809375.html 问题2:NFS配置项no_root_squash和 ...

  2. 常用NFS mount选项介绍

    通过NFS挂接远程主机的文件系统时,使用一些不同的选现可以使得mount比较简单易用.这些选项可以在mount命令中使用,也可以在/etc/fstab和autofs中设定.  以下是NFS mount ...

  3. Linux实战教学笔记22:企业级NFS网络文件共享服务

    目录 第二十二节 企业级NFS网络文件共享服务 第一章 NFS网络文件共享服务 1.1 NFS介绍 1.2 NFS系统原理介绍 1.3 NFS服务端部署环境准备 1.4 NFS server端的设置 ...

  4. Linux 笔记 - 第二十一章 配置 NFS 服务

    一.前言 NFS(Network File System,网络文件系统),主要功能是通过网络(一般是局域网)让不同的主机系统之间可以共享文件或目录.NFS 客户端(一般为应用服务器,例如web)可以通 ...

  5. nfs mount:reason given by server: Permission denied

    遇到nfs mount的问题,以前从未遇到过,问题出的很奇怪,现象是 mount: 10.1.10.22:/cicro failed, reason given by server: Permissi ...

  6. Linux操作系统(第二版)(RHEL 8/CentOS 8)

    Linux操作系统(第二版)(RHEL 8/CentOS 8) http://www.tup.tsinghua.edu.cn/booksCenter/book_08172501.html Linux操 ...

  7. Linux操作系统(第二版)(RHEL 8/CentOS 8)——勘误表

    Linux操作系统(第二版)(RHEL 8/CentOS 8)--勘误表 http://www.tup.tsinghua.edu.cn/booksCenter/book_08172501.html 本 ...

  8. Linux远程备份—ftp方式、NFS方式

    问题:现在项目中每天都有从其它各个系统发过来的数据文件(存放在/var/data目录下,以.txt结尾),虽然很久以前的文件很少用到,占用了很多空间,却不能删除.于是,想把一个月以前的文件都压缩了传到 ...

  9. linux 磁盘管理三部曲——(3)mount挂载,/etc/fstab配置文件

    当我们分完区,并做好文件系统格式化,就到了最后的挂载mount了,挂载完毕就可以使用磁盘设备了. 一.什么是挂载,卸载 任何块设备都不能直接访问,需挂载在目录上访问 挂载: 将额外文件系统与根文件系统 ...

随机推荐

  1. cf D. Renting Bikes

    http://codeforces.com/contest/363/problem/D 先对b和p排序,用二分求出可以租的车子的最大辆数,其中用mid以后的个人钱数去租前mid的价钱的车子. #inc ...

  2. NGINX当中的SSL配置(PEM启动密码免输入)

    干过的都懂,这个东东好像很碍事. 很影响RELOAD的效率...并且,,,好像这个弄了之后,NGINX作RELOAD之后,可以即时更新配置了..(还是说那个DVROOT.CER影响的??未考证) ht ...

  3. Qt事件机制浅析(定义,产生,异步事件循环,转发,与信号的区别。感觉QT事件与Delphi的事件一致,而信号则与Windows消息一致)

    Qt事件机制 Qt程序是事件驱动的, 程序的每个动作都是由幕后某个事件所触发.. Qt事件的发生和处理成为程序运行的主线,存在于程序整个生命周期. Qt事件的类型很多, 常见的qt的事件如下: 键盘事 ...

  4. PowerShell 字符串操作符

    字符串操作符 格式化操作符 –F 在PowerShell文本操作符中非常重要,经常被用来增强数字类型和日期类型的可读性: "{0} diskettes per CD" -f (72 ...

  5. jQuery 1.6+ 中attr()与prop() 区别

    最近在写一个关于checkbox全选与取消全选的优化方法时,看到很多高手用到了.prop(). 于是在jquery的帮助文档查了一下,才知道这是在jquery 1.6.1中新加的方法,用来设置属性.但 ...

  6. requirejs-define jquery 快速初学实例(一)

    原文地址:http://6yang.net/articles_view.php?id=1103 2011-10-18 13:12:01 by [6yang], 1029 visits, 收藏 | 返回 ...

  7. eucimage

  8. NetAnalyzer笔记 之 九 使用C#对HTTP数据还原

    [创建时间:2016-05-12 00:19:00] NetAnalyzer下载地址 在NetAnalyzer2016中加入了一个HTTP分析功能,很过用户对此都很感兴趣,那么今天写一下具体的实现方式 ...

  9. 照猫画虎学gnuplot之简单介绍

    简单介绍:Gnuplot是一个命令行驱动的科学画图工具,可将数学函数或数值资料以平面图或立体图的形式画在不同种类终端机或画图输出装置上. 它是由Colin Kelley 和 Thomas Willia ...

  10. 设置程序图标-初识IOS

    相信我们都很喜欢做出的程序弄成自己的图标. 在创建项目过后显示的页面中,选择App lcons and launch images,  点击App lcons Source 之后的方向符号,把里面的东 ...