shell-系統初始化腳本,只是一個初級腳本,不過有了它能節省很多時間。
#!/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