1. 程式人生 > >民間最全的Linux系統內核參數調優說明

民間最全的Linux系統內核參數調優說明

空閑 服務器端 ext nco rbm mint uuid num broadcast

  相信做運維的同仁,進行運維環境初建時,必須要考慮到操作系統內核參數的優化問題,本人經歷數次的運維環境重建後,決定要自行收集一份比較完善的系統內核參數優化說明文件出來,於是就有了下文,本文當前值是官方默認參數,建議參數直接添加於sysctl -a輸出的結果每一行的後面,希望對運維的同仁做系統內核參數調優時有所幫助。廢話不多講,直接上幹貨!

#3.10.0-862.el7.x86_64
#CentOS Linux release 7.5.1804

abi.vsyscall32 = 1
crypto.fips_enabled = 0
debug.exception-trace = 1
debug.kprobes-optimization = 1
debug.panic_on_rcu_stall = 0
dev.cdrom.autoclose = 1
dev.cdrom.autoeject = 0
dev.cdrom.check_media = 0
dev.cdrom.debug = 0
dev.cdrom.info = CD-ROM information, Id: cdrom.c 3.20 2003/12/17
dev.cdrom.info =
dev.cdrom.info = drive name: sr0
dev.cdrom.info = drive speed: 1
dev.cdrom.info = drive # of slots: 1
dev.cdrom.info = Can close tray: 1
dev.cdrom.info = Can open tray: 1
dev.cdrom.info = Can lock tray: 1
dev.cdrom.info = Can change speed: 1
dev.cdrom.info = Can select disk: 0
dev.cdrom.info = Can read multisession: 1
dev.cdrom.info = Can read MCN: 1
dev.cdrom.info = Reports media changed: 1
dev.cdrom.info = Can play audio: 1
dev.cdrom.info = Can write CD-R: 1
dev.cdrom.info = Can write CD-RW: 1
dev.cdrom.info = Can read DVD: 1
dev.cdrom.info = Can write DVD-R: 1
dev.cdrom.info = Can write DVD-RAM: 1
dev.cdrom.info = Can read MRW: 1
dev.cdrom.info = Can write MRW: 1
dev.cdrom.info = Can write RAM: 1
dev.cdrom.info =
dev.cdrom.info =
dev.cdrom.lock = 1
dev.hpet.max-user-freq = 64
dev.mac_hid.mouse_button2_keycode = 97
dev.mac_hid.mouse_button3_keycode = 100
dev.mac_hid.mouse_button_emulation = 0
dev.parport.default.spintime = 500
dev.parport.default.timeslice = 200
dev.raid.speed_limit_max = 200000 #RAID最大讀取速率,如果RAID性能較高,可以修改此上限來提升IO性能
dev.raid.speed_limit_min = 1000 #RAID最小讀取速率
dev.scsi.logging_level = 0 #是否開啟scsi磁盤的日誌功能,一般情況不建議開啟
fs.aio-max-nr = 65536
fs.aio-nr = 0
fs.binfmt_misc.status = enabled
fs.dentry-state = 23528 10917 45 0 0 0
fs.dir-notify-enable = 1
fs.epoll.max_user_watches = 411340
fs.file-max = 197872
fs.file-nr = 1120 0 197872
fs.inode-nr = 20574 298
fs.inode-state = 20574 298 0 0 0 0 0
fs.inotify.max_queued_events = 16384
fs.inotify.max_user_instances = 128
fs.inotify.max_user_watches = 8192
fs.lease-break-time = 45
fs.leases-enable = 1
fs.may_detach_mounts = 0
fs.mount-max = 100000
fs.mqueue.msg_default = 10
fs.mqueue.msg_max = 10
fs.mqueue.msgsize_default = 8192
fs.mqueue.msgsize_max = 8192
fs.mqueue.queues_max = 256
fs.nr_open = 1048576
fs.overflowgid = 65534
fs.overflowuid = 65534
fs.pipe-max-size = 1048576
fs.pipe-user-pages-hard = 0
fs.pipe-user-pages-soft = 16384
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
fs.quota.allocated_dquots = 0
fs.quota.cache_hits = 0
fs.quota.drops = 0
fs.quota.free_dquots = 0
fs.quota.lookups = 0
fs.quota.reads = 0
fs.quota.syncs = 0
fs.quota.warnings = 1
fs.quota.writes = 0
fs.suid_dumpable = 0
kernel.acct = 4 2 30
kernel.acpi_video_flags = 0
kernel.auto_msgmni = 1
kernel.bootloader_type = 114
kernel.bootloader_version = 2
kernel.cad_pid = 1
kernel.cap_last_cap = 36
kernel.compat-log = 1
kernel.core_pattern = core
kernel.core_pipe_limit = 0
kernel.core_uses_pid = 1
kernel.ctrl-alt-del = 0
kernel.dmesg_restrict = 0
kernel.domainname = (none)
kernel.ftrace_dump_on_oops = 0
kernel.ftrace_enabled = 1
kernel.hardlockup_all_cpu_backtrace = 0
kernel.hardlockup_panic = 1
kernel.hostname = example_server.com #由此可以看出,主機名是屬於內核的
kernel.hotplug =
kernel.hung_task_check_count = 4194304
kernel.hung_task_panic = 0
kernel.hung_task_timeout_secs = 120
kernel.hung_task_warnings = 10
kernel.io_delay_type = 0
kernel.kexec_load_disabled = 0
kernel.keys.gc_delay = 300
kernel.keys.maxbytes = 20000
kernel.keys.maxkeys = 200
kernel.keys.persistent_keyring_expiry = 259200
kernel.keys.root_maxbytes = 25000000
kernel.keys.root_maxkeys = 1000000
kernel.kptr_restrict = 0
kernel.max_lock_depth = 1024
kernel.modprobe = /sbin/modprobe
kernel.modules_disabled = 0
kernel.msg_next_id = -1
kernel.msgmax = 8192
kernel.msgmnb = 16384
kernel.msgmni = 3958
kernel.ngroups_max = 65536
kernel.nmi_watchdog = 1
kernel.ns_last_pid = 1651
kernel.numa_balancing = 0
kernel.numa_balancing_scan_delay_ms = 1000
kernel.numa_balancing_scan_period_max_ms = 60000
kernel.numa_balancing_scan_period_min_ms = 1000
kernel.numa_balancing_scan_size_mb = 256
kernel.numa_balancing_settle_count = 4
kernel.osrelease = 3.10.0-862.el7.x86_64
kernel.ostype = Linux
kernel.overflowgid = 65534
kernel.overflowuid = 65534
kernel.panic = 0
kernel.panic_on_io_nmi = 0
kernel.panic_on_oops = 1
kernel.panic_on_stackoverflow = 0
kernel.panic_on_unrecovered_nmi = 0
kernel.panic_on_warn = 0
kernel.perf_cpu_time_max_percent = 25
kernel.perf_event_max_sample_rate = 100000
kernel.perf_event_mlock_kb = 516
kernel.perf_event_paranoid = 2
kernel.pid_max = 131072
kernel.poweroff_cmd = /sbin/poweroff
kernel.print-fatal-signals = 0
kernel.printk = 4 4 1 7
kernel.printk_delay = 0
kernel.printk_ratelimit = 5
kernel.printk_ratelimit_burst = 10
kernel.pty.max = 4096
kernel.pty.nr = 1
kernel.pty.reserve = 1024
kernel.random.boot_id = b91ea354-c5d0-4c48-abcd-18da3dcd6741
kernel.random.entropy_avail = 978
kernel.random.poolsize = 4096
kernel.random.read_wakeup_threshold = 64
kernel.random.urandom_min_reseed_secs = 60
kernel.random.uuid = 923d2748-02d8-47b8-968d-9c2b7c420bec
kernel.random.write_wakeup_threshold = 896
kernel.randomize_va_space = 2
kernel.real-root-dev = 0
kernel.sched_autogroup_enabled = 0
kernel.sched_cfs_bandwidth_slice_us = 5000
kernel.sched_child_runs_first = 0
kernel.sched_domain.cpu0.domain0.busy_factor = 32
kernel.sched_domain.cpu0.domain0.busy_idx = 2
kernel.sched_domain.cpu0.domain0.cache_nice_tries = 1
kernel.sched_domain.cpu0.domain0.flags = 559
kernel.sched_domain.cpu0.domain0.forkexec_idx = 0
kernel.sched_domain.cpu0.domain0.idle_idx = 0
kernel.sched_domain.cpu0.domain0.imbalance_pct = 117
kernel.sched_domain.cpu0.domain0.max_interval = 4
kernel.sched_domain.cpu0.domain0.max_newidle_lb_cost = 17063
kernel.sched_domain.cpu0.domain0.min_interval = 2
kernel.sched_domain.cpu0.domain0.name = MC
kernel.sched_domain.cpu0.domain0.newidle_idx = 0
kernel.sched_domain.cpu0.domain0.wake_idx = 0
kernel.sched_domain.cpu1.domain0.busy_factor = 32
kernel.sched_domain.cpu1.domain0.busy_idx = 2
kernel.sched_domain.cpu1.domain0.cache_nice_tries = 1
kernel.sched_domain.cpu1.domain0.flags = 559
kernel.sched_domain.cpu1.domain0.forkexec_idx = 0
kernel.sched_domain.cpu1.domain0.idle_idx = 0
kernel.sched_domain.cpu1.domain0.imbalance_pct = 117
kernel.sched_domain.cpu1.domain0.max_interval = 4
kernel.sched_domain.cpu1.domain0.max_newidle_lb_cost = 1898
kernel.sched_domain.cpu1.domain0.min_interval = 2
kernel.sched_domain.cpu1.domain0.name = MC
kernel.sched_domain.cpu1.domain0.newidle_idx = 0
kernel.sched_domain.cpu1.domain0.wake_idx = 0
kernel.sched_latency_ns = 12000000
kernel.sched_migration_cost_ns = 500000
kernel.sched_min_granularity_ns = 10000000
kernel.sched_nr_migrate = 32
kernel.sched_rr_timeslice_ms = 100
kernel.sched_rt_period_us = 1000000
kernel.sched_rt_runtime_us = 950000
kernel.sched_schedstats = 0
kernel.sched_shares_window_ns = 10000000
kernel.sched_time_avg_ms = 1000
kernel.sched_tunable_scaling = 1
kernel.sched_wakeup_granularity_ns = 15000000
kernel.sem = 250 32000 32 128
kernel.sem_next_id = -1
kernel.shm_next_id = -1
kernel.shm_rmid_forced = 0
kernel.shmall = 18446744073692774399
kernel.shmmax = 18446744073692774399
kernel.shmmni = 4096
kernel.softlockup_all_cpu_backtrace = 0
kernel.softlockup_panic = 0
kernel.stack_tracer_enabled = 0
kernel.sysctl_writes_strict = 1
kernel.sysrq = 16
kernel.tainted = 0
kernel.threads-max = 15691
kernel.timer_migration = 1
kernel.traceoff_on_warning = 0
kernel.unknown_nmi_panic = 0
kernel.usermodehelper.bset = 4294967295 31
kernel.usermodehelper.inheritable = 4294967295 31
kernel.version = #1 SMP Fri Apr 20 16:44:24 UTC 2018
kernel.watchdog = 1
kernel.watchdog_cpumask = 0-127
kernel.watchdog_thresh = 10
kernel.yama.ptrace_scope = 0
net.core.bpf_jit_enable = 0
net.core.busy_poll = 0
net.core.busy_read = 0
net.core.default_qdisc = pfifo_fast
net.core.dev_weight = 64
net.core.dev_weight_rx_bias = 1
net.core.dev_weight_tx_bias = 1
net.core.message_burst = 10
net.core.message_cost = 5
net.core.netdev_budget = 300
net.core.netdev_max_backlog = 1000 #網絡設備監聽隊列的最大長度(此值決定了全局並發能力,但不可大過65535,建議值10000)
net.core.netdev_rss_key = 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
net.core.netdev_tstamp_prequeue = 1 #網絡設備預置隊列序號,意味著從指定值開始順延序列化
net.core.optmem_max = 20480 #每個套接字所允許的最大緩沖區的大小
net.core.rmem_default = 212992 #網絡協議棧默認接收內存
net.core.rmem_max = 212992 #網絡協議棧最大接收內存
net.core.rps_sock_flow_entries = 0
net.core.somaxconn = 128 #定義了系統中每一個端口最大的監聽隊列長度,這是個全局的參數 建議值1280
net.core.warnings = 1
net.core.wmem_default = 212992 #網絡協議棧默認發送內存
net.core.wmem_max = 212992 #網絡協議棧最大發送內存
net.core.xfrm_acq_expires = 30
net.core.xfrm_aevent_etime = 10
net.core.xfrm_aevent_rseqth = 2
net.core.xfrm_larval_drop = 1
net.ipv4.cipso_cache_bucket_size = 10
net.ipv4.cipso_cache_enable = 1
net.ipv4.cipso_rbm_optfmt = 0
net.ipv4.cipso_rbm_strictvalid = 1
net.ipv4.conf.all.accept_local = 0 #是否允許所有接口接收從本機IP地址上發送給本機的數據包
net.ipv4.conf.all.accept_redirects = 1 #是否接收重寫過的數據包(用作路由器時默認值為0)
net.ipv4.conf.all.accept_source_route = 0 #是否接收無源路由的數據包
net.ipv4.conf.all.arp_accept = 0 #默認對不在ARP表中的IP地址發出的APR包的處理方式:0不在ARP表中創建對應IP地址的表項;1在ARP表中創建對應IP地址的表項
net.ipv4.conf.all.arp_announce = 0 #對網絡接口上,本地IP地址的發出的,ARP回應,作出相應級別的限制: 確定不同程度的限制,宣布對來自本地源IP地址發出Arp請求的接口
#0: 在任意網絡接口(eth0,eth1,lo)上的任何本地地址
#1:盡量避免不在該網絡接口子網段的本地地址做出arp回應. 當發起ARP請求的源IP地址是被設置應該經由路由達到此網絡接口的時候很有用.此時會檢查來訪IP是否為所有接口上的子網段內ip之一.如果改來訪IP不屬於各個網絡接口上的子網段內,那麽將采用級別2的方式來進行處理.
#2:對查詢目標使用最適當的本地地址.在此模式下將忽略這個IP數據包的源地址並嘗試選擇與能與該地址通信的本地地址.首要是選擇所有的網絡接口的子網中外出訪問子網中包含該目標IP地址的本地地址. 如果沒有合適的地址被發現,將選擇當前的發送網絡接口或其他的有可能接受到該ARP回應的網絡接口來進行發送.
net.ipv4.conf.all.arp_filter = 0 # 0:內核設置每個網絡接口各自應答其地址上的arp詢問。這項看似會錯誤的設置卻經常能非常有效,因為它增加了成功通訊的機會。在Linux主機上,每個IP地址是網絡接口獨立的,而非一個復合的接口。只有在一些特殊的設置的時候,比如負載均衡的時候會帶來麻煩
#1:允許多個網絡介質位於同一子網段內,每個網絡界面依據是否內核指派路由該數據包經過此接口來確認是否回答ARP查詢(這個實現是由來源地址確定路由的時候決定的),換句話說,允許控制使用某一塊網卡(通常是第一塊)回應arp詢問
net.ipv4.conf.all.arp_ignore = 0 #定義對目標地址為本地IP的ARP詢問不同的應答模式(LVS負載均衡時此值需要修改為2)
#0:回應任何網絡接口上對任何本地IP地址的arp查詢請求
#1:只回答目標IP地址是來訪網絡接口本地地址的ARP查詢請求
#2:只回答目標IP地址是來訪網絡接口本地地址的ARP查詢請求,且來訪IP必須在該網絡接口的子網段內
#3:不回應該網絡界面的arp請求,而只對設置的唯一和連接地址做出回應
#8:不回應所有(本地地址)的arp查詢
net.ipv4.conf.all.arp_notify = 0 #是否開啟arp通知鏈操作:0不做任何操作,1當設備或硬件地址改變時自動產生一個arp請求
net.ipv4.conf.all.bootp_relay = 0 #是否接收源地址為0.a.b.c,目的地址不是本機的數據包,是為了支持bootp服務
net.ipv4.conf.all.disable_policy = 0 #是否禁止internet協議安全性驗證
net.ipv4.conf.all.disable_xfrm = 0 #是否禁止internet協議安全性加密
net.ipv4.conf.all.force_igmp_version = 0
net.ipv4.conf.all.forwarding = 0
net.ipv4.conf.all.log_martians = 0 #是否開啟並記錄欺騙,源路由和重定向數據包:記錄帶有不允許的地址的數據報到內核日誌中(如果是路由器建議值為1)
net.ipv4.conf.all.mc_forwarding = 0 #是否進行多播路由(只有內核編譯有CONFIG_MROUTE並且有路由服務程序在運行該參數才有效)
net.ipv4.conf.all.medium_id = 0 #用來區分不同媒介.兩個網絡設備可以使用不同的值,使他們只有其中之一接收到廣播包.通常,這個參數被用來配合proxy_arp實現roxy_arp的特性即是允許arp報文在兩個不同的網絡介質中轉發.
#0:表示各個網絡介質接受他們自己介質上的媒介
#-1:表示該媒介未知
net.ipv4.conf.all.promote_secondaries = 1 #主備IP地址切換控制機制(建議值1)0當接口的主IP地址被移除時,刪除所有次IP地址;1當接口的主IP地址被移除時,將次IP地址提升為主IP地址
net.ipv4.conf.all.proxy_arp = 0 #是否啟用arp代理功能
net.ipv4.conf.all.proxy_arp_pvlan = 0 #回應代理ARP的數據包從接收到此代理ARP請求的網絡接口出去
net.ipv4.conf.all.route_localnet = 0 #是否允許外部訪問localhost
net.ipv4.conf.all.rp_filter = 1 #是否開啟反向路徑過濾
net.ipv4.conf.all.secure_redirects = 1 #是否支持安全重定向數據包
net.ipv4.conf.all.send_redirects = 1 #是否發送重定向數據包
net.ipv4.conf.all.shared_media = 1 #發送或接收RFC1620 共享媒體重定向 會覆蓋ip_secure_redirects的值
net.ipv4.conf.all.src_valid_mark = 0 #是否為所有接口上源地址有效的數據包打標記
net.ipv4.conf.all.tag = 0
net.ipv4.conf.default.accept_local = 0 #默認是否允許接收從本機IP地址上發送給本機的數據包
net.ipv4.conf.default.accept_redirects = 1 #默認是否接收重寫過的數據包(建議值1)
net.ipv4.conf.default.accept_source_route = 0 #默認是否接收無源路由的數據包
net.ipv4.conf.default.arp_accept = 0
net.ipv4.conf.default.arp_announce = 0
net.ipv4.conf.default.arp_filter = 0
net.ipv4.conf.default.arp_ignore = 0 #LVS負載均衡需要修改此值為1
net.ipv4.conf.default.arp_notify = 0
net.ipv4.conf.default.bootp_relay = 0
net.ipv4.conf.default.disable_policy = 0
net.ipv4.conf.default.disable_xfrm = 0
net.ipv4.conf.default.force_igmp_version = 0
net.ipv4.conf.default.forwarding = 0
net.ipv4.conf.default.log_martians = 0 #默認是否開啟並記錄欺騙,源路由和重定向數據包(如果是路由器建議值為1)
net.ipv4.conf.default.mc_forwarding = 0
net.ipv4.conf.default.medium_id = 0
net.ipv4.conf.default.promote_secondaries = 1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.default.proxy_arp_pvlan = 0
net.ipv4.conf.default.route_localnet = 0
net.ipv4.conf.default.rp_filter = 1 #默認是否開啟反向路徑過濾
net.ipv4.conf.default.secure_redirects = 1 #默認是否支持安全重定向數據包
net.ipv4.conf.default.send_redirects = 1 #默認是否發送重定向數據包
net.ipv4.conf.default.shared_media = 1
net.ipv4.conf.default.src_valid_mark = 0 #默認是否為源地址有效的數據包打標記
net.ipv4.conf.default.tag = 0
net.ipv4.conf.eth0.accept_local = 0
net.ipv4.conf.eth0.accept_redirects = 1
net.ipv4.conf.eth0.accept_source_route = 0
net.ipv4.conf.eth0.arp_accept = 0
net.ipv4.conf.eth0.arp_announce = 0
net.ipv4.conf.eth0.arp_filter = 0
net.ipv4.conf.eth0.arp_ignore = 0
net.ipv4.conf.eth0.arp_notify = 0
net.ipv4.conf.eth0.bootp_relay = 0
net.ipv4.conf.eth0.disable_policy = 0
net.ipv4.conf.eth0.disable_xfrm = 0
net.ipv4.conf.eth0.force_igmp_version = 0
net.ipv4.conf.eth0.forwarding = 0
net.ipv4.conf.eth0.log_martians = 0
net.ipv4.conf.eth0.mc_forwarding = 0
net.ipv4.conf.eth0.medium_id = 0
net.ipv4.conf.eth0.promote_secondaries = 1
net.ipv4.conf.eth0.proxy_arp = 0
net.ipv4.conf.eth0.proxy_arp_pvlan = 0
net.ipv4.conf.eth0.route_localnet = 0
net.ipv4.conf.eth0.rp_filter = 1
net.ipv4.conf.eth0.secure_redirects = 1
net.ipv4.conf.eth0.send_redirects = 1
net.ipv4.conf.eth0.shared_media = 1
net.ipv4.conf.eth0.src_valid_mark = 0
net.ipv4.conf.eth0.tag = 0
net.ipv4.conf.lo.accept_local = 0
net.ipv4.conf.lo.accept_redirects = 1
net.ipv4.conf.lo.accept_source_route = 1
net.ipv4.conf.lo.arp_accept = 0
net.ipv4.conf.lo.arp_announce = 0
net.ipv4.conf.lo.arp_filter = 0
net.ipv4.conf.lo.arp_ignore = 0
net.ipv4.conf.lo.arp_notify = 0
net.ipv4.conf.lo.bootp_relay = 0
net.ipv4.conf.lo.disable_policy = 1
net.ipv4.conf.lo.disable_xfrm = 1
net.ipv4.conf.lo.force_igmp_version = 0
net.ipv4.conf.lo.forwarding = 0
net.ipv4.conf.lo.log_martians = 0
net.ipv4.conf.lo.mc_forwarding = 0
net.ipv4.conf.lo.medium_id = 0
net.ipv4.conf.lo.promote_secondaries = 0
net.ipv4.conf.lo.proxy_arp = 0
net.ipv4.conf.lo.proxy_arp_pvlan = 0
net.ipv4.conf.lo.route_localnet = 0
net.ipv4.conf.lo.rp_filter = 0
net.ipv4.conf.lo.secure_redirects = 1
net.ipv4.conf.lo.send_redirects = 1
net.ipv4.conf.lo.shared_media = 1
net.ipv4.conf.lo.src_valid_mark = 0
net.ipv4.conf.lo.tag = 0
net.ipv4.fwmark_reflect = 0
net.ipv4.icmp_echo_ignore_all = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_errors_use_inbound_ifaddr = 0
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.icmp_msgs_burst = 50
net.ipv4.icmp_msgs_per_sec = 1000
net.ipv4.icmp_ratelimit = 1000
net.ipv4.icmp_ratemask = 6168
net.ipv4.igmp_max_memberships = 20
net.ipv4.igmp_max_msf = 10
net.ipv4.igmp_qrv = 2
net.ipv4.inet_peer_maxttl = 600
net.ipv4.inet_peer_minttl = 120
net.ipv4.inet_peer_threshold = 65664
net.ipv4.ip_default_ttl = 64 #定義數據報的生存周期:最多經過多少路由器後數據將被丟棄
net.ipv4.ip_dynaddr = 0
net.ipv4.ip_early_demux = 1
net.ipv4.ip_forward = 0 #是否啟用IP轉發(如果做路由需要開啟此項)
net.ipv4.ip_forward_use_pmtu = 0 #是否支持巨型幀轉發(使用LVS做負載均衡器時建議此值為1)
net.ipv4.ip_local_port_range = 32768 60999 #服務器端可用端口範圍(建議值 1024 65535)
net.ipv4.ip_local_reserved_ports = #系統預留端口列表:可以防止並發時占用服務端口
net.ipv4.ip_no_pmtu_disc = 0 #是否關閉路徑MTU探測功能
net.ipv4.ip_nonlocal_bind = 0
net.ipv4.ipfrag_high_thresh = 4194304
net.ipv4.ipfrag_low_thresh = 3145728
net.ipv4.ipfrag_max_dist = 64
net.ipv4.ipfrag_secret_interval = 600
net.ipv4.ipfrag_time = 30
net.ipv4.neigh.default.anycast_delay = 100
net.ipv4.neigh.default.app_solicit = 0
net.ipv4.neigh.default.base_reachable_time_ms = 30000
net.ipv4.neigh.default.delay_first_probe_time = 5
net.ipv4.neigh.default.gc_interval = 30
net.ipv4.neigh.default.gc_stale_time = 60
net.ipv4.neigh.default.gc_thresh1 = 128
net.ipv4.neigh.default.gc_thresh2 = 512
net.ipv4.neigh.default.gc_thresh3 = 1024
net.ipv4.neigh.default.locktime = 100
net.ipv4.neigh.default.mcast_solicit = 3
net.ipv4.neigh.default.proxy_delay = 80
net.ipv4.neigh.default.proxy_qlen = 64
net.ipv4.neigh.default.retrans_time_ms = 1000
net.ipv4.neigh.default.ucast_solicit = 3
net.ipv4.neigh.default.unres_qlen = 31
net.ipv4.neigh.default.unres_qlen_bytes = 65536
net.ipv4.neigh.eth0.anycast_delay = 100
net.ipv4.neigh.eth0.app_solicit = 0
net.ipv4.neigh.eth0.base_reachable_time_ms = 30000
net.ipv4.neigh.eth0.delay_first_probe_time = 5
net.ipv4.neigh.eth0.gc_stale_time = 60
net.ipv4.neigh.eth0.locktime = 100
net.ipv4.neigh.eth0.mcast_solicit = 3
net.ipv4.neigh.eth0.proxy_delay = 80
net.ipv4.neigh.eth0.proxy_qlen = 64
net.ipv4.neigh.eth0.retrans_time_ms = 1000
net.ipv4.neigh.eth0.ucast_solicit = 3
net.ipv4.neigh.eth0.unres_qlen = 31
net.ipv4.neigh.eth0.unres_qlen_bytes = 65536
net.ipv4.neigh.lo.anycast_delay = 100
net.ipv4.neigh.lo.app_solicit = 0
net.ipv4.neigh.lo.base_reachable_time_ms = 30000
net.ipv4.neigh.lo.delay_first_probe_time = 5
net.ipv4.neigh.lo.gc_stale_time = 60
net.ipv4.neigh.lo.locktime = 100
net.ipv4.neigh.lo.mcast_solicit = 3
net.ipv4.neigh.lo.proxy_delay = 80
net.ipv4.neigh.lo.proxy_qlen = 64
net.ipv4.neigh.lo.retrans_time_ms = 1000
net.ipv4.neigh.lo.ucast_solicit = 3
net.ipv4.neigh.lo.unres_qlen = 31
net.ipv4.neigh.lo.unres_qlen_bytes = 65536
net.ipv4.ping_group_range = 1 0
net.ipv4.route.error_burst = 5000
net.ipv4.route.error_cost = 1000
net.ipv4.route.gc_elasticity = 8
net.ipv4.route.gc_interval = 60
net.ipv4.route.gc_min_interval = 0
net.ipv4.route.gc_min_interval_ms = 500
net.ipv4.route.gc_thresh = -1
net.ipv4.route.gc_timeout = 300
net.ipv4.route.max_size = 2147483647
net.ipv4.route.min_adv_mss = 256
net.ipv4.route.min_pmtu = 552
net.ipv4.route.mtu_expires = 600
net.ipv4.route.redirect_load = 20
net.ipv4.route.redirect_number = 9
net.ipv4.route.redirect_silence = 20480
net.ipv4.tcp_abort_on_overflow = 0
net.ipv4.tcp_adv_win_scale = 1
net.ipv4.tcp_allowed_congestion_control = cubic reno #IPV4 TCP允許的擁塞控制算法
net.ipv4.tcp_app_win = 31
net.ipv4.tcp_autocorking = 1
net.ipv4.tcp_available_congestion_control = cubic reno #內核中可用的TCP擁塞控制算法
net.ipv4.tcp_base_mss = 512
net.ipv4.tcp_challenge_ack_limit = 1000
net.ipv4.tcp_congestion_control = cubic #當前正在使用的TCP擁塞控制算法
net.ipv4.tcp_dsack = 1 #是否允許TCP發送“兩個完全相同”的SACK
net.ipv4.tcp_early_retrans = 3
net.ipv4.tcp_ecn = 2
net.ipv4.tcp_fack = 1 #啟用轉發應答(Forward Acknowledgment 建議值1),可以進行有選擇應答(SACK)從而減少擁塞情況的發生
net.ipv4.tcp_fastopen = 0
net.ipv4.tcp_fastopen_key = 00000000-00000000-00000000-00000000
net.ipv4.tcp_fin_timeout = 60 #server端主動發起斷開連接後保持在FIN-WAIT-2狀態的時間(建議30s)
net.ipv4.tcp_frto = 2
net.ipv4.tcp_invalid_ratelimit = 500 #無效數據包發送速率時間限制(單位:毫秒)
net.ipv4.tcp_keepalive_intvl = 75 #探測消息未獲得響應時,重發該消息的間隔時間(單位:秒 建議值 30)
net.ipv4.tcp_keepalive_probes = 9 #在認定TCP連接失效之前,最多發送多少個keepalive探測消息(建議值3)
net.ipv4.tcp_keepalive_time = 7200 #TCP發送keepalive探測消息的間隔時間(秒),用於確認TCP連接是否有效(建議值1800)
net.ipv4.tcp_limit_output_bytes = 262144 #單個套接字限制最大輸出字節數(建議保持默認256KB)
net.ipv4.tcp_low_latency = 0 #是否允許TCP/IP棧適應在高吞吐量情況下低延時的情況(此選項建議為0)
net.ipv4.tcp_max_orphans = 8192 #允許保留的僵屍套接字的最大值(此值設置過大會給CC×××帶來便利)
net.ipv4.tcp_max_ssthresh = 0
net.ipv4.tcp_max_syn_backlog = 128 #SYN隊列的長度,增大其值可以增大服務器接收並發的能力 (建議值1280)
net.ipv4.tcp_max_tw_buckets = 8192 #針對TIME-WAIT數量配置其上限(此值配置太大很容易給CC×××提供便利)
net.ipv4.tcp_mem = 45918 61225 91836 #TCP協議棧緩沖區的最小值、壓力值、最大值;高於最大值,TCP拒絕分配socket
net.ipv4.tcp_min_tso_segs = 2
net.ipv4.tcp_moderate_rcvbuf = 1 #是否開啟TCP緩沖內存自動調整功能
net.ipv4.tcp_mtu_probing = 0 #是否開啟tcp層路徑mtu發現
net.ipv4.tcp_no_metrics_save = 0 #是否將LAST_ACK狀態保存各種連接信息到路由緩存中:方便下次連接時快速恢復現場
net.ipv4.tcp_notsent_lowat = -1
net.ipv4.tcp_orphan_retries = 0 #僵屍套接字的重試次數
net.ipv4.tcp_reordering = 3
net.ipv4.tcp_retrans_collapse = 1
net.ipv4.tcp_retries1 = 3 #放棄回應一個TCP連接請求前進行重試的次數
net.ipv4.tcp_retries2 = 15 #放棄一個已經建立的TCP連接前進行重試的次數
net.ipv4.tcp_rfc1337 = 0
net.ipv4.tcp_rmem = 4096 87380 6291456 #TCP套接字接收緩沖區的最小值、壓力值、最大值;高於最大值,TCP拒絕分配socket
net.ipv4.tcp_sack = 1 #是否啟用有選擇的應答(Selective Acknowledgment 建議值1),使TCP只重新發送交互過程中丟失的包,不用發送後續所有的包,而且提供相應機制使接收方能告訴發送方哪些數據丟失,哪些數據重發了,哪些數據已經提前收到了。如此大大提高了客戶端與服務器端數據交互的效率
net.ipv4.tcp_slow_start_after_idle = 1 #擁塞窗口在經過一段時間空閑後是否需要重新初始化(建議值1)
net.ipv4.tcp_stdurg = 0
net.ipv4.tcp_syn_retries = 6 #server主動連接client時發送syn的重試次數(沒有特殊需求,建議保持此值)
net.ipv4.tcp_synack_retries = 5 #server應答client的synack的重試次數
net.ipv4.tcp_syncookies = 1 #是否打開SYN Cookie功能(啟用此功能可以防止部分SYN×××)
net.ipv4.tcp_thin_dupack = 0
net.ipv4.tcp_thin_linear_timeouts = 0
net.ipv4.tcp_timestamps = 1 #是否啟用TCP時間戳(會在TCP包頭增加12個字節),增加了報文大小,但實現了更好的TCP性能
net.ipv4.tcp_tso_win_divisor = 3
net.ipv4.tcp_tw_recycle = 0 #是否快速回收TIME-WAIT套接字,不建議快速回收,但可以reuse,否則NAT環境會有問題
net.ipv4.tcp_tw_reuse = 0 #是否將處於TIME-WAIT狀態的socket(TIME-WAIT的端口)重新用於TCP連接
net.ipv4.tcp_window_scaling = 1 #要支持超過64KB的TCP窗口,必須啟用該值,TCP連接雙方都啟用時才生效
net.ipv4.tcp_wmem = 4096 16384 4194304 #TCP套接字發送緩沖區的最小值、壓力值、最大值;高於最大值,TCP拒絕分配socket
net.ipv4.tcp_workaround_signed_windows = 0
net.ipv4.udp_mem = 47073 62766 94146
net.ipv4.udp_rmem_min = 4096
net.ipv4.udp_wmem_min = 4096
net.ipv4.xfrm4_gc_thresh = 32768
net.ipv6.anycast_src_echo_reply = 0
net.ipv6.bindv6only = 0
net.ipv6.conf.all.accept_dad = 0
net.ipv6.conf.all.accept_ra = 1
net.ipv6.conf.all.accept_ra_defrtr = 1
net.ipv6.conf.all.accept_ra_pinfo = 1
net.ipv6.conf.all.accept_ra_rt_info_max_plen = 0
net.ipv6.conf.all.accept_ra_rtr_pref = 1
net.ipv6.conf.all.accept_redirects = 1
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.all.autoconf = 1
net.ipv6.conf.all.dad_transmits = 1
net.ipv6.conf.all.disable_ipv6 = 0 #是否在所有的網絡接口上禁用IPv6(XenServer虛機禁用無效)
net.ipv6.conf.all.force_mld_version = 0
net.ipv6.conf.all.force_tllao = 0
net.ipv6.conf.all.forwarding = 0
net.ipv6.conf.all.hop_limit = 64
net.ipv6.conf.all.max_addresses = 16
net.ipv6.conf.all.max_desync_factor = 600
net.ipv6.conf.all.mc_forwarding = 0
net.ipv6.conf.all.mldv1_unsolicited_report_interval = 10000
net.ipv6.conf.all.mldv2_unsolicited_report_interval = 1000
net.ipv6.conf.all.mtu = 1280
net.ipv6.conf.all.ndisc_notify = 0
net.ipv6.conf.all.optimistic_dad = 0
net.ipv6.conf.all.proxy_ndp = 0
net.ipv6.conf.all.regen_max_retry = 3
net.ipv6.conf.all.router_probe_interval = 60
net.ipv6.conf.all.router_solicitation_delay = 1
net.ipv6.conf.all.router_solicitation_interval = 4
net.ipv6.conf.all.router_solicitations = 3
net.ipv6.conf.all.temp_prefered_lft = 86400
net.ipv6.conf.all.temp_valid_lft = 604800
net.ipv6.conf.all.use_optimistic = 0
net.ipv6.conf.all.use_tempaddr = 0
net.ipv6.conf.default.accept_dad = 1
net.ipv6.conf.default.accept_ra = 1
net.ipv6.conf.default.accept_ra_defrtr = 1
net.ipv6.conf.default.accept_ra_pinfo = 1
net.ipv6.conf.default.accept_ra_rt_info_max_plen = 0
net.ipv6.conf.default.accept_ra_rtr_pref = 1
net.ipv6.conf.default.accept_redirects = 1
net.ipv6.conf.default.accept_source_route = 0
net.ipv6.conf.default.autoconf = 1
net.ipv6.conf.default.dad_transmits = 1
net.ipv6.conf.default.disable_ipv6 = 0 #默認是否禁用IPv6(用不到IPv6時建議禁用-設定此值為1 (XenServer虛機禁用無效))
net.ipv6.conf.default.force_mld_version = 0
net.ipv6.conf.default.force_tllao = 0
net.ipv6.conf.default.forwarding = 0
net.ipv6.conf.default.hop_limit = 64
net.ipv6.conf.default.max_addresses = 16
net.ipv6.conf.default.max_desync_factor = 600
net.ipv6.conf.default.mc_forwarding = 0
net.ipv6.conf.default.mldv1_unsolicited_report_interval = 10000
net.ipv6.conf.default.mldv2_unsolicited_report_interval = 1000
net.ipv6.conf.default.mtu = 1280
net.ipv6.conf.default.ndisc_notify = 0
net.ipv6.conf.default.optimistic_dad = 0
net.ipv6.conf.default.proxy_ndp = 0
net.ipv6.conf.default.regen_max_retry = 3
net.ipv6.conf.default.router_probe_interval = 60
net.ipv6.conf.default.router_solicitation_delay = 1
net.ipv6.conf.default.router_solicitation_interval = 4
net.ipv6.conf.default.router_solicitations = 3
net.ipv6.conf.default.temp_prefered_lft = 86400
net.ipv6.conf.default.temp_valid_lft = 604800
net.ipv6.conf.default.use_optimistic = 0
net.ipv6.conf.default.use_tempaddr = 0
net.ipv6.conf.eth0.accept_dad = 1
net.ipv6.conf.eth0.accept_ra = 1
net.ipv6.conf.eth0.accept_ra_defrtr = 1
net.ipv6.conf.eth0.accept_ra_pinfo = 1
net.ipv6.conf.eth0.accept_ra_rt_info_max_plen = 0
net.ipv6.conf.eth0.accept_ra_rtr_pref = 1
net.ipv6.conf.eth0.accept_redirects = 1
net.ipv6.conf.eth0.accept_source_route = 0
net.ipv6.conf.eth0.autoconf = 1
net.ipv6.conf.eth0.dad_transmits = 1
net.ipv6.conf.eth0.disable_ipv6 = 0
net.ipv6.conf.eth0.force_mld_version = 0
net.ipv6.conf.eth0.force_tllao = 0
net.ipv6.conf.eth0.forwarding = 0
net.ipv6.conf.eth0.hop_limit = 64
net.ipv6.conf.eth0.max_addresses = 16
net.ipv6.conf.eth0.max_desync_factor = 600
net.ipv6.conf.eth0.mc_forwarding = 0
net.ipv6.conf.eth0.mldv1_unsolicited_report_interval = 10000
net.ipv6.conf.eth0.mldv2_unsolicited_report_interval = 1000
net.ipv6.conf.eth0.mtu = 1500
net.ipv6.conf.eth0.ndisc_notify = 0
net.ipv6.conf.eth0.optimistic_dad = 0
net.ipv6.conf.eth0.proxy_ndp = 0
net.ipv6.conf.eth0.regen_max_retry = 3
net.ipv6.conf.eth0.router_probe_interval = 60
net.ipv6.conf.eth0.router_solicitation_delay = 1
net.ipv6.conf.eth0.router_solicitation_interval = 4
net.ipv6.conf.eth0.router_solicitations = 3
net.ipv6.conf.eth0.temp_prefered_lft = 86400
net.ipv6.conf.eth0.temp_valid_lft = 604800
net.ipv6.conf.eth0.use_optimistic = 0
net.ipv6.conf.eth0.use_tempaddr = 0
net.ipv6.conf.lo.accept_dad = -1
net.ipv6.conf.lo.accept_ra = 1
net.ipv6.conf.lo.accept_ra_defrtr = 1
net.ipv6.conf.lo.accept_ra_pinfo = 1
net.ipv6.conf.lo.accept_ra_rt_info_max_plen = 0
net.ipv6.conf.lo.accept_ra_rtr_pref = 1
net.ipv6.conf.lo.accept_redirects = 1
net.ipv6.conf.lo.accept_source_route = 0
net.ipv6.conf.lo.autoconf = 1
net.ipv6.conf.lo.dad_transmits = 1
net.ipv6.conf.lo.disable_ipv6 = 0 #是否在lo接口上禁用IPv6 (XenServer虛機禁用無效)
net.ipv6.conf.lo.force_mld_version = 0
net.ipv6.conf.lo.force_tllao = 0
net.ipv6.conf.lo.forwarding = 0
net.ipv6.conf.lo.hop_limit = 64
net.ipv6.conf.lo.max_addresses = 16
net.ipv6.conf.lo.max_desync_factor = 600
net.ipv6.conf.lo.mc_forwarding = 0
net.ipv6.conf.lo.mldv1_unsolicited_report_interval = 10000
net.ipv6.conf.lo.mldv2_unsolicited_report_interval = 1000
net.ipv6.conf.lo.mtu = 65536
net.ipv6.conf.lo.ndisc_notify = 0
net.ipv6.conf.lo.optimistic_dad = 0
net.ipv6.conf.lo.proxy_ndp = 0
net.ipv6.conf.lo.regen_max_retry = 3
net.ipv6.conf.lo.router_probe_interval = 60
net.ipv6.conf.lo.router_solicitation_delay = 1
net.ipv6.conf.lo.router_solicitation_interval = 4
net.ipv6.conf.lo.router_solicitations = 3
net.ipv6.conf.lo.temp_prefered_lft = 86400
net.ipv6.conf.lo.temp_valid_lft = 604800
net.ipv6.conf.lo.use_optimistic = 0
net.ipv6.conf.lo.use_tempaddr = -1
net.ipv6.fwmark_reflect = 0
net.ipv6.icmp.ratelimit = 1000
net.ipv6.idgen_delay = 1
net.ipv6.idgen_retries = 3
net.ipv6.ip6frag_high_thresh = 4194304
net.ipv6.ip6frag_low_thresh = 3145728
net.ipv6.ip6frag_secret_interval = 600
net.ipv6.ip6frag_time = 60
net.ipv6.ip_nonlocal_bind = 0
net.ipv6.mld_max_msf = 64
net.ipv6.mld_qrv = 2
net.ipv6.neigh.default.anycast_delay = 100
net.ipv6.neigh.default.app_solicit = 0
net.ipv6.neigh.default.base_reachable_time_ms = 30000
net.ipv6.neigh.default.delay_first_probe_time = 5
net.ipv6.neigh.default.gc_interval = 30
net.ipv6.neigh.default.gc_stale_time = 60
net.ipv6.neigh.default.gc_thresh1 = 128
net.ipv6.neigh.default.gc_thresh2 = 512
net.ipv6.neigh.default.gc_thresh3 = 1024
net.ipv6.neigh.default.locktime = 0
net.ipv6.neigh.default.mcast_solicit = 3
net.ipv6.neigh.default.proxy_delay = 80
net.ipv6.neigh.default.proxy_qlen = 64
net.ipv6.neigh.default.retrans_time_ms = 1000
net.ipv6.neigh.default.ucast_solicit = 3
net.ipv6.neigh.default.unres_qlen = 31
net.ipv6.neigh.default.unres_qlen_bytes = 65536
net.ipv6.neigh.eth0.anycast_delay = 100
net.ipv6.neigh.eth0.app_solicit = 0
net.ipv6.neigh.eth0.base_reachable_time_ms = 30000
net.ipv6.neigh.eth0.delay_first_probe_time = 5
net.ipv6.neigh.eth0.gc_stale_time = 60
net.ipv6.neigh.eth0.locktime = 0
net.ipv6.neigh.eth0.mcast_solicit = 3
net.ipv6.neigh.eth0.proxy_delay = 80
net.ipv6.neigh.eth0.proxy_qlen = 64
net.ipv6.neigh.eth0.retrans_time_ms = 1000
net.ipv6.neigh.eth0.ucast_solicit = 3
net.ipv6.neigh.eth0.unres_qlen = 31
net.ipv6.neigh.eth0.unres_qlen_bytes = 65536
net.ipv6.neigh.lo.anycast_delay = 100
net.ipv6.neigh.lo.app_solicit = 0
net.ipv6.neigh.lo.base_reachable_time_ms = 30000
net.ipv6.neigh.lo.delay_first_probe_time = 5
net.ipv6.neigh.lo.gc_stale_time = 60
net.ipv6.neigh.lo.locktime = 0
net.ipv6.neigh.lo.mcast_solicit = 3
net.ipv6.neigh.lo.proxy_delay = 80
net.ipv6.neigh.lo.proxy_qlen = 64
net.ipv6.neigh.lo.retrans_time_ms = 1000
net.ipv6.neigh.lo.ucast_solicit = 3
net.ipv6.neigh.lo.unres_qlen = 31
net.ipv6.neigh.lo.unres_qlen_bytes = 65536
net.ipv6.route.gc_elasticity = 9
net.ipv6.route.gc_interval = 30
net.ipv6.route.gc_min_interval = 0
net.ipv6.route.gc_min_interval_ms = 500
net.ipv6.route.gc_thresh = 1024
net.ipv6.route.gc_timeout = 60
net.ipv6.route.max_size = 16384
net.ipv6.route.min_adv_mss = 1220
net.ipv6.route.mtu_expires = 600
net.ipv6.xfrm6_gc_thresh = 32768
net.netfilter.nf_conntrack_acct = 0
net.netfilter.nf_conntrack_buckets = 16384
net.netfilter.nf_conntrack_checksum = 1
net.netfilter.nf_conntrack_count = 1
net.netfilter.nf_conntrack_dccp_loose = 1
net.netfilter.nf_conntrack_dccp_timeout_closereq = 64
net.netfilter.nf_conntrack_dccp_timeout_closing = 64
net.netfilter.nf_conntrack_dccp_timeout_open = 43200
net.netfilter.nf_conntrack_dccp_timeout_partopen = 480
net.netfilter.nf_conntrack_dccp_timeout_request = 240
net.netfilter.nf_conntrack_dccp_timeout_respond = 480
net.netfilter.nf_conntrack_dccp_timeout_timewait = 240
net.netfilter.nf_conntrack_events = 1
net.netfilter.nf_conntrack_events_retry_timeout = 15
net.netfilter.nf_conntrack_expect_max = 256
net.netfilter.nf_conntrack_frag6_high_thresh = 4194304
net.netfilter.nf_conntrack_frag6_low_thresh = 3145728
net.netfilter.nf_conntrack_frag6_timeout = 60
net.netfilter.nf_conntrack_generic_timeout = 600
net.netfilter.nf_conntrack_helper = 1
net.netfilter.nf_conntrack_icmp_timeout = 30
net.netfilter.nf_conntrack_icmpv6_timeout = 30
net.netfilter.nf_conntrack_log_invalid = 0
net.netfilter.nf_conntrack_max = 65536
net.netfilter.nf_conntrack_sctp_timeout_closed = 10
net.netfilter.nf_conntrack_sctp_timeout_cookie_echoed = 3
net.netfilter.nf_conntrack_sctp_timeout_cookie_wait = 3
net.netfilter.nf_conntrack_sctp_timeout_established = 432000
net.netfilter.nf_conntrack_sctp_timeout_heartbeat_acked = 210
net.netfilter.nf_conntrack_sctp_timeout_heartbeat_sent = 30
net.netfilter.nf_conntrack_sctp_timeout_shutdown_ack_sent = 3
net.netfilter.nf_conntrack_sctp_timeout_shutdown_recd = 0
net.netfilter.nf_conntrack_sctp_timeout_shutdown_sent = 0
net.netfilter.nf_conntrack_tcp_be_liberal = 0
net.netfilter.nf_conntrack_tcp_loose = 1
net.netfilter.nf_conntrack_tcp_max_retrans = 3
net.netfilter.nf_conntrack_tcp_timeout_close = 10
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60
net.netfilter.nf_conntrack_tcp_timeout_established = 432000
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120
net.netfilter.nf_conntrack_tcp_timeout_last_ack = 30
net.netfilter.nf_conntrack_tcp_timeout_max_retrans = 300
net.netfilter.nf_conntrack_tcp_timeout_syn_recv = 60
net.netfilter.nf_conntrack_tcp_timeout_syn_sent = 120
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120
net.netfilter.nf_conntrack_tcp_timeout_unacknowledged = 300
net.netfilter.nf_conntrack_timestamp = 0
net.netfilter.nf_conntrack_udp_timeout = 30
net.netfilter.nf_conntrack_udp_timeout_stream = 180
net.netfilter.nf_log.0 = NONE
net.netfilter.nf_log.1 = NONE
net.netfilter.nf_log.10 = NONE
net.netfilter.nf_log.11 = NONE
net.netfilter.nf_log.12 = NONE
net.netfilter.nf_log.2 = NONE
net.netfilter.nf_log.3 = NONE
net.netfilter.nf_log.4 = NONE
net.netfilter.nf_log.5 = NONE
net.netfilter.nf_log.6 = NONE
net.netfilter.nf_log.7 = NONE
net.netfilter.nf_log.8 = NONE
net.netfilter.nf_log.9 = NONE
net.netfilter.nf_log_all_netns = 0
net.nf_conntrack_max = 65536
net.unix.max_dgram_qlen = 512
user.max_ipc_namespaces = 7845
user.max_mnt_namespaces = 7845
user.max_net_namespaces = 7845
user.max_pid_namespaces = 7845
user.max_user_namespaces = 0
user.max_uts_namespaces = 7845
vm.admin_reserve_kbytes = 8192 #始終會預留給管理員的內存
vm.block_dump = 0
vm.dirty_background_bytes = 0
vm.dirty_background_ratio = 10 #當系統臟頁的比例或者所占內存數量超過 dirty_background_ratio(百分數)閾值時,啟動相關內核線程(pdflush/flush/kdmflush)開始將臟頁寫入磁盤
vm.dirty_bytes = 0
vm.dirty_expire_centisecs = 3000 #聲明Linux內核寫緩沖區裏面的數據多"舊"了之後,pdflush/flush/kdmflush進程就開始考慮寫到磁盤中去
vm.dirty_ratio = 30 #當系統pagecache的臟頁達到系統內存 dirty_ratio(百分數)閾值時,系統就會阻塞新的寫請求,直到臟頁被回寫到磁盤
vm.dirty_writeback_centisecs = 500 #內核線程(pdflush/flush/kdmflush)多久喚醒一次來檢查是否需要將cache中的數據寫入磁盤,單位1/100秒
vm.drop_caches = 0 #釋放cache,該參數每修改一次,觸發一次釋放操作(手動釋放caches時就需要改變此值)
vm.extfrag_threshold = 500
vm.hugepages_treat_as_movable = 0
vm.hugetlb_shm_group = 0
vm.laptop_mode = 0
vm.legacy_va_layout = 0
vm.lowmem_reserve_ratio = 256 256 32
vm.max_map_count = 65530
vm.memory_failure_early_kill = 0
vm.memory_failure_recovery = 1
vm.min_free_kbytes = 45056 #系統內核保留內存的最低值
vm.min_slab_ratio = 5
vm.min_unmapped_ratio = 1
vm.mmap_min_addr = 4096
vm.mmap_rnd_bits = 28
vm.mmap_rnd_compat_bits = 8
vm.nr_hugepages = 0 #控制內存是否可以使用大頁面
vm.nr_hugepages_mempolicy = 0
vm.nr_overcommit_hugepages = 0
vm.nr_pdflush_threads = 0
vm.numa_zonelist_order = default
vm.oom_dump_tasks = 1 #OOM信息打印(建議值1 能夠在發生OOM後查看當時情景)
vm.oom_kill_allocating_task = 0 #控制是否殺死觸發OOM的進程(建議值0 OOM發生時內核自動kill內存占用最多的進程)
vm.overcommit_kbytes = 0
vm.overcommit_memory = 0 #控制是否允許超額申請內存
vm.overcommit_ratio = 50 #允許超額申請物理內容+此百分比的swap內存(只有當vm.overcommit_memory=2時此值才會生效)
vm.page-cluster = 3 #控制內核一次從SWAP中連續讀取2的多少次冪內存頁
vm.panic_on_oom = 0 #控制內核在OOM時是否panic(恐慌)
vm.percpu_pagelist_fraction = 0
vm.stat_interval = 1 #VM統計信息更新的時間間隔,默認值1s
vm.swappiness = 30 #控制物理內存剩余%多少時使用SWAP(建議值0,但0並非禁用SWAP,只是充分利用物理內存)
vm.user_reserve_kbytes = 60940 #始終會預留給用戶空間的內存
vm.vfs_cache_pressure = 100
vm.zone_reclaim_mode = 0

