解决Centos7.4下由于系统开启ipv6导致salt执行命令太慢的问题
场景:在centos7.4系统下安装saltstack,但安装完salt-master和salt-minion,执行salt命令等待时间都很长,如执行简单salt "*" test.ping命令都需要花费20s的时间。
以下来解决此问题:
1)关闭salt服务,开启salt的dubug模式进行问题定位:
[[email protected] ~]# systemctl stop salt-master [[email protected] ~]# salt-master -l debug
日志输出如下:
从日志中会发现以下信息,其问题原因是因为安装完系统默认开启ipv6和ipv4,hosts文件没有设置主机名:
[WARNING ] Unable to find IPv4 record for "centos7" causing a 0:00:10.016759 second timeout when rendering grains. Set the dns or /etc/hosts for IPv6 to clear this. [WARNING ] Unable to find IPv6 record for "centos7" causing a 0:00:10.016759 second timeout when rendering grains. Set the dns or /etc/hosts for IPv6 to clear this.
粗暴一些关闭ipv6,并设置hosts文件:
首先通过ifconfig命令会发现ipv6是开启的:
2) 关闭ipv6设置:
编辑/etc/sysctl.conf配置,添加net.ipv6.conf.all.disable_ipv6=1
编辑/etc/sysconfig/network配置,增加 NETWORKING_IPV6=no:
编辑网卡配置文件ifcfg-eno16777736,确保IPV6INIT=no:
执行sysctl -p或reboot命令,使配置生效:
[[email protected] ~]# sysctl -p
在此通过ifconfig命令查看,会发现已经关闭ipv6:
设置hosts文件:
关闭salt的debug模式,重启salt-master服务:
[[email protected] ~]# systemctl start salt-master
执行salt命令,会发现执行速度很快了。
注意:另外可以通过修改salt配置文件设置ipv6 监听
转载于:https://blog.51cto.com/bovin/2166031