zoukankan      html  css  js  c++  java
  • linux性能优化

    一.最小化安装系统
    二.关闭NetworkManager服务。

    NetworkManger服务如果启动,当你手动配置网卡时会发生冲突

    [root@linuxangel ~]# /etc/init.d/NetworkManager stop
    Stopping NetworkManager daemon:                            [  OK  ]
    [root@linuxangel ~]# chkconfig NetworkManager off
    [root@linuxangel ~]# chkconfig --list NetworkManager
    NetworkManager  0:off   1:off   2:off   3:off   4:off   5:off   6:off
    [root@linuxangel ~]#

    三.开启messagebus

    这是 Linux 的 IPC(Interprocess Communication,进程间通讯)服务。确切地说,它与 DBUS 交互,是重要的系统服务。强烈建议开启它。

    [root@linuxangel ~]# chkconfig --list messagebus
    messagebus      0:off   1:off   2:on    3:on    4:on    5:on    6:off
    [root@linuxangel ~]# 

    四.linux服务管理工具ntsysv

    ntsysv工具能在命令行下开启text_mod 模块,方便管理服务,能够很直观的观察那些的启动,那些服务停止.

    五.irqbalance服务被证实为非常重要的服务,它能够合理的调用cpu资源,优化中断分配。

    [root@linuxangel ~]# /etc/init.d/irqbalance start
    Starting irqbalance:                                       [  OK  ]
    [root@linuxangel ~]# chkconfig --list irqbalance 
    irqbalance      0:off   1:off   2:off   3:on    4:on    5:on    6:off
    [root@linuxangel ~]# chkconfig --level 23456 irqbalance on

    七.关闭打印服务:这个非常有必要,几乎没有使用linux去打印东西,主流的打印机驱动也不支持。

    [root@linuxangel ~]# /etc/rc.d/init.d/cups stop
    Stopping cups:                                             [  OK  ]
    [root@linuxangel ~]# chkconfig --level 23456 cups off 
    [root@linuxangel ~]# chkconfig --list cups
    cups            0:off   1:off   2:off   3:off   4:off   5:off   6:off
    [root@linuxangel ~]#

    八.针对需求关闭或者开启的iptables
    如果你的服务器不是用于特殊的服务,如web前端,mysql等等,建议关闭iptables服务。降低系统负载。

    [root@linuxangel ~]# 
    [root@linuxangel ~]# /etc/init.d/iptables stop
    iptables: Flushing firewall rules:                         [  OK  ]
    iptables: Setting chains to policy ACCEPT: nat mangle filte[  OK  ]
    iptables: Unloading modules:                               [  OK  ]
    [root@linuxangel ~]# chkconfig --level 23456 iptables off

    九.关闭selinux

    [root@linuxangel ~]# setenforce 0  #零时设置为permissive(自由模式)
    [root@linuxangel ~]# sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config #禁止selinux(需重启系统)  

    十.关闭不需要的多余的tty控制终端
    修改/etc/inittab文件
    找到类似tty1,tty2,留下三到两个终端,关闭其余的终端。
    然后执行init q

    十一.增强扛SYN Flood攻击的能力:

    [root@linuxangel ~]# echo "net.ipv4.tcp_syncookies = 1" >> /etc/sysctl.conf 
    
    [root@linuxangel ~]# sysctl -p   #应用修改:
    net.ipv4.ip_forward = 0
    net.ipv4.conf.default.rp_filter = 1
    net.ipv4.conf.default.accept_source_route = 0
    kernel.sysrq = 0
    kernel.core_uses_pid = 1
    net.ipv4.tcp_syncookies = 1
    net.bridge.bridge-nf-call-ip6tables = 0
    net.bridge.bridge-nf-call-iptables = 0
    net.bridge.bridge-nf-call-arptables = 0
    kernel.msgmnb = 65536
    kernel.msgmax = 65536
    kernel.shmmax = 68719476736
    kernel.shmall = 4294967296
    net.ipv4.tcp_syncookies = 1
    [root@linuxangel ~]# 

    十二.修改linux的history记录个数:

    [root@linuxangel ~]# sed -i 's/HISTSIZE=.*/HISTSIZE=100/g' /etc/profile
    定期执行history -c命令,可以加入到计划任务,尤其是在安全级别比较高的服务器上。

    十三.停止ipv6,现阶段基本没有使用到ipv6技术,建议关闭。

    [root@linuxangel ~]# echo "alias net-pf-10 off" >> /etc/modprobe.d/dist.conf 
    [root@linuxangel ~]# echo "alias ipv6 off " >> /etc/modprobe.d/dist.conf
    [root@linuxangel ~]# echo "IPV6INIT=no" >> /etc/sysconfig/network-scripts/ifcfg-eth0 

    十四.限制打开文件的最大数:
    理论上修改这个配置文件是有效的,但是部分系统重启之后就还原了。

    [root@linuxangel ~]# vi /etc/security/limits.conf

    解决办法是使用ulimit -SHn 65535命令修改,并加入到系统启动脚本当中
    可以通过脚本查看一些服务打开的文件数:

    #!/bin/bash
    for pid in $(ps aux | grep http | grep -v grep | awk '{print $2}');do
    cat /proc/$pid/limits |grep 'Max open files';
    done
    [root@linuxangel ~]# for pid in $(ps aux | grep http | grep -v grep | awk '{print $2}');do cat /proc/$pid/limits | grep 'Max open files'; done
    Max open files            1024                 4096                 files     
    Max open files            1024                 4096                 files     
    Max open files            1024                 4096                 files     
    Max open files            1024                 4096                 files     
    Max open files            1024                 4096                 files     
    Max open files            1024                 4096                 files     
    Max open files            1024                 4096                 files     
    Max open files            1024                 4096                 files     
    Max open files            1024                 4096                 files     
    Max open files            1024                 4096                 files     
    Max open files            1024                 4096                 files     
    [root@linuxangel ~]#
  • 相关阅读:
    关于事件的分发与传递
    Android直播app用什么技术可以做到延迟小一些?
    android菜鸟求教eclipse创建avd问题
    安卓APP集成支付宝,调用支付接口,直接退出程序了
    关于蓝牙socket 服务器端首次accept总出错!
    【求助】Android 4.4.2 的WebView的问题
    android 4.0.3开机时不能收到广播
    vue 应用 :关于 ElementUI 的 message 组件
    vue 应用 : 计数器组件
    vue 应用 :多语言显示
  • 原文地址:https://www.cnblogs.com/osxlinux/p/3410346.html
Copyright © 2011-2022 走看看