順便附上以功能模塊歸類後的參數調優列表

RAID性能參數調優

dev.raid.speed_limit_min = 1000 #RAID最小讀取速率
dev.raid.speed_limit_max = 200000 #RAID最大讀取速率,如果RAID性能較高,可以修改此上限來提升IO性能
dev.scsi.logging_level = 0 #是否開啟scsi磁盤的日誌功能,一般情況不建議開啟

網絡協議棧調整:單位是字節

net.core.optmem_max = 20480 #每個套接字所允許的最大緩沖區的大小
net.core.rmem_default = 212992 #網絡協議棧默認接收內存
net.core.rmem_max = 212992 #網絡協議棧最大接收內存
net.core.wmem_default = 212992 #網絡協議棧默認發送內存
net.core.wmem_max = 212992 #網絡協議棧最大發送內存
net.ipv4.tcp_moderate_rcvbuf = 1 #是否開啟TCP緩沖內存自動調整功能
net.ipv4.tcp_mem = 45918 61225 91836 #TCP協議棧緩沖區的最小值、壓力值、最大值;高於最大值,TCP拒絕分配socket
net.ipv4.tcp_rmem = 4096 87380 6291456 #TCP套接字接收緩沖區的最小值、壓力值、最大值;高於最大值,TCP拒絕分配socket
net.ipv4.tcp_wmem = 4096 16384 4194304 #TCP套接字發送緩沖區的最小值、壓力值、最大值;高於最大值,TCP拒絕分配socket

