系统开启ipv6导致salt执行命令太慢的问题

Posted 抛物线.

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了系统开启ipv6导致salt执行命令太慢的问题相关的知识,希望对你有一定的参考价值。

在centos7.4系统下安装saltstack,但安装完salt-master和salt-minion,执行salt命令等待时间都很长,如执行简单salt “*” test.ping命令都需要花费20s的时间。

以下来解决此问题:

  • 1)关闭salt服务,开启salt的dubug模式进行问题定位:
[root@master master.d]# systemctl stop salt-master
[root@master master.d]# salt-master -l debug   


WARNING ] Unable to find IPv6 record for "master" causing a 0:00:20.023294 second timeout when rendering grains. Set the dns or /etc/hosts for IPv6 to clear this.
[WARNING ] Unable to find IPv6 record for "master" causing a 0:00:20.024155 second timeout when rendering grains. Set the dns or /etc/hosts for IPv6 to clear this.
[WARNING ] Unable to find IPv6 record for "master" causing a 0:00:20.022684 second timeout when rendering grains. Set the dns or /etc/hosts for IPv6 to clear this.
[WARNING ] Unable to find IPv6 record for "master" causing a 0:00:20.027110 second timeout when rendering grains. Set the dns or /etc/hosts for IPv6 to clear this.
[WARNING ] Unable to find IPv6 record for "master" causing a 0:00:20.021819 second timeout when rendering grains. Set the dns or /etc/hosts for IPv6 to clear this.

从日志中会发现以下信息,其问题原因是因为安装完系统默认开启ipv6和ipv4,

粗暴一些关闭ipv6:

  • 首先通过ip a命令会发现ipv6是开启的:
[root@master ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:10:97:0f brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.12/24 brd 192.168.10.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe10:970f/64 scope link 
       valid_lft forever preferred_lft forever
[root@master ~]# 

1,编辑/etc/sysctl.conf配置,添加net.ipv6.conf.all.disable_ipv6=1

[root@master ~]# vi /etc/sysctl.conf 
# System default settings live in /usr/lib/sysctl.d/00-system.conf.
# To override those settings, enter new settings here, or in an /etc/sysctl.d/<name>.conf file
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
net.ipv6.conf.all.disable_ipv6=1

2,编辑/etc/sysconfig/network配置,增加 NETWORKING_IPV6=no:

[root@master ~]# vi /etc/sysconfig/network
# Created by anaconda
NETWORKING_IPV6=no

3,编辑网卡配置文件ifcfg-enp0s3,确保IPV6INIT=no:

[root@master ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=734b1b3c-2aff-4ebc-904c-8f7cb554bb99
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.10.12
NETMASK=255.255.255.0
GATEWAY=192.168.10.1
  • 执行sysctl -p或reboot命令,使配置生效:
[root@master ~]# sysctl -p
net.ipv6.conf.all.disable_ipv6 = 1
[root@master ~]# 
  • 在此通过ifconfig命令查看,会发现已经关闭ipv6:
[root@master ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:10:97:0f brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.12/24 brd 192.168.10.255 scope global dynamic enp0s3
       valid_lft 1145sec preferred_lft 1145sec
[root@master ~]# 

以上是关于系统开启ipv6导致salt执行命令太慢的问题的主要内容,如果未能解决你的问题,请参考以下文章

求教kswapd进程占用cpu导致系统慢的问题

OpenStack Cinder删除卷太慢的解决方法

如何解决浏览器中图片加载太慢的情况?

解决MAVEN项目因achetype加载太慢的问题

linux配置禁用启用IPv6

github clone速度太慢导致failed的解决方案