场景:在centos7.4系统下安装saltstack,但安装完salt-master和salt-minion,执行salt命令等待时间都很长,如执行简单salt "*" test.ping命令都须要花费20s的时间。centos
如下来解决此问题:bash
1)关闭salt服务,开启salt的dubug模式进行问题定位:ide
[root@centos7 ~]# systemctl stop salt-master [root@centos7 ~]# salt-master -l debug
日志输出以下:this
从日志中会发现如下信息,其问题缘由是由于安装完系统默认开启ipv6和ipv4,hosts文件没有设置主机名:centos7
[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文件:spa
首先经过ifconfig命令会发现ipv6是开启的:debug
2) 关闭ipv6设置:3d
编辑/etc/sysctl.conf配置,添加net.ipv6.conf.all.disable_ipv6=1日志
编辑/etc/sysconfig/network配置,增长 NETWORKING_IPV6=no:blog
编辑网卡配置文件ifcfg-eno16777736,确保IPV6INIT=no:
执行sysctl -p或reboot命令,使配置生效:
[root@centos7 ~]# sysctl -p
在此经过ifconfig命令查看,会发现已经关闭ipv6:
设置hosts文件:
关闭salt的debug模式,重启salt-master服务:
[root@centos7 ~]# systemctl start salt-master
执行salt命令,会发现执行速度很快了。
注意:另外能够经过修改salt配置文件设置ipv6 监听