TCP並發性能優化

net.core.somaxconn = 1280 #定義了系統中每一個端口最大的監聽隊列長度,這是個全局的參數
net.ipv4.tcp_max_syn_backlog = 1280 #SYN隊列的長度,增大其值可以增大服務器接收並發的能力
net.ipv4.tcp_max_tw_buckets = 8192 #針對TIME-WAIT數量配置其上限
net.ipv4.tcp_syn_retries = 6 #server主動連接client時發送syn的重試次數
net.ipv4.tcp_synack_retries = 5 #server應答client的synack的重試次數
net.ipv4.tcp_fin_timeout = 30 #server端主動發起斷開連接後保持在FIN-WAIT-2狀態的時間
net.ipv4.tcp_max_orphans = 8192 #允許保留的僵屍套接字的最大值
net.core.netdev_max_backlog = 2000 #網卡設備將請求放入隊列的長度
net.core.netdev_tstamp_prequeue = 1 #網絡設備預置隊列序號

net.ipv4.tcp_tw_recycle = 0 #是否需要快速回收TIME-WAIT套接字,不建議快速回收,但可以reuse,否則NAT環境會有問題
net.ipv4.tcp_tw_reuse = 1 #是否允許將處於TIME-WAIT狀態的socket(TIME-WAIT的端口)用於新的TCP連接
net.ipv4.tcp_window_scaling = 1 #要支持超過64KB的TCP窗口,必須啟用該值,TCP連接雙方都啟用時才生效
net.ipv4.tcp_syncookies = 1 #是否打開SYN Cookie功能,該功能可以防止部分SYN×××
net.ipv4.tcp_timestamps = 1 #是否啟用TCP時間戳(會在TCP包頭增加12個字節),增加了報文大小,但實現了更好的TCP性能

