Linux服务器应用部署前的优化脚本

    Linux生产服务器在部署应用程序前,都要对系统进行优化,没用的进程服务该关的关掉,一些基本的开发软件都要装上,避免在安装程序的时候因缺少必要的包而不能编译通过,很是麻烦。以下脚本是作者平常工作中积累的一些优化集合,写的很龊,请大家多多包涵。。

#!/bin/bash
lang=`expr substr "$LANG" 1 5`
if [ $lang = "zh_CN" ]; then
        status='启用'
else
        status='on'
fi

array=(acpid anacron cpuspeed crond network sshd syslog yum-updatesd)

for shname in `chkconfig --list |grep "3:$status" |awk '{print $1}'`
do
        if [[ !("${array[@]}" =~ "$shname") ]]; then
                echo chkconfig $shname off
                echo `service $shname stop`
                echo `chkconfig $shname off`
        fi

done

#Set timezone
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

yum install -y ntp
ntpdate -u pool.ntp.org
date

#Disable SeLinux
if [ -s /etc/selinux/config ]; then
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
fi

for packages in patch make gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap;
do yum -y install $packages; done

cat >>/etc/security/limits.conf<<eof
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
eof

cat >>/etc/sysctl.conf<<eof
fs.file-max=65535
eof

转载于:https://my.oschina.net/chinaearl/blog/112378

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值