nfs的安装和配置

nfs的安装和配置,经常安装,做个比较复制快些。

1. yum 安装

yum install nfs-utils -y
yum install rpcbind -y
yum install mount.nfs -y

 

2. 选择好要nfs的目录

mkdir /var/exportfs
mkdir /var/exportfs/upload
mkdir /var/exportfs/share

如果是挂载的其它盘则使用

cat /etc/fstab
/dev/vdb1		/var/redis		ext4	defaults	0 0
/dev/vdb2		/var/exports		ext4	defaults	0 0
mount -a    //挂载

或者:

mount [-t type] [-o option] device dir
mount -t ext4 /dev/vdb1 /var/redis
//卸载
umount /dev/vdb1    或umount /var/redis

 

3. 编写exports文件(nfs配置文件)

cat /etc/exports
/var/exportfs/upload		10.30.196.147/32(rw,no_root_squash,no_all_squash,sync) 10.30.196.142/32(rw,no_root_squash,no_all_squash,sync) 10.27.109.112/32(rw,no_root_squash,no_all_squash,sync) 10.27.110.20/32(rw,no_root_squash,no_all_squash,sync) 10.27.110.13/32(rw,no_root_squash,no_all_squash,sync)
/var/exportfs/share		10.30.196.147/32(rw,no_root_squash,no_all_squash,sync) 10.30.196.142/32(rw,no_root_squash,no_all_squash,sync) 10.27.109.112/32(rw,no_root_squash,no_all_squash,sync) 10.27.110.20/32(rw,no_root_squash,no_all_squash,sync) 10.27.110.13/32(rw,no_root_squash,no_all_squash,sync) 10.27.60.27/32(rw,no_root_squash,no_all_squash,sync) 10.28.109.8/32(rw,no_root_squash,no_all_squash,sync) 10.28.142.168/32(rw,no_root_squash,no_all_squash,sync) 10.27.210.240/32(rw,no_root_squash,no_all_squash,sync)

设定那些机器具有那些权限

 

4. 启动nfs

service rpcbind start
service nfs start

如果出现

Starting NFS mountd: rpc.mountd: svc_tli_create: could not open connection for udp6
rpc.mountd: svc_tli_create: could not open connection for tcp6
rpc.mountd: svc_tli_create: could not open connection for udp6
rpc.mountd: svc_tli_create: could not open connection for tcp6
rpc.mountd: svc_tli_create: could not open connection for udp6
rpc.mountd: svc_tli_create: could not open connection for tcp6
                                                           [FAILED]

这个是ipv6的支持,不需要则可以

vi /etc/netconfig 
udp tpi_clts v inet udp - -
tcp tpi_cots_ord v inet tcp - -
#udp6 tpi_clts v inet6 udp - -
#tcp6 tpi_cots_ord v inet6 tcp - -
rawip tpi_raw - inet - - -
local tpi_cots_ord - loopback - - -
unix tpi_cots_ord - loopback - - -

如果出现

Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
rpc.nfsd: address family inet6 not supported by protocol TCP
rpc.nfsd: unable to set any sockets for nfsd

这是rpcbind没有启动,需要先启动rpcbind, service rpcbind start

6. 需要主要的地方:

service rpcbind start
rpcbind需要比nfs先启动

然后在service nfs start
过程中需要确保nfs 和rpcbind 服务会开机启动。
chkconfig rpcbind --list
chkconfig nfs --list
chkconfig rpcbind on
chkconfig nfs on

 

7. nfs客户机

也需要rpcbind,和nfs。

使用showmount -e 192.168.111.111来查看

使用mount -t nfs 192.168.111.111:/var/exportfs/share /opt/share

还可以是用 /etc/fstab里添加如下代码实现开机自动挂载

10.27.110.25:/var/exportfs/upload	/usr/local/upload	nfs	defaults	0 0
10.27.110.25:/var/exportfs/share		/opt/share		nfs	defaults	0 0

 

转载于:https://my.oschina.net/lenglingx/blog/875501

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值