對於用不上IPV6的建議直接禁用

net.ipv6.conf.default.disable_ipv6 = 1 #默認是否在lo接口上禁用IPv6 (XenServer虛機禁用無效)
net.ipv6.conf.all.disable_ipv6 = 1 #是否在所有接口上禁用IPv6 (XenServer虛機禁用無效)
net.ipv6.conf.lo.disable_ipv6 = 1 #是否在lo接口上禁用IPv6 (XenServer虛機禁用無效)

系統端口設定

net.ipv4.ip_local_port_range = 10000 65535 #服務器端可用端口範圍(建議值 1024 65535)
net.ipv4.ip_local_reserved_ports = #系統預留端口列表:可以防止並發時占用服務端口

TCP丟包重傳機制控制,TCP擁塞控制算法對TCP傳輸速率的影響比較大

net.ipv4.tcp_available_congestion_control = cubic reno #內核中可用的TCP擁塞控制算法
net.ipv4.tcp_congestion_control = cubic #當前正在使用的TCP擁塞控制算法
net.ipv4.tcp_allowed_congestion_control = cubic reno #IPV4 TCP允許的擁塞控制算法

TCP keepalive時長控制

net.ipv4.tcp_keepalive_intvl = 30 #探測消息未獲得響應時,重發該消息的間隔時間(秒)
net.ipv4.tcp_keepalive_probes = 3 #在認定TCP連接失效之前,最多發送多少個keepalive探測消息
net.ipv4.tcp_keepalive_time = 1800 #TCP發送keepalive探測消息的間隔時間(秒),用於確認TCP連接是否有效

