首页 > 系统服务 > 详细

linux 安装优化脚本

时间:2017-01-12 16:26:02      阅读:34      评论:0      收藏:0      [点我收藏+]

标签:linux 安装后优化

linux 服务器安装后需要优化

cat >>/server/scripts/youhua.sh<<END


#!/bin/bash

#selinux off

sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/‘ /etc/selinux/config

setenforce 0

#iptables off

/etc/init.d/iptables stop

chkconfig iptables off


#add users

useradd alvin

echo "142857"|passwd --stdin alvin

\cp /etc/sudoers /etc/sudoers.ori

echo "alvin ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers

tail -l /etc/sudoers

visudo -c


#services

#chkconfig egrep -v "crond|sshd|network|rsyslog|sysstat"|awk‘{print"chkconfig",$1,"off"}‘|bash

LANG=en

for alvin in `chkconfig --list|grep 3:on|awk ‘{print $1}‘`;do chkconfig --level 3 $alvin off;done

for alvin in crond network rsyslog sshd sysstat ;do chkconfig --level 3 $alvin on; done 

chkconfig --list|grep 3:on


#ntpdate

ntpdate times.aliyun.com

echo ‘#time sync‘ >>/var/spool/cron/root

echo ‘*/5 * * * * /usr/sbin/ntpdate times.aliyun.com >/dev/null 2>&1‘ >>/var/spool/cron/root

crontab -l


#ulimit

echo ‘* - nofile 65535‘ >>/etc/security/limits.conf

tail -l /etc/security/limits.conf


#kernel

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


#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


#yumrepo

mv /etc/yum.repos.d/CentOS-Base.repo \

/etc/yum.repos.d/CentOS-Base.repo.backup

wget -O /etc/yum.repos.d/CentOS-Base.repo \

http://mirrors.aliyun.com/repo/Centos-6.repo


mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup

wget -O /etc/yum.repos.d/epel.repo \

http://mirrors.aliyun.com/repo/epel-6.repo


#install command

yum install tree telnet dos2unix sysstat lrzsz nc nmap -y


#update system

cd /etc/pki/rpm-gpg

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*

yum update -y


END

本文出自 “知识改变命运” 博客,请务必保留此出处http://ahtornado.blog.51cto.com/4826737/1891313

linux 安装优化脚本

标签:linux 安装后优化

原文:http://ahtornado.blog.51cto.com/4826737/1891313

(0)
(0)
   
举报
评论 一句话评论(0
0条  
登录后才能评论!
© 2014 bubuko.com 版权所有 鲁ICP备09046678号-4
打开技术之扣,分享程序人生!
             

鲁公网安备 37021202000002号