linux 系统优化初始化配置
一、系统优化配置
1、修改yum源 配置国内yum源
阿里云yum源地址
#CentOS 5.x wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo #CentOS 6.x wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo #CentOS 7.x wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
163 yum 源地址
# CentOS 5.x wget http://mirrors.163.com/.help/CentOS5-Base-163.repo # CentOS 6.x wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
yum clean all
yum makecache
yum update
yum upgrade 跟新系统到最新
2、安装软件包
yum -y install lrzsz sysstat
安装后的基本调优 设置
关闭所有的服务
for vick in 'chkconfig --list|grep 3:on|awk 'print $1';do chkconfig --level 3 $vick off;done
启动服务的内容
for vick in crond network syslog sshd;do chkconfig --level 3 $vick on ;done
查看3级别的启动状态
chkconfig --list |grep 3:on
更改ssh 登入配置
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
vim /etc/ssh/sshd_config
#####vick######
Port 99 #修改ssh连接默认端口
PermitRootLogin no #禁止root远程登入
PermitEmptyPasswords no #禁止空密码登入
UseDNS no #不使用 DNS
#####vick######
sudo 设置
visudo
/root
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
vick ALL=(ALL) ALL
$PATH
vim ~/.bash_profile
source ~/.bash_profile
echo $PATH
字符集调整
echo 'LANG="zh_CN.GB18030"' > /etc/sysconfig/i18n
source /etc/sysconfig/i18n
服务器时间同步
echo '*/5 * * * * /usr/sbin/ntpdate time.windows.com >/dev/null 2>&1' >> /var/spool/cron/root
修改描述符
echo '* - nofile 65535'>> /etc/security/limits.conf
ulimit -n 查看描述符字符集大小
调整内核参数
vim /etc/sysctl.conf
net.ipv4.tcp_fin_timeout = 2
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_keepalive_time = 600
net.ipv4.ip_local_port_range = 4000 65000
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_max_tw_buckets = 360000
net.ipv4.route.gc_timeout = 100
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_synack_retries = 1
net.ipv4.ip_conntrack_max = 25000000
好记性不如烂笔头