对于一个刚安装完毕的linux系统,有如下通用的优化措施。
优化编译器
编辑/etc/profile,增加:
For CPU i686 or PentiumPro, Pentium II, Pentium III
CFLAGS='-O9 -funroll-loops -ffast-math -malign-double -mcpu=pentiumpro -march=pentiumpro -fomit-frame-pointer -fno-exceptions'
export CFLAGS
For CPU i586 or Pentium
CFLAGS='-O3 -march=pentium -mcpu=pentium -ffast-math -funroll-loops -fomit-frame-pointer -fforce-mem -fforce-addr -malign-double -fno-exceptions'
export CFLAGS
For CPU i486
CFLAGS='-O3 -funroll-all-loops -malign-double -mcpu=i486 -march=i486 -fomit-frame-pointer -fnoexceptions'
export CFLAGS
优化SWAP分区
将SWAP分区置于硬盘的开始部分,可以获得部分的系统性能提升。
优化虚拟内存系统
编辑/etc/sysctl.conf,增加或者更改如下:
# Improve file system performance
vm.bdflush = 100 1200 128 512 15 5000 500 1884 2
# Improve virtual memory performance
vm.buffermem = 80 10 60
优化文件系统
编辑/etc/sysctl.conf,增加或者更改如下:
# Improve the number of open files
fs.file-max = 8192
# Improve the number of inodes opened
fs.inode-max = 32768
此外,对于有频繁读写的文件系统,可以使用noatime的mount选项,这样,对于文件系统的读,系统不会产生对于文件节点atime信息的更新操作。
优化TCP/IP
编辑/etc/sysctl.conf,增加或者更改如下:
# Allowed local port range
net.ipv4.ip_local_port_range = 32768 61000
# Decrease the time default value for tcp_fin_timeout connection
net.ipv4.tcp_fin_timeout = 30
# Decrease the time default value for tcp_keepalive_time connection
net.ipv4.tcp_keepalive_time = 1800
# Turn off the tcp_window_scaling
net.ipv4.tcp_window_scaling = 0
# Turn off the tcp_sack
net.ipv4.tcp_sack = 0
# Turn off the tcp_timestamps
net.ipv4.tcp_timestamps = 0
优化IDE磁盘
应用hdparm命令配置IDE磁盘的32位DMA通道,可以极大的提升磁盘IO,某些情况下几乎可以提升到2倍的IO性能。具体使用参见hdparm的manual
阅读(660) | 评论(0) | 转发(0) |