1. 内核调优

  1. echo "
  2. net.bridge.bridge-nf-call-ip6tables=1
  3. net.bridge.bridge-nf-call-iptables=1
  4. net.ipv4.ip_forward=1
  5. net.ipv4.conf.all.forwarding=1
  6. net.ipv4.neigh.default.gc_thresh1=4096
  7. net.ipv4.neigh.default.gc_thresh2=6144
  8. net.ipv4.neigh.default.gc_thresh3=8192
  9. net.ipv4.neigh.default.gc_interval=60
  10. net.ipv4.neigh.default.gc_stale_time=120
  11. # 参考 https://github.com/prometheus/node_exporter#disabled-by-default
  12. kernel.perf_event_paranoid=-1
  13. #sysctls for k8s node config
  14. net.ipv4.tcp_slow_start_after_idle=0
  15. net.core.rmem_max=16777216
  16. fs.inotify.max_user_watches=524288
  17. kernel.softlockup_all_cpu_backtrace=1
  18. kernel.softlockup_panic=0
  19. kernel.watchdog_thresh=30
  20. fs.file-max=2097152
  21. fs.inotify.max_user_instances=8192
  22. fs.inotify.max_queued_events=16384
  23. vm.max_map_count=262144
  24. fs.may_detach_mounts=1
  25. net.core.netdev_max_backlog=16384
  26. net.ipv4.tcp_wmem=4096 12582912 16777216
  27. net.core.wmem_max=16777216
  28. net.core.somaxconn=32768
  29. net.ipv4.ip_forward=1
  30. net.ipv4.tcp_max_syn_backlog=8096
  31. net.ipv4.tcp_rmem=4096 12582912 16777216
  32. net.ipv6.conf.all.disable_ipv6=1
  33. net.ipv6.conf.default.disable_ipv6=1
  34. net.ipv6.conf.lo.disable_ipv6=1
  35. kernel.yama.ptrace_scope=0
  36. vm.swappiness=0
  37. # 可以控制core文件的文件名中是否添加pid作为扩展。
  38. kernel.core_uses_pid=1
  39. # Do not accept source routing
  40. net.ipv4.conf.default.accept_source_route=0
  41. net.ipv4.conf.all.accept_source_route=0
  42. # Promote secondary addresses when the primary address is removed
  43. net.ipv4.conf.default.promote_secondaries=1
  44. net.ipv4.conf.all.promote_secondaries=1
  45. # Enable hard and soft link protection
  46. fs.protected_hardlinks=1
  47. fs.protected_symlinks=1
  48. # 源路由验证
  49. # see details in https://help.aliyun.com/knowledge_detail/39428.html
  50. net.ipv4.conf.all.rp_filter=0
  51. net.ipv4.conf.default.rp_filter=0
  52. net.ipv4.conf.default.arp_announce = 2
  53. net.ipv4.conf.lo.arp_announce=2
  54. net.ipv4.conf.all.arp_announce=2
  55. # see details in https://help.aliyun.com/knowledge_detail/41334.html
  56. net.ipv4.tcp_max_tw_buckets=5000
  57. net.ipv4.tcp_syncookies=1
  58. net.ipv4.tcp_fin_timeout=30
  59. net.ipv4.tcp_synack_retries=2
  60. kernel.sysrq=1
  61. " >> /etc/sysctl.conf

接着执行sysctl -p

2. nofile

  1. cat >> /etc/security/limits.conf <<EOF
  2. * soft nofile 65535
  3. * hard nofile 65536
  4. EOF