nfs的安装和配置,经常安装,做个比较复制快些。
1. yum 安装
yum install nfs-utils -yyum install rpcbind -yyum install mount.nfs -y
2. 选择好要nfs的目录
mkdir /var/exportfsmkdir /var/exportfs/uploadmkdir /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 dirmount -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 startservice nfs start
如果出现
Starting NFS mountd: rpc.mountd: svc_tli_create: could not open connection for udp6rpc.mountd: svc_tli_create: could not open connection for tcp6rpc.mountd: svc_tli_create: could not open connection for udp6rpc.mountd: svc_tli_create: could not open connection for tcp6rpc.mountd: svc_tli_create: could not open connection for udp6rpc.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 TCPrpc.nfsd: unable to set any sockets for nfsd
这是rpcbind没有启动,需要先启动rpcbind, service rpcbind start
6. 需要主要的地方:
service rpcbind startrpcbind需要比nfs先启动然后在service nfs start过程中需要确保nfs 和rpcbind 服务会开机启动。chkconfig rpcbind --listchkconfig nfs --listchkconfig rpcbind onchkconfig 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 010.27.110.25:/var/exportfs/share /opt/share nfs defaults 0 0