kubernetes内核参数优化

 建议设置

  1. net.ipv4.tcp_keepalive_time=600
  2. net.ipv4.tcp_keepalive_intvl=30
  3. net.ipv4.tcp_keepalive_probes=10
  4. net.ipv6.conf.all.disable_ipv6=1
  5. net.ipv6.conf.default.disable_ipv6=1
  6. net.ipv6.conf.lo.disable_ipv6=1
  7. net.ipv4.neigh.default.gc_stale_time=120
  8. net.ipv4.conf.all.rp_filter=0
  9. net.ipv4.conf.default.rp_filter=0
  10. net.ipv4.conf.default.arp_announce=2
  11. net.ipv4.conf.lo.arp_announce=2
  12. net.ipv4.conf.all.arp_announce=2
  13. net.ipv4.ip_local_port_range= 45001 65000
  14. net.ipv4.ip_forward=1
  15. net.ipv4.tcp_max_tw_buckets=6000
  16. net.ipv4.tcp_syncookies=1
  17. net.ipv4.tcp_synack_retries=2
  18. net.bridge.bridge-nf-call-ip6tables=1
  19. net.bridge.bridge-nf-call-iptables=1
  20. net.netfilter.nf_conntrack_max=2310720
  21. net.ipv6.neigh.default.gc_thresh1=8192
  22. net.ipv6.neigh.default.gc_thresh2=32768
  23. net.ipv6.neigh.default.gc_thresh3=65536
  24. net.core.netdev_max_backlog=16384
  25. net.core.rmem_max = 16777216
  26. net.core.wmem_max = 16777216
  27. net.ipv4.tcp_max_syn_backlog = 8096
  28. net.core.somaxconn = 32768
  29. fs.inotify.max_user_instances=8192
  30. fs.inotify.max_user_watches=524288
  31. fs.file-max=52706963
  32. fs.nr_open=52706963
  33. kernel.pid_max = 4194303
  34. net.bridge.bridge-nf-call-arptables=1
  35. vm.swappiness=0
  36. vm.overcommit_memory=1
  37. vm.panic_on_oom=0
  38. vm.max_map_count = 262144

 

 


内核参数解释

  1. net.ipv4.tcp_keepalive_time=600 #此参数表示TCP发送keepalive探测消息的间隔时间(秒)
  2. net.ipv4.tcp_keepalive_intvl=30 #tcp检查间隔时间(keepalive探测包的发送间隔)
  3. net.ipv4.tcp_keepalive_probes=10 #tcp检查次数(如果对方不予应答,探测包的发送次数)
  4. net.ipv6.conf.all.disable_ipv6=1 #禁用IPv6,修为0为启用IPv6
  5. net.ipv6.conf.default.disable_ipv6=1 #禁用IPv6,修为0为启用IPv6
  6. net.ipv6.conf.lo.disable_ipv6=1 #禁用IPv6,修为0为启用IPv6
  7. net.ipv4.neigh.default.gc_stale_time=120 #ARP缓存条目超时
  8. net.ipv4.conf.all.rp_filter=0 #默认为1,系统会严格校验数据包的反向路径,可能导致丢包
  9. net.ipv4.conf.default.rp_filter=0 #不开启源地址校验
  10. net.ipv4.conf.default.arp_announce=2 #始终使用与目的IP地址对应的最佳本地IP地址作为ARP请求的源IP地址
  11. net.ipv4.conf.lo.arp_announce=2 #始终使用与目的IP地址对应的最佳本地IP地址作为ARP请求的源IP地址
  12. net.ipv4.conf.all.arp_announce=2 #始终使用与目的IP地址对应的最佳本地IP地址作为ARP请求的源IP地址
  13. net.ipv4.ip_local_port_range= 45001 65000 # 定义网络连接可用作其源(本地)端口的最小和最大端口的限制,同时适用于TCP和UDP连接。
  14. net.ipv4.ip_forward=1 # 其值为0,说明禁止进行IP转发;如果是1,则说明IP转发功能已经打开。
  15. net.ipv4.tcp_max_tw_buckets=6000 #配置服务器 TIME_WAIT 数量
  16. net.ipv4.tcp_syncookies=1 #此参数应该设置为1,防止SYN Flood
  17. net.ipv4.tcp_synack_retries=2 #表示回应第二个握手包(SYN+ACK包)给客户端IP后,如果收不到第三次握手包(ACK包),进行重试的次数(默认为5)
  18. net.bridge.bridge-nf-call-ip6tables=1 # 是否在ip6tables链中过滤IPv6包
  19. net.bridge.bridge-nf-call-iptables=1 # 二层的网桥在转发包时也会被iptables的FORWARD规则所过滤,这样有时会出现L3层的iptables rules去过滤L2的帧的问题
  20. net.netfilter.nf_conntrack_max=2310720 #连接跟踪表的大小,建议根据内存计算该值CONNTRACK_MAX = RAMSIZE (in bytes) / 16384 / (x / 32),并满足nf_conntrack_max=4*nf_conntrack_buckets,默认262144
  21. net.ipv6.neigh.default.gc_thresh1=8192
  22. net.ipv6.neigh.default.gc_thresh2=32768
  23. net.ipv6.neigh.default.gc_thresh3=65536
  24. #gc_thresh3 是表大小的绝对限制
  25. #gc_thresh2 设置为等于系统的最大预期邻居条目数的值
  26. #在这种情况下,gc_thresh3 应该设置为一个比 gc_thresh2 值高的值,例如,比 gc_thresh2 高 25%-50%,将其视为浪涌容量。
  27. #gc_thresh1 提高到较大的值;此设置的作用是,如果表包含的条目少于 gc_thresh1,内核将永远不会删除(超时)过时的条目。
  28. net.core.netdev_max_backlog=16384 # 每CPU网络设备积压队列长度
  29. net.core.rmem_max = 16777216 # 所有协议类型读写的缓存区大小
  30. net.core.wmem_max = 16777216 # 最大的TCP数据发送窗口大小
  31. net.ipv4.tcp_max_syn_backlog = 8096 # 第一个积压队列长度
  32. net.core.somaxconn = 32768 # 第二个积压队列长度
  33. fs.inotify.max_user_instances=8192 # 表示每一个real user ID可创建的inotify instatnces的数量上限,默认128.
  34. fs.inotify.max_user_watches=524288 # 同一用户同时可以添加的watch数目,默认8192。
  35. fs.file-max=52706963 # 文件描述符的最大值
  36. fs.nr_open=52706963 #设置最大微博号打开数
  37. kernel.pid_max = 4194303 #最大进程数
  38. net.bridge.bridge-nf-call-arptables=1 #是否在arptables的FORWARD中过滤网桥的ARP包
  39. vm.swappiness=0 # 禁止使用 swap 空间,只有当系统 OOM 时才允许使用它
  40. vm.overcommit_memory=1 # 不检查物理内存是否够用
  41. vm.panic_on_oom=0 # 开启 OOM
  42. vm.max_map_count = 262144
posted @ 2023-07-07 16:19  纯捡垃圾吃的  阅读(104)  评论(0编辑  收藏  举报
返回顶部