nfs搭建和可能的问题

http://www.cnblogs.com/hackerer/p/5221556.html
挺不错的参考文档

NFS服务器搭建:
服务器IP: 10.135.152.241

yum install rpcbind nfs-utils

# cat /etc/exports
/nfs_data 10.104.71.154(rw,no_root_squash,no_all_squash,sync)
#/nfs_data 172.16.1.0/24(rw,sync,all_squash)

# mkdir /nfs_data
# chown -R nfsnobody.nfsnobody /nfs_data
说明: 该用户在安装nfs时就创建好了

# /etc/init.d/rpcbind start
# /etc/init.d/nfs start
# /etc/init.d/nfs status/reload/stop/restart

启动命令加到/etc/rc.local
/etc/init.d/rpcbind start
/etc/init.d/nfs start

启动nfs可能会遇到的问题:
# /etc/init.d/nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas: Cannot register service: RPC: Unable to receive; errno = Connection refused
rpc.rquotad: unable to register (RQUOTAPROG, RQUOTAVERS, udp).
                                                           [FAILED]
Starting NFS mountd:                                       [FAILED]
Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
rpc.nfsd: unable to set any sockets for nfsd
                                                           [FAILED]
原因:
RH系操作系统在6.0版本号之后没有portmap服务控制rpc的启动。因为NFS和nfslock的启动须要向rpc进行注冊,rpc不启动的话就会报错。

解决方法:启动rpcbind&rpcidmap rpcbind是6.0版本号后默认的RPC服务,所以要先于nfs启动。假设不启动rpcidmap则会造成用户权限的映射错误,用户的权限看起来是一串数字。

# /etc/init.d/rpcbind start
Starting rpcbind:                                          [  OK  ]
# /etc/init.d/rpcidmapd start
Starting RPC idmapd:                                       [  OK  ]
# /etc/init.d/nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]

# cat /var/lib/nfs/etab
/data001/data/sites/imgdsp.100msh.com 10.104.71.154(rw,sync,wdelay,hide,nocrossnfs_data,secure,no_root_squash,no_all_squash,no_subtree_check,secure_locks,acl,anonuid=65534,anongid=65534,sec=sys,rw,no_root_squash,no_all_squash)
/data001/data/sites/imgdsp.100msh.com 10.104.35.202(rw,sync,wdelay,hide,nocrossnfs_data,secure,no_root_squash,no_all_squash,no_subtree_check,secure_locks,acl,anonuid=65534,anongid=65534,sec=sys,rw,no_root_squash,no_all_squash)

10.135.152.241是NFS服务器地址
# showmount -e 10.135.152.241 <==挂载前首先检查有权限需要挂载的信息
Export list for 10.135.152.241:
/data 10.135.152.241/24 <---可以看到共享/data目录

本机做挂载测试
# mount -t nfs 10.135.152.241:/data /mnt  ##将/data共享目录挂载到本地的/mnt目录
# df -h
Filesystem          Size  Used Avail Use% Mounted on
/dev/sda3           7.1G  1.5G  5.3G  22% /
tmpfs               279M     0  279M   0% /dev/shm
/dev/sda1           190M   36M  145M  20% /boot
10.135.152.241:/data  7.1G  1.5G  5.3G  22% /mnt

挂载nfs
# yum -y install nfs-utils rpcbind 
# /etc/init.d/rpcbind start
Starting rpcbind:                                          [  OK  ]

mount -t nfs 10.135.152.241:/nfs_data /nfs_data

可能会遇到的问题:
mount: wrong fs type, bad option, bad superblock on 10.135.152.241:/data/img,
       missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)
       In some cases useful info is found in syslog - try
       dmesg | tail  or so
      
原因:
[[email protected] data]# ll /sbin/mount*
查看/sbin/mount.<type>文件,果然发现没有/sbin/mount.nfs的文件,安装nfs-utils即可

解决:
yum install nfs-utils

挂载成功后测试共享目录的读,写

