歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> CentOS 5.6 Linux安裝系統後的基本優化

CentOS 5.6 Linux安裝系統後的基本優化

日期:2017/2/28 15:56:29   编辑:Linux教程

1.關閉不必要的服務器

#ntsysv

保留

crond

Linux計劃任務服務

irqbalance

用於優化中斷分配,以充分利用CPU 多核

network

sshd

syslog

Linux 日志系統(重要)

2關閉iptables

#services iptables stop && chkconfig iptables off

關閉SELinux

#vim /etc/selinux/config

將文件中的selinux=""改為 desabled ,並重啟

使用setenforce 0 可以不需要重啟關閉SELinux 但是重啟後失效

3.關閉不需要的tty

#vim /etc/inittab

# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

注釋掉後4 個控制台 並執行 init q 命令生效

4.停止打印服務

#/etc/init.d/cups stop

#chkconfig cups off

5.關閉ipv6

#vim /etc/modprobe.conf

添加內容

alias net-pf-10 off

alias ipv6 off

保存退出

#echo "IPV6INIT = no" >>/etc/sysconfig/network-scripts/ifcfg-eth0

#reboot 重啟生效

6.調整Linux 的最大文件打開數

#vim /etc/rc.d/rc.local

添加內容

ulimit -SHn 65565

7關閉CentOS的寫磁盤I/O功能

一個linux文件默認有3個時間

atime:對此文件的訪問時間

ctime: 此文件的inode發生變化的時間

mtime: 此文件的修改時間

#vim /etc/fstab

/dev/sda2 /data ext3 noatime,nodiratime 0 0

8,優化Linux 下的內核tcp 參數以提高系統性能

#vim /etc/sysctl.config

添加內容

net.ipv4.tcp_fin_timeout = 30

net.ipv4.tcp_keepalive_time = 1200

net.ipv4.tcp_syncookise = 1

net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_tw_recycle = 1

net.ipv4.ip_local_port_range = 1024 65000

net.ipv4.tcp_nax_syn_backlog = 8192

net.ipv4.tcp_max_tw_buckets = 5000

#sysctl -p 生效

Copyright © Linux教程網 All Rights Reserved