标签:linux优化!
linux 优化!!!172.16.1.5?????? lb01
172.16.1.6?????lb02
172.16.1.7?????web01
172.16.1.8?????web02
172.16.1.9?????web03
172.16.1.51?????db01?db01.tsbk.org
172.16.1.31?????nfs01
172.16.1.41?????backup
172.16.1.61?????m01
(1)yum repolist 查看系统源
(2)备份你的原镜像文件,以免出错后可以恢复
touch /etc/yum.repos.d/CentOS-Base.repo.backup
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
(3)下载新的CentOS-Base.repo 到/etc/yum.repos.d/
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
(4)清除yum缓存
yum clean all
(5)yum repolist 查看是否已更新
setenforce 0 临时关闭防火墙
/etc/sysconfig/selinux 配置文件修改
/etc/init.d/iptables stop
chkconfig iptables off 关闭iptables开机自启动
chkconfig|egrep?-v?"crond|sshd|network|rsyslog|sysstat"|awk?‘{print?"chkconfig",$1,"off"}‘|bash
useradd oldboy
echo 123456|passwd --stdin oldboy
\cp /etc/sudoers /etc/sudoers.ori
echo "oldboy ALL=(ALL) NOPASSWD: ALL " >>/etc/sudoers
tail -1 /etc/sudoers
visudo -c
ntpdate ntp1.aliyun.com 时间同步
crontab -e 配置定时任务
cp /etc/sysconfig/i18n /etc/sysconfig/i18n.ori
echo ‘LANG="en_US.UTF-8"‘ >/etc/sysconfig/i18n
source /etc/sysconfig/i18n
echo $LANG
默认描述文件数为1024个,建议调大点为65535
ulimit -a 查看文件数
ulimit -n 65535 临时修改文件描述数量
/etc/security/limits.conf 配置文件
echo ‘* - nofile 65535 ‘ >>/etc/security/limits.conf 永久修改文件描述数量
(1)sysctl.conf 优化
cat?>>/etc/sysctl.conf<<EOF
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?=?36000
net.ipv4.route.gc_timeout?=?100
net.ipv4.tcp_syn_retries?=?1
net.ipv4.tcp_synack_retries?=?1
net.core.somaxconn?=?16384
net.core.netdev_max_backlog?=?16384
net.ipv4.tcp_max_orphans?=?16384
(2)iptables优化
#以下参数是对iptables防火墙的优化,防火墙不开会提示,可以忽略不理。
net.nf_conntrack_max?=?25000000
net.netfilter.nf_conntrack_max?=?25000000
net.netfilter.nf_conntrack_tcp_timeout_established?=?180
net.netfilter.nf_conntrack_tcp_timeout_time_wait?=?120
net.netfilter.nf_conntrack_tcp_timeout_close_wait?=?60
net.netfilter.nf_conntrack_tcp_timeout_fin_wait?=?120
EOF
sysctl?-p
yum install lrzsz nmap tree dos2unix nc telnet sl -y
(1)sed -i.bak ‘s@#UseDNS yes@UseDNS no@g;s@^GSSAPIAuthentication yes@GSSAPIAuthentication no@g‘ /etc/ssh/sshd_config
(2)/etc/init.d/sshd reload 重启sshd
mkdir /server/{scripts,tools} /application -p
标签:linux优化!
原文地址:http://blog.51cto.com/13520779/2084520