mount挂载性能优化参数选项
(1)禁止更新目录及文件时间戳挂载
mount -t nfs -o noatime,nodiratime 10.135.152.241:/data

(2)安全加优化的挂载方式
mount -t nfs -o nosuid,noexec,nodev,noatime,nodiratime,intr,rsize=131072,wsize=131072 10.135.152.241:/nfs_data /mnt

(3)默认的挂载方式
mount -t nfs 10.135.152.241:/nfs_data /mnt

NFS内核优化
编辑/etc/sysctl.conf
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

# sysctl -p

其他问题:
【LINUX】在redhat6系统中 当NFS启动后 rpc.svcgssd 状态还是STOP

[[email protected] Packages]# cat /etc/redhat-release
    Red Hat Enterprise Linux Server release 6.7 (Santiago)
    [[email protected] Packages]# service rpcbind status
    rpcbind (pid 4744) is running...
    [[email protected] Packages]# service nfs status
    rpc.svcgssd is stopped    -- 问题所在
    rpc.mountd (pid 5733) is running...
    nfsd (pid 5749 5748 5747 5746 5745 5744 5743 5742) is running...
    rpc.rquotad (pid 5728) is running...

描述:如果NFS 配置为Kerberos 自动共享模式,该服务才会有用或者启动
原文如下:
This is an expected behaviour. rpc.svcgssd and rpc.gssd daemons only needs to be enabled if NFS is configured to to export shares via Kerberos authentication

NFS 默认是不配置Kerberos 共享 的
NFS service by default is not configured to export shares via Kerberos