memory

vm.overcommit_memory = 0 #控制是否允許超額申請內存
vm.overcommit_ratio = 50 #只有當vm.overcommit_memory=2時此值才會生效

vm.page-cluster = 3 #控制內核一次從SWAP中連續讀取2的多少次冪內存頁

vm.panic_on_oom = 0 #控制內核在OOM時是否panic(恐慌)
vm.stat_interval = 1 #VM統計信息更新的時間間隔,默認值1s

vm.swappiness = 0 #控制物理內存剩余%多少時使用SWAP(建議值0,但0並非禁用SWAP,只是充分利用物理內存)
vm.min_free_kbytes = 45056 #系統內核保留內存的最低值
vm.user_reserve_kbytes = 60942 #始終會預留給用戶空間的內存,此處預留60M
vm.admin_reserve_kbytes = 8192 #始終會預留給管理員的內存,此處預留8M

OOM控制

vm.oom_dump_tasks = 1 #OOM信息打印
vm.oom_kill_allocating_task = 0 #控制是否殺死觸發OOM的進程(建議值0 OOM發生時內核自動kill內存占用最多的進程)

安全防護模塊

net.ipv4.conf.default.log_martians = 0 #默認是否開啟並記錄欺騙,源路由和重定向數據包(如果是路由器建議值為1)
net.ipv4.conf.all.log_martians = 0 #是否開啟並記錄欺騙,源路由和重定向數據包:記錄帶有不允許的地址的數據報到內核日誌中(如果是路由器建議值為1)
net.ipv4.conf.default.accept_redirects = 1 #默認是否接收重寫過的數據包
net.ipv4.conf.all.accept_redirects = 1 #是否接收重寫過的數據包:用作路由器時默認值為0
net.ipv4.conf.default.accept_source_route = 0 #默認是否接收無源路由的數據包
net.ipv4.conf.all.accept_source_route = 0 #是否接收無源路由的數據包
net.ipv4.conf.default.secure_redirects = 1 #默認是否支持安全重定向數據包
net.ipv4.conf.all.secure_redirects = 1 #是否支持安全重定向數據包
net.ipv4.conf.default.rp_filter = 1 #默認是否開啟反向路徑過濾
net.ipv4.conf.all.rp_filter = 1 #是否開啟反向路徑過濾

