Linux 系统优化

1. 使用yum安装常用软件:


yum install -y wget sysstat tcpdump ntp unzip vixie-cron crontabs lynx rpmforge

2. 改时区

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

运行crontab -e

01 00 * * * /usr/sbin/ntpdate 210.72.145.44

3. 关闭selinux
vi /etc/selinux/config

将SELINUX= enforcing 改为SELINUX=disabled

4. 调整最大打开文件句柄数

vi /etc/sysctl.conf,插入下行:

fs.file-max = 65535


vi /etc/security/limits.conf文件中设置最大打开文件数, 下面是一行提示:
* - nofile 65535

保存,重启。启动后 ulimit -n验证



5. 改主机名

vi /etc/sysconfig/network

HOSTNAME=**

vi /etc/hosts

127.0.0.1 **

6. 禁用ipv6

vi /etc/modprobe.conf 插入以下两句

alias net-pf-10 off
alias ipv6 off

7. 优化linux内核参数

vi /etc/sysctl.conf 最后插入以下几句

#wxd Add

net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768

8. 服务优化脚本

#!/bin/sh



for i in `ls /etc/rc3.d/S*`
do
CURSRV=`echo $i|cut -c 15-`

echo $CURSRV
case $CURSRV in
crond | irqbalance | microcode_ctl | network | random | sshd | syslog | local | iptables )
echo "Base services, Skip!"
;;
*)
echo "change $CURSRV to off"
chkconfig --level 235 $CURSRV off
service $CURSRV stop
;;
esac
done



9. 更改ssh默认连接端口,禁止root登录

cat /etc/ssh/sshd_config


Port 10082
PermitRootLogin no

你可能感兴趣的:(linux,系统优化)