Ubuntu 16.04系统上NFS的安装与使用

Ubuntu 16.04镜像源:

# deb cdrom:[Ubuntu 16.04.3 LTS _Xenial Xerus_ - Release amd64 (20170801)]/ xenial main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu xenial partner
# deb-src http://archive.canonical.com/ubuntu xenial partner

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
#deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse

一、服务器端:

1.1安装NFS服务:

sudo apt install nfs-kernel-server

1.2编写配置文件:

vi /etc/exports

#/etc/exports文件的内容如下:

/tmp *(rw,sync,no_subtree_check,no_root_squash)

/data *(rw,sync,no_subtree_check,no_root_squash)

/logs *(rw,sync,no_subtree_check,no_root_squash)

1.3重启nfs服务

sudo service nfs-kernel-server restart

1.4查询命令

showmount -e localhost

#将配置文件中的目录全部重新export一次!无需重启服务。

sudo exportfs -rv

#查看NFS的运行状态

sudo nfsstat

#查看rpc执行信息,可以用于检测rpc运行情况

sudo rpcinfo

#查看网络端口,NFS默认是使用111端口。

sudo netstat -tu -4

二、客户端:

2.1安装客户端工具:

#在需要连接到NFS服务器的客户端机器上,

#需要执行以下命令,安装nfs-common软件包。

#apt会自动安装nfs-common、rpcbind等12个软件包

sudo apt install nfs-common

 

2.2查看NFS服务器上的共享目录

#显示指定的(192.168.3.167)NFS服务器上export出来的目录

sudo showmount -e 192.168.3.167

 

2.3创建本地挂载目录

sudo mkdir -p /mnt/data

sudo mkdir -p /mnt/logs

 

2.4挂载共享目录

#将NFS服务器192.168.3.167上的目录,挂载到本地的/mnt/目录下

sudo mount -t nfs 192.168.3.167:/data /mnt/data

sudo mount -t nfs 192.168.3.167:/logs /mnt/logs

  

#注:在没有安装nfs-common或者nfs-kernel-server软件包的机器上,

#直接执行showmount、exportfs、nfsstat、rpcinfo等命令时,

#系统会给出友好的提示,

#比如直接showmount会提示需要执行sudo apt install nfs-common命令,

#比如直接rpcinfo会提示需要执行sudo apt install rpcbind命令。
 

转载:https://blog.csdn.net/csdn_duomaomao/article/details/77822883

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值