net.ipv4.tcp_invalid_ratelimit = 500 #無效數據包發送速率時間限制(單位:毫秒)
net.ipv4.tcp_limit_output_bytes = 262144 #單個套接字限制最大輸出字節數

保障TCP通信質量

net.ipv4.tcp_sack = 1 #是否啟用有選擇的應答(Selective Acknowledgment),使TCP只重新發送交互過程中丟失的包,不用發送後續所有的包,而且提供相應機制使接收方能告訴發送方哪些數據丟失,哪些數據重發了,哪些數據已經提前收到了。如此大大提高了客戶端與服務器端數據交互的效率
net.ipv4.tcp_fack = 1 #啟用轉發應答(Forward Acknowledgment 建議值1),可以進行有選擇應答(SACK)從而減少擁塞情況的發生

net.ipv4.tcp_slow_start_after_idle = 1 #擁塞窗口在經過一段時間空閑後是否需要重新初始化
net.ipv4.tcp_stdurg = 0
net.ipv4.tcp_retries1 = 3 #放棄回應一個TCP連接請求前進行重試的次數
net.ipv4.tcp_retries2 = 15 #放棄一個已經建立的TCP連接前進行重試的次數
net.ipv4.tcp_rfc1337 = 0
net.ipv4.tcp_mtu_probing = 0 #是否開啟tcp層路徑mtu發現
net.ipv4.tcp_no_metrics_save = 0 #是否將LAST_ACK狀態保存各種連接信息到路由緩存中:方便下次連接時快速恢復現場

IO密集性服務器優化參數

vm.dirty_expire_centisecs = 3000 #聲明Linux內核寫緩沖區裏面的數據多"舊"了之後,pdflush/flush/kdmflush進程就開始考慮寫到磁盤中去
vm.dirty_background_ratio = 10 #當系統臟頁的比例或者所占內存數量超過 dirty_background_ratio(百分數)閾值時,啟動相關內核線程(pdflush/flush/kdmflush)開始將臟頁寫入磁盤
vm.dirty_ratio = 30 #當系統pagecache的臟頁達到系統內存 dirty_ratio(百分數)閾值時,系統就會阻塞新的寫請求,直到臟頁被回寫到磁盤

vm.drop_caches = 0 #釋放cache,該參數每修改一次,觸發一次釋放操作
vm.dirty_writeback_centisecs = 500 #內核線程(pdflush/flush/kdmflush)多久喚醒一次來檢查是否需要將cache中的數據寫入磁盤,單位1/100秒

LVS負載均衡需要修改選項arp_ignore=1,arp_announce=2,兩項的默認開關不用修改,需要修改all和lo

net.ipv4.conf.default.arp_ignore = 0
net.ipv4.conf.all.arp_ignore = 0 #定義對目標地址為本地IP的ARP詢問不同的應答模式
#0:回應任何網絡接口上對任何本地IP地址的arp查詢請求
#1:只回答目標IP地址是來訪網絡接口本地地址的ARP查詢請求
#2:只回答目標IP地址是來訪網絡接口本地地址的ARP查詢請求,且來訪IP必須在該網絡接口的子網段內
#3:不回應該網絡界面的arp請求,而只對設置的唯一和連接地址做出回應
#8:不回應所有(本地地址)的arp查詢
net.ipv4.conf.lo.arp_ignore = 0
net.ipv4.conf.default.arp_announce = 0
net.ipv4.conf.all.arp_announce = 0 #對網絡接口上,本地IP地址的發出的,ARP回應,作出相應級別的限制: 確定不同程度的限制,宣布對來自本地源IP地址發出Arp請求的接口
#0: 在任意網絡接口(eth0,eth1,lo)上的任何本地地址
#1:盡量避免不在該網絡接口子網段的本地地址做出arp回應. 當發起ARP請求的源IP地址是被設置應該經由路由達到此網絡接口的時候很有用.此時會檢查來訪IP是否為所有接口上的子網段內ip之一.如果改來訪IP不屬於各個網絡接口上的子網段內,那麽將采用級別2的方式來進行處理.
#2:對查詢目標使用最適當的本地地址.在此模式下將忽略這個IP數據包的源地址並嘗試選擇與能與該地址通信的本地地址.首要是選擇所有的網絡接口的子網中外出訪問子網中包含該目標IP地址的本地地址. 如果沒有合適的地址被發現,將選擇當前的發送網絡接口或其他的有可能接受到該ARP回應的網絡接口來進行發送.
net.ipv4.conf.lo.arp_announce = 0
net.ipv4.ip_no_pmtu_disc = 0 #是否關閉路徑MTU探測功能
net.ipv4.ip_forward_use_pmtu = 0 #是否支持巨型幀轉發(使用LVS做負載均衡器時建議此值為1)

net.ipv4.conf.default.arp_accept = 0
net.ipv4.conf.all.arp_accept = 0 #默認對不在ARP表中的IP地址發出的APR包的處理方式:0不在ARP表中創建對應IP地址的表項;1在ARP表中創建對應IP地址的表項

net.ipv4.conf.default.arp_filter = 0
net.ipv4.conf.all.arp_filter = 0 # 0:內核設置每個網絡接口各自應答其地址上的arp詢問。這項看似會錯誤的設置卻經常能非常有效,因為它增加了成功通訊的機會。在Linux主機上,每個IP地址是網絡接口獨立的,而非一個復合的接口。只有在一些特殊的設置的時候,比如負載均衡的時候會帶來麻煩
#1:允許多個網絡介質位於同一子網段內,每個網絡界面依據是否內核指派路由該數據包經過此接口來確認是否回答ARP查詢(這個實現是由來源地址確定路由的時候決定的),換句話說,允許控制使用某一塊網卡(通常是第一塊)回應arp詢問

net.ipv4.conf.default.arp_notify = 0
net.ipv4.conf.all.arp_notify = 0 #是否開啟arp通知鏈操作:0不做任何操作,1當設備或硬件地址改變時自動產生一個arp請求
net.ipv4.conf.default.bootp_relay = 0
net.ipv4.conf.all.bootp_relay = 0 #是否接收源地址為0.a.b.c,目的地址不是本機的數據包,是為了支持bootp服務
net.ipv4.conf.default.disable_policy = 0
net.ipv4.conf.all.disable_policy = 0 #是否禁止internet協議安全性驗證
net.ipv4.conf.default.disable_xfrm = 0
net.ipv4.conf.all.disable_xfrm = 0 #是否禁止internet協議安全性加密

net.ipv4.conf.default.force_igmp_version = 0
net.ipv4.conf.all.force_igmp_version = 0

路由器選項控制

net.ipv4.conf.default.forwarding = 0
net.ipv4.ip_forward = 0 #是否啟用IP轉發
net.ipv4.conf.all.forwarding = 0 #是否啟用轉發功能
net.ipv4.conf.default.mc_forwarding = 0
net.ipv4.conf.all.mc_forwarding = 0 #是否進行多播路由(只有內核編譯有CONFIG_MROUTE並且有路由服務程序在運行該參數才有效)
net.ipv4.conf.default.medium_id = 0
net.ipv4.conf.all.medium_id = 0 #用來區分不同媒介.兩個網絡設備可以使用不同的值,使他們只有其中之一接收到廣播包.通常,這個參數被用來配合proxy_arp實現roxy_arp的特性即是允許arp報文在兩個不同的網絡介質中轉發.
#0:表示各個網絡介質接受他們自己介質上的媒介
#-1:表示該媒介未知
net.ipv4.conf.default.promote_secondaries = 1
net.ipv4.conf.all.promote_secondaries = 1 #主備IP地址切換控制機制:0當接口的主IP地址被移除時,刪除所有次IP地址;1當接口的主IP地址被移除時,將次IP地址提升為主IP地址
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.all.proxy_arp = 0 #是否啟用arp代理功能
net.ipv4.conf.default.proxy_arp_pvlan = 0
net.ipv4.conf.all.proxy_arp_pvlan = 0 #回應代理ARP的數據包從接收到此代理ARP請求的網絡接口出去
net.ipv4.conf.default.route_localnet = 0
net.ipv4.conf.all.route_localnet = 0 #是否允許外部訪問localhost
net.ipv4.conf.default.shared_media = 1
net.ipv4.conf.all.shared_media = 1 #發送或接收RFC1620 共享媒體重定向 會覆蓋ip_secure_redirects的值

路由機制控制

net.ipv4.ip_no_pmtu_disc = 0 #是否關閉路徑MTU探測功能
net.ipv4.ip_forward_use_pmtu = 0 #是否支持巨型幀轉發(使用LVS做負載均衡器時建議此值為1)
net.ipv4.conf.default.send_redirects = 1 #默認是否發送重定向數據包
net.ipv4.conf.all.send_redirects = 1 #是否發送重定向數據包
net.ipv4.ip_default_ttl = 64 #定義數據報的生存周期:最多經過多少路由器後數據將被丟棄

net.ipv4.conf.default.src_valid_mark = 0 #默認是否為源地址有效的數據包打標記
net.ipv4.conf.all.src_valid_mark = 0 #是否為所有接口上源地址有效的數據包打標記

net.ipv4.conf.default.tag = 0
net.ipv4.conf.all.tag = 0

net.ipv4.conf.default.accept_local = 0 #默認是否允許接收從本機IP地址上發送給本機的數據包
net.ipv4.conf.all.accept_local = 0 #是否允許所有接口接收從本機IP地址上發送給本機的數據包

內存大頁面使用策略

vm.nr_hugepages = 0 #控制內存是否可以使用大頁面

能力有限,沒有對所有linux內核參數做註釋說明,還望高人閱讀後幫忙添磚加瓦,力求更回完美,在此提前謝謝大家,希望閱讀之後,多多留言指正,我會及時進行更新!

民間最全的Linux系統內核參數調優說明