mount.nfs:无法parsing服务器

我有一个nfs客户端无法parsing可parsing的DNS名称的问题。

[root@testserver-2 ~]# host nfs-server-host-name nfs-server-host-name has address 10.37.4.131 [root@testserver-2 ~]# nslookup nfs-server-host-name Server: 127.0.0.1 Address: 127.0.0.1#53 Name: nfs-server-host-name Address: 10.37.4.126 [root@testserver-2 ~]# showmount -e nfs-server-host-name clnt_create: RPC: Unknown host [root@testserver-2 ~]# ss -lnp |grep rpc LISTEN 0 128 *:111 *:* users:(("rpcbind",7627,8) [root@testserver-2 ~]# mount -t nfs -o defaults,auto,proto=tcp nfs-server-host-name:/ifs/exports/EXPORT /mnt/export mount.nfs: Failed to resolve server nfs-server-host-name: Name or service not known 

本地parsing通过dnsmasq设置:

 [root@testserver-2 ~]# cat /etc/resolv.conf options rotate timeout:2 attempts:4 nameserver 127.0.0.1 nameserver 10.1.1.1 nameserver 8.8.8.8 [root@testserver-2 ~]# cat /etc/dnsmasq.conf resolv-file=/etc/resolv.conf server=/nfs-server-host-name/10.37.4.1 #IP address of Isilon smart connect resolver listen-address=127.0.0.1 

nsswitchconfiguration(默认Centos 6):

 [root@testserver-2 ~]# grep hosts /etc/nsswitch.conf hosts: files dns 

请注意, nfs-server-host-nameparsing由Isilon智能连接parsing器处理,该parsing器通过dnsmasq在本地configuration为nfs-server-host-name的parsing器并工作(如上例所示)。 用IP地址replacenfs-server-host-name不是一个选项,因为有多个由parsing器平衡的NFS节点,因此IP是可变的,不能被硬编码。 因此,主机和nslookup的上述两个结果是不同的。 这是有意和预期的行为。

还请注意, nfs-server-host-namenfs-server-host-name的一个非常精确的例子。 实际的主机名看起来几乎相同,它不是FQDN。 事实上,主机名中根本没有点。 这是我无法控制的function。

使用一个有效的节点IP地址手动装载时,导出安装正常。 当一个节点的地址被放入/etc/hosts ,它将被挂载。 当通过DNS方式parsing时,它不适用于nfs客户端,但适用于其他networking工具,如主机,dig或ping。

这似乎不是一个不常见的问题,但是到目前为止我发现的所有提示都是“用IP代替主机名”,这是我不能做的事情。

我错过了什么?

showmount命令有一个RPC调用,它使用gethostbyname_r尝试获取主机名的信息。 解释由它返回的错误并没有多大的意义。 你可以运行一个testing,看看错误实际上是什么? 这个代码是从这里看到的实际的glibc clnt_gen.c代码中修改的

示例C源程序:

 #include <netdb.h> #include <alloca.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> int main(int argc, char **argv) { struct hostent hostbuf, *h; size_t hstbuflen; char *hsttmpbuf; char *hostname; int herr; if (argc != 2) { exit(-1); } hostname = argv[1]; hstbuflen = 1024; hsttmpbuf = alloca(hstbuflen); while (gethostbyname_r (hostname, &hostbuf, hsttmpbuf, hstbuflen, &h, &herr) != 0 || h == NULL) { if (herr != NETDB_INTERNAL || errno != ERANGE) { printf("gethostbyname_r error: %s\n", hstrerror(herr)); exit(0); } else { hstbuflen *= 2; hsttmpbuf = alloca (hstbuflen); } } } 

将其保存为ghbntest.c并使用gcc -o ghbntest ghbntest.c命令进行gcc -o ghbntest ghbntest.c 。 使用./ghbntest nfs-server-host-name 。 输出示例:

 $ ./ghbntest 12345.example.com gethostbyname_r error: Unknown host 

我还没有弄清楚真正的问题是什么,但是解决方法是从/etc/resolv.conf删除rotate选项, /etc/fstab nfs-server-host-name之后加一个点来防止域search即使在/etc/resolv.conf没有search选项),即:

 nfs-server-host-name.:/nfs/export/... ^ ^---up here 

它可能与内核构build选项CONFIG_NFS_USE_LEGACY_DNS有关,在我的内核上设置为yes

nfs-client(仅限于nfs-client)的行为是只要在/etc/resolv.conf查询第二个名称服务器,不pipe有多less个,只要存在rotate选项。 但是,当没有第二个名称服务器时,它确实工作。 打败我…