zoukankan      html  css  js  c++  java
  • Linux内核参数优化

    1、调整sysctl.conf文件参数:

    [root@localhost /]# vim /etc/sysctl.conf
    
    # 定义系统中每一个端口最大的监听队列的长度:
    net.core.somaxconn = 2048
    
    # 一个进程可以拥有的VMA(虚拟内存区域)的数量:
    vm.max_map_count=262144
    
    # 允许系统内核分配所有的物理内存:
    vm.overcommit_memory = 1
    
    # 调用虚拟内存的阈值数:
    vm.swappiness=1
    
    [root@localhost /]# sysctl -p
    

    2、调整 / 每个进程最多允许同时打开文件数 / 每个进程最多可以同时建立TCP连接数: 

    sed -i 's/# End of file//g' /etc/security/limits.conf
    sed -i '$a *           soft  nofile  409600' /etc/security/limits.conf
    sed -i '$a *           hard  nofile  409600' /etc/security/limits.conf
    sed -i '$a *           soft  nproc   204800' /etc/security/limits.conf
    sed -i '$a *           hard  nproc   204800' /etc/security/limits.conf
    sed -i '$a # End of file' /etc/security/limits.conf
    

    注:mongodb系统要求nofile = noroc*2

    系统重启后生效:

    # reboot
    

    验证设置:

    [root@localhost /]# ulimit -a | grep "open files"
    open files                      (-n) 131070
    

    查看一个进程的limit设置:

    cat /proc/YOUR-PID/limits
    

    3、禁用Transparent Huge Pages(THP):

    vim /etc/rc.local
    
    添加如下内容:
    
    if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
    echo never > /sys/kernel/mm/transparent_hugepage/enabled
    fi
    
    if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
    echo never > /sys/kernel/mm/transparent_hugepage/defrag
    fi 

      注:CentOS7系统/etc/rc.local默认没有执行权限,需要自己添加权限

    chmod +x /etc/rc.d/rc.local
    

    [THE END]

  • 相关阅读:
    实现一个与内容合二为一的ActionBar动画效果
    hdoj 1506&&1505(City Game) dp
    remine chart2安装
    zoom的学习
    海哥:T2C时代的到来了,那么什么叫T2C?
    minhash算法
    动态创建按钮的JS
    socket编程在windows和linux下的区别
    http staus汇总
    MySQL HINT:Straight_JOIN
  • 原文地址:https://www.cnblogs.com/configure/p/6733187.html
Copyright © 2011-2022 走看看