只是一个初级脚本,不过有了它能节省很多时间。

#!/bin/bash
########################
#系统初始化脚本
########################
########################
#系统环境初始化
########################
#修改dns
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
#修改主机名称
#修改yum仓库源
yum -y install wget
cd /etc/yum.repos.d/
# 备份
mv CentOS-Base.repo CentOS-Base.repo.old
# 获取163源
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
mv CentOS6-Base-163.repo CentOS-Base.repo
# 生成缓存
yum makecache
# 更新
yum update
#同步时间和时区
yum -y install ntp
# 修改当前时区为上海
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# 同步时间并更新硬件时钟
ntpdate time.windows.com && hwclock -w
# 修改vim
yum -y install vim-enhanced
echo " alias vi='vim' "  >>  ~/.bashrc
echo "syntax on" > ~/.vimrc
#安装系统监测工具
yum -y install sysstat telnet lrzsz
# 关闭SeLinux
setenforce 0
# 优化Linux内核参数
cat < EOF >>/etc/sysctl.conf
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_tw_recycle = 1
# net.ipv4.tcp_tw_len = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
# net.ipv4.tcp_fin_timeout = 30
# net.ipv4.tcp_keepalive_time = 120
net.ipv4.ip_local_port_range = 1024 65535
EOF
################
#软件安装篇
################
mkdir /root/source
# libtool
cd /root/source
wget http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz
tar xzf libtool-2.4.2.tar.gz
cd libtool-2.4.2
./configure
make
make install
cd /root/source
# autoconf
cd /root/source
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar xzf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure
make
make install
cd /root/source
# automake
cd /root/source
wget http://ftp.gnu.org/gnu/automake/automake-1.14.tar.gz
tar xzf automake-1.14.tar.gz
cd automake-1.14
./configure
make
make install
cd /root/source
# pcre
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.gz
tar xzf pcre-8.33.tar.gz
cd pcre-8.33
./configure
make
make install
cd /root/source
# libmcypt
cd /root/source
wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmcrypt%2Ffiles%2FLibmcrypt%2F2.5.8%2F&ts=1377662988&use_mirror=jaist
tar xzf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure LDFLAGS=-ldl
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd /root/source
wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
tar xzf memcached-1.4.15.tar.gz
cd memcached-1.4.15
./configure --prefix=/usr/local/memcached-1.4.15
make
make install
ln -s /usr/local/memcached-1.4.15 /usr/local/memcached