Chinaunix首页 | 论坛 | 博客
  • 博客访问: 672721
  • 博文数量: 220
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1961
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-04 21:54
文章分类

全部博文(220)

文章存档

2018年(1)

2015年(140)

2014年(79)

我的朋友

分类: 系统运维

2015-02-04 11:23:21

脚本主要用于新安装服务器系统的初始化工作,具体包括:

  1. 关闭ipv6模块
  2. 关闭selinux
  3. 让vim显示颜色
  4. 设置系统语言编码
  5. 优化系统服务
  6. 内核参数优化等。

可以根据自己的实际情况修改,可用于生产环境。原作者是NetSeek,本人做了部分修改。

#!/bin/sh
# desc: lsm03624 modified by 
#-------------------cut begin-------------------------------------------
#welcome  << EOF
+--------------------------------------------------------------+
| === Welcome to  System  === |
+--------------
+----------------------Author:NetSeek--------------------------+
EOF
#disable ipv6
cat << EOF
+--------------------------------------------------------------+
| === Welcome to Disable IPV6 === |
+--------------------------------------------------------------+
EOF  " net-pf-10 off" >> /etc/.conf
echo "alias ipv6 off" >> /etc/modprobe.conf
/sbin/ --level 35  off
echo "ipv6 is disabled!"

#disable selinux  -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
echo "selinux is disabled,you must !"

#vim
sed -i "8 s/^/alias ='vim'/" /root/.bashrc
echo 'syntax on' > /root/.vimrc

#zh_cn
sed -i -e 's/^LANG=.*/LANG="zh_CN.UTF-8"/' /etc/sysconfig/i18n
# configure  max to 52100
echo "* soft nofile 52100
* hard nofile 52100" >> /etc/security/limits.conf

#tunoff services
#--------------------------------------------------------------------------------
cat << EOF
+--------------------------------------------------------------+
| === Welcome to Tunoff services === |
+--------------------------------------------------------------+
EOF
#---------------------------------------------------------------------------------
for i in ` /etc/rc3.d/S*`
do
CURSRV=`echo $i|cut -c 15-`

echo $CURSRV
case $CURSRV in
cpuspeed | crond | irqbalance | microcode_ctl | mysqld | network |  | -fpm |  |  | syslog )
#这个启动的系统服务根据具体的应用情况设置,其中network、sshd、syslog是三项必须要启动的系统服务!
echo "Base services, Skip!"
;;
*)
echo "change $CURSRV to off"
chkconfig --level 235 $CURSRV off  $CURSRV stop
;;
esac
done  -rf /etc/.conf
echo "net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 134217728
net.ipv4.ip_local_port_range = 1024 65536
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_fin_timeout = 3
net.ipv4.tcp_tw_recycle = 1
net.core.netdev_max_backlog = 30000
net.ipv4.tcp_no_metrics_save = 1
net.core.somaxconn = 262144
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
vm.swappiness = 6" >> /etc/sysctl.conf
echo "optimizited kernel configure was done!"
阅读(1688) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~