內核調優

相信作運維的同仁,進行運維環境初建時,必需要考慮到操做系統內核參數的優化問題,本人經歷數次的運維環境重建後,決定要自行收集一份比較完善的系統內核參數優化說明文件出來,因而就有了下文,本文當前值是官方默認參數,建議參數直接添加於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 #控制內存是否可使用大頁面
相關文章
相關標籤/搜索