1#!/bin/Bash2 #添加epel和rpmforge的外部yum扩展源3cd/usr/local/src4 wgethttp//Mirrors.ustc.edu.cn/fedora/epel//5/x86_64/epel-release-5-4.noarch.rpm5RPM-IVH epel-release-5-4. noarch.rpm6 wgethttp//packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm7RPM-IVH rpmforge-release-0.5.2-2. el5.rf.x86_64.rpm8 #安装gcc基础库文件以及sysstat工具9 Yum-YInstall GCC GCC-c++ vim-enhancedUnzipUnrar SysstatTen #配置ntpdate自动对时 One Yum-YInstallNTP A Echo "* * * * /usr/sbin/ntpdate ntp.api.bz >>/dev/null 2>&1">>/etc/crontab - ntpdate ntp.api.bz - Service Crond Restart the #配置文件的ulimit值 -Ulimit-shn65535 - Echo "Ulimit-shn 65535">>/etc/rc.local - Cat>>/etc/security/limits.conf <<EOF +* Soft Nofile60000 -* Hard Nofile65535 + EOF A #tune Kernel parametres (Basic system kernel optimization) at Cat>>/etc/sysctl.conf <<EOF -Net.ipv4.tcp_syncookies =1 -Net.ipv4.tcp_syn_retries =1 -Net.ipv4.tcp_tw_recycle =1 -Net.ipv4.tcp_tw_reuse =1 -Net.ipv4.tcp_fin_timeout =1 inNet.ipv4.tcp_keepalive_time = - -Net.ipv4.ip_local_port_range =1024x768 65535 to EOF +/sbin/sysctl-P -#禁用control-alt-Delete key combination to prevent accidental operation the sed-I.'[email protected]::ctrlaltdel:/sbin/shutdown-t3-r [email protected] #ca:: ctrlaltdel:/sbin/shutdown-t3-r [email Protected]'/etc/Inittab * #关闭SElinux $ sed-I.'[email protected][email protected][email protected]'/etc/selinux/ConfigPanax Notoginseng #ssh服务配置优化 - sed-i-e's/^/#/'-i-e's/^/#/'/etc/SSH/Sshd_config the sed-I.'[email protected] #UseDNS [email protected] [email protected]'/etc/SSH/Sshd_config + Service sshd Restart A #禁用ipv6地址 the Echo "alias net-pf-10 off">>/etc/modprobe. conf + Echo "alias IPv6 off">>/etc/modprobe. conf - Echo "Install Ipv6/bin/true">>/etc/modprobe. conf $ Echo "Ipv6init=no">>/etc/sysconfig/Network $ sed-I.'[email protected][email protected][email protected]'/etc/sysconfig/Network - chkconfig ip6tables off - #vim基础语法优化 the Echo "Syntax on">>/root/. VIMRC - Echo "Set Nohlsearch">>/root/. VIMRCWuyi #停用系统中不必要的服务 the chkconfig bluetooth off - chkconfig sendmail off Wu chkconfig kudzu off - chkconfig Nfslock off About chkconfig Portmap off $ chkconfig iptables off - chkconfig autofs off -ChkconfigYum-updatesd off - #重启服务器 AReboot
Linux system infrastructure installation and kernel optimization scripts after minimal installation