如何加快安赛?

时间:2015-05-13 10:43:20

标签: dns ansible

我们最近实施了ansible。不知何故,我们发现它真的很慢,并想知道如何加速。 所以,我做了一些支持,发现/etc/resolv.conf和/ etc / hosts相关,然后似乎是反向DNS问题如下:

18:32:13.961094 IP 192.168.22.2.44206 > 192.168.23.2.53: 12243+ PTR? xxx.xxx.29.115.in-addr.arpa. (45)
18:32:18.966199 IP 192.168.22.2.44206 > 192.168.23.2.53: 12243+ PTR? xxx.xxx.29.115.in-addr.arpa. (45)
18:32:18.967019 IP 192.168.23.2.53 > 192.168.22.2.44206: 12243 NXDomain* 0/0/0 (45)
18:32:18.967986 IP 192.168.22.2.44057 > 192.168.23.2.53: 19913+ PTR? xxx.xxx.29.115.in-addr.arpa. (45)
18:32:23.973096 IP 192.168.22.2.44057 > 192.168.23.2.53: 19913+ PTR? xxx.xxx.29.115.in-addr.arpa. (45)
18:32:23.976649 IP 192.168.23.2.53 > 192.168.22.2.44057: 19913 NXDomain* 0/0/0 (45)

18:32:23.977230 IP 192.168.22.2.44997 > 192.168.23.2.53: 8795+ PTR? xxx.xxx.29.115.in-addr.arpa. (45)
18:32:28.982280 IP 192.168.22.2.44997 > 192.168.23.2.53: 8795+ PTR? xxx.xxx.29.115.in-addr.arpa. (45)
18:32:28.982980 IP 192.168.23.2.53 > 192.168.22.2.44997: 8795 NXDomain* 0/0/0 (45)
18:32:28.983550 IP 192.168.22.2.38603 > 192.168.23.2.53: 41907+ PTR? xxx.xxx.29.115.in-addr.arpa. (45)
18:32:33.988665 IP 192.168.22.2.38603 > 192.168.23.2.53: 41907+ PTR? xxx.xxx.29.115.in-addr.arpa. (45)
18:32:33.989414 IP 192.168.23.2.53 > 192.168.22.2.38603: 41907 NXDomain* 0/0/0 (45)

如你所见,做PTR需要20s?每个节点查询。(实际节点IP由xxx.xxx替换)。 那么,为什么ansible必须进行反向DNS查询?我们可以简单地禁用它吗?怎么样?

顺便说一下,我们已经更改了默认值" ControlPersist = 30s"在ansible.cfg中更长,之后真的有很多帮助。但是,启动连接时反向DNS查询延迟也是绝对不可接受的。

2 个答案:

答案 0 :(得分:2)

感谢@leucos和@CalleDybedahl,这个问题最终导致了ssh gssapi身份验证方法。在附加" GSSAPIAuthentication = no"到ansible.cfg中的ssh_args,不再有PTR查询。 仅供参考,我们也在〜/ .ssh / config中进行,因为在我们的环境中没有实现GSSAPI身份验证。

答案 1 :(得分:0)

在尝试加快Ansible速度时,这是我的观察。

SSH尝试身份验证的顺序非常重要。通常在Ansible中,我们使用公共密钥身份验证。 因此,在/etc/ansible/ansible.cfg中添加 PreferredAuthentications 条目后,速度提高了近17倍。

  

ssh_args = -o ControlMaster = auto -o ControlPersist = 60m -o PreferredAuthentications = publickey

下面是结果。

[admin@SON-DOCM ~]$ time ansible -m ping 2405:200:xxx:xxxx::6:40
2405:200:xxx:xxxx::6:40 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

real    0m31.897s
user    0m1.307s
sys     0m0.248s
[admin@SON-DOCM ~]$ vi /etc/ansible/ansible.cfg
[admin@SON-DOCM ~]$ time ansible -m ping 2405:200:xxx:xxxx::6:40
2405:200:xxx:xxxx::6:40 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

real    0m1.882s
user    0m0.757s
sys     0m0.172s