Kerberos协议:(此处解释转载自http://www.jb51.net/article/94875.htm)

Kerberos协议主要用于计算机网络的身份鉴别(Authentication), 其特点是用户只需输入一次身份验证信息就可以凭借此验证获得的票据(ticket-granting ticket)访问多个服务,即SSO(Single Sign On)。由于在每个Client和Service之间建立了共享密钥,使得该协议具有相当的安全性。

在client上运行:
showmount -e cloud.squirrel.org
clnt_create: RPC: Port mapper failure - Unable to receive: errno 111 (Connection refused)

showmount -e 192.168.205.129
Export list for 192.168.205.129:
/export *

mount -t nfs cloud.squirrel.org:/export/primary /primarymount
mount.nfs: Connection timed out

mount -t nfs 192.168.205.129:/export/primary /primarymount
mount.nfs: access denied by server while mounting 192.168.205.129:/export/primary

到server去tail -200 /var/log/messages:
refused mount request from 192.168.205.1 for /export/primary (/export): illegal port 1024

已经快接近成功了,google了一下,说是server上nfs要加上一个insecure:
gedit /etc/exports
在原来的那一行上修改如下:
/export *(rw,async,insecure,no_root_squash)

然后:
exportfs -rv
service nfs restart

在client上重新
mount -t nfs 192.168.205.129:/export/primary /primarymount
没有提示,应该成功了,可以确认:
mount |grep primary
OK!

时间: 2024-12-29 10:37:40

nfs搭建和可能的问题的相关文章

Lvs+keepalived+httpd+NFS搭建高可用

Lvs+keepalived+httpd+NFS搭建高可用 自己捯饬的模型图 NAT模型图 注意事项:RealServer需要把网关指向Director,并且Director要打开转发功能命令如下: echo "1" > /proc/sys/net/ipv4/ip_foreward DR模型图 注意事项:需要在RealServer配置如下信息: echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore echo 1 > /proc

nfs搭建;nfs监控;mount对于nfs的相应配置

nfs搭建 https://www.cnblogs.com/lms0755/p/9211585.html https://www.jianshu.com/p/e47cccbb3ae5 https://help.aliyun.com/knowledge_detail/125389.html#task-1130493 https://www.cnblogs.com/yueminghai/p/6473758.html nfs监控 https://blog.csdn.net/daocaoren15431

LAMP+DNS+NFS搭建discuz论坛项目

一.项目目的 两台web服务器,共享关系型数据库,共享NFS服务器,利用DNS记录轮询提供负载均衡: 搭建论坛www.wuhf.com 二.项目设计 DNSServer,DBServer,NFSServer,WebServer1:WebServer2:搭建5个虚拟机 域名wuhf.com,通过本地DNS解析到内网两台web服务器,实现轮询负载均衡: 在两台web服务器上搭建discuz论坛: 使用MariaDB存放结构化数据 使用NFS服务器存放非结构化数据 三.项目计划 1.网络架构实现 主机

Linux下NFS搭建流程

一.NFS简介 NFS是Network File System的缩写,即网络文件系统.一种使用于分散式文件协定,有SUN公司开发.功能是通过网络让不同的机器.不同的操作系统能够分享个人数据,让应用程序通过网络可以访问位于服务器磁盘中的数据. NFS在文件传送或信息传送的过过程中,依赖于RPC协议.RPC,远程过程调用(Remote Procedure Call),是使客户端能够执行其他系统中程序的一种机制.NFS本身是没有提供信息传输的协议和功能的,但NFS却能让我们通过网络进行资料的分享,就是

NFS搭建

NFS(network file system),即网络文件系统:它用于在网络上共享存储. 这次试验准备两台虚拟机,一个作为服务端,一个为客户端.服务端共享一个目录,然后客户端挂载这个目录就可以实现共享存储了. 1.服务端配置NFS 首先需要安装两个包nfs-utils和rpcbind(用于服务端和客户端之间的通信,CentOS6版本以前都是安装portmap包,实际上是同一个东西) [[email protected] ~]# yum install -y nfs-utils rpcbind

linux centos 6.0 nfs搭建

在启动NFS  SERVER之前,首先要启动rpcbind服务(即老版本portmap服务,)否则NFS SERVER 就无法向RPC服务注册,另外,如果RPC服务重新启动,原来已注册好的NFS端口数据就会丢失,因此,此时RPC服务管理的NFS程序也需要重新启动以向PRC端口注册,特别提示:一般修改NFS配置文件后,是不需要重启NFS的.直接在命令行实行/etc/init.d/nfs reload 或exportfs -rv  即可使修改的/etc/exports生效. 2.NFS系统守护进程

heartbeat v2配置高可用web集群和基于nfs搭建MySQL高可用集群

安装环境:Centos 6.4, httpd2.4,mysql5.5,heartbeat v2 提供两台机器node1和node2,在/etc/hosts文件中添加名称解析,并且主机名称要与节点名称要相同,即uname -n的名称要和hosts定义的名称必须一样. #   IP                         HOSTNAME             ALIAS 10.204.80.79     node1.mylinux.com     node1 10.204.80.80  

Linux nfs 搭建

nfs    NetWork  File System   网络文件系统 以下是NFS最显而易见的好处: 1. 节省本地存储空间,将常用的数据存放在一台NFS服务器上且可以通过网络访问,那么本地终端将可以减少自身存储空间的使用. 2. 用户不需要在网络中的每个机器上都建有Home目录,Home目录可以放在NFS服务器上且可以在网络上被访问使用. 3. 一些存储设备如软驱.CDROM和Zip(一种高储存密度的磁盘驱动器与磁盘)等都可以在网络上被别的机器使用.这可以减少整个网络上可移动介质设备的数量

Centos6.5 + Oracle 11g r2 + nfs搭建RAC环境一

环境要求: 1.2台系统为Centos6.5的机器,其中 1台做nfs(硬盘大小至少4T) 2. 每台机器至少2块网卡 3. 准备5个可用的IP地址(一个为scan,二台配置各配置public和private地址) 4. 内存至少2G以下内存,建议使用4G或者更高 地址规划: 第一台主机:rac1  网卡eth0 IP地址:172.16.0.1/24  网卡eth1地址: 192.168.1.192/24 第一台主机:rac1  网卡eth0 IP地址:172.16.0.2/24  网卡eth1