初始centOS系統(tǒng)環(huán)境
#!/bin/bash
#
# 1. 在線安裝一些編譯環(huán)境
# 2. 關(guān)閉防火墻
# 3. 修改內(nèi)核參數(shù)#
#
yuminst(){
#update yum
yum -y update
#install epel EPEL 是yum的一個軟件源,里面包含了許多基本源里沒有的軟件
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
#install
yum install -y setuptool ntsysv iptables pcre-devel openssl-devel bzip2-devel xinetd lrzsz lsof system-config-securitylevel-tui system-config-network-tui apr-util xorg-x11-drv-penmount perl-DBD-MySQL bind-utils --nogpgcheck
yum install -y zip unzip --nogpgcheck
yum install -y libselinux-python python-devel
yum install -y net-snmp #net-snmp-perl net-snmp-utils net-snmp-devel
yum install -y mlocate --nogpgcheck
updatedb
yum install -y ncurses ncurses-devel bison
yum install -y glibc glibc-common glibc-devel gd gd-devel libtool libpcap libpcap-devel gdbm gdbm-devel zlib zlib-devel libxslt audit-libs-devel --nogpgcheck
yum install -y openssh openssh-server openssh-clients --nogpgcheck
yum install -y make cmake vim* gcc gcc-c++ --nogpgcheck
yum install -y nfs-utils nfs-utils-lib nfs4-acl-tools cifs-utils xfsprogs --nogpgcheck
yum install -y crontabs vixie-cron --nogpgcheck
yum install -y ntp --nogpgcheck
yum install -y telnet
#yum -y install wget
}
ser(){
/etc/init.d/crond start
chkconfig crond on
/etc/init.d/iptables stop
chkconfig iptables off
/etc/init.d/sshd start
chkconfig sshd on
setenforce 0
sed -ri 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
}
kernal(){
#內(nèi)核參數(shù)修改
modprobe nf_conntrack
echo "modprobe nf_conntrack" >> /etc/rc.local
modprobe bridge
echo "modprobe bridge" >> /etc/rc.local
echo '
net.ipv4.tcp_fin_timeout = 60
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_syncookies = 1
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 = 2
net.ipv4.tcp_synack_retries = 1
net.core.somaxconn = 32768
net.core.netdev_max_backlog = 32768
net.ipv4.tcp_max_orphans = 327680
net.nf_conntrack_max = 102400
net.netfilter.nf_conntrack_max = 102400
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' >> /etc/sysctl.conf
sysctl -p
echo ''
}
filelimit(){
#修改打開文件限制
echo 'ulimit -n 65535' >> /etc/profile
source /etc/profile
echo '* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535' >> /etc/security/limits.conf
echo '* soft nproc 65535' >> /etc/security/limits.d/90-nproc.conf
echo -e "================= 修改打開文件限制完成 ================="
}
echo "1: yum安裝基礎(chǔ)環(huán)境"
echo "2: 修改內(nèi)核參數(shù)及文件限制"
echo "3: all"
read -p "請選擇:" num
if [ -z $num ];then
echo $num
elif [ $num -eq 1 ];then
yuminst ser
elif [ $num -eq 2 ];then
kernal
filelimit
elif [ $num -eq 3 ];then
yuminst
ser
kernal filelimit
else
echo "請輸入正確選項"
exit
fi
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者