Linux kernel optimization related shell script

Source: Internet
Author: User

#修改 some of the default configurations in the/etc/sysctl.conf file
if [ grep -v "^\s*#" /etc/sysctl.conf|grep -c "net.ipv4.ip_forward\s\+=\+0"];then
Cat >>/etc/sysctl.conf << EOF
Net.ipv4.ip_forward = 0
Net.ipv4.tcp_max_tw_buckets = 5000
Fs.file-max = 65535
Net.ipv4.ip_local_port_range = 1024 65000
Net.ipv4.tcp_syncookies = 1
Vm.overcommit_memory = 1
Net.ipv4.tcp_fin_timeout = 1
Net.ipv4.tcp_keepalive_time = 1200
Net.ipv4.tcp_mem = 94500000 915000000 927000000
Net.ipv4.tcp_tw_reuse = 1
Net.ipv4.tcp_tw_recycle = 1
Net.ipv4.tcp_timestamps = 0
Net.ipv4.tcp_synack_retries = 1
Net.ipv4.tcp_syn_retries = 1
Net.ipv4.tcp_abort_on_overflow = 0
Net.core.rmem_max = 16777216
Net.core.wmem_max = 16777216
Net.core.netdev_max_backlog = 262144
Net.core.somaxconn = 65535
vm.max_map_count=655360
Net.ipv4.tcp_max_orphans = 3276800
Net.ipv4.tcp_max_syn_backlog = 262144
Net.core.wmem_default = 8388608
Net.core.rmem_default = 8388608
Eof
Sysctl-p #effective
Fi
Number of files #修改open
if [ grep -v ‘^\s*#‘ /etc/security/limits.conf |grep -c ‘soft nofile‘-eq 0];then
Cat >>/etc/security/limits.conf <<eof

    • Soft Nofile 65535
    • Hard Nofile 65535
      Eof
      ULIMIT-HSN 65535
      Fi

If [ grep -v ‘^\s*#‘ /etc/security/limits.d/20-nproc.conf |grep -c ‘soft nofile‘ -eq 0];then
Rm-rf/etc/security/limits.d/20-nproc.conf
CP $PACKAGE _dir/20-nproc.conf/etc/security/limits.d/
Fi

If [ grep -v ‘^\s*#‘ /etc/systemd/system.conf |grep -c ‘DefaultLimitCORE=infinity‘ -eq 0];then
Cat >>/etc/systemd/system.conf <<eof

Defaultlimitcore=infinity
defaultlimitnofile=100000
defaultlimitnproc=100000

Eof

Fi

If [ grep -v ‘^\s*#‘ /etc/systemd/user.conf |grep -c ‘DefaultLimitCORE=infinity‘ -eq 0];then
Cat >>/etc/systemd/user.conf <<eof

Defaultlimitcore=infinity
defaultlimitnofile=100000
defaultlimitnproc=100000

Eof

Linux kernel optimization related shell script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.