Chinaunix首页 | 论坛 | 博客
  • 博客访问: 294608
  • 博文数量: 47
  • 博客积分: 1667
  • 博客等级: 上尉
  • 技术积分: 686
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-06 16:20
文章分类

全部博文(47)

文章存档

2013年(20)

2012年(20)

2011年(7)

分类: LINUX

2013-05-08 14:45:18

##在网上看到一个初始化脚本自己改了改
#http://kerry.blog.51cto.com/172631/555535/

#!/bin/bash


#welcome
cat << EOF
+--------------------------------------------------------------+
|         === Welcome to Centos System init ===                |
+--------------------------------------------------------------+
EOF




##Install software##
yum clean all
yum -y install man  vixie-cron  vim* 
yum -y update
#set ntp
yum -y install ntp
/bin/cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo "13 2 * * * /usr/sbin/ntpdate  time.windows.com > /dev/null 2>&1" >>  /var/spool/cron/root
service crond restart
#set ulimit
echo "ulimit -SHn 102400" >> /etc/rc.local
cat >> /etc/security/limits.conf << EOF
*           soft   nofile       65535
*           hard   nofile       65535
EOF
 
###PS1
echo 'PS1="[\u@\H \w]\\$"' >> /etc/profile




true > /etc/sysctl.conf
cat >> /etc/sysctl.conf << EOF
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 = 4294967296
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 262144
net.core.somaxconn = 262144
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 1024 65535
fs.file-max = 102400
EOF
/sbin/sysctl -p
echo "sysctl set OK!!"
#close ctrl+alt+del
sed -i "s/ca::ctrlaltdel:\/sbin\/shutdown -t3 -r now/#ca::ctrlaltdel:\/sbin\/shutdown -t3 -r now/" /etc/inittab
sed  -i '/tty3/s/^/#/'  /etc/inittab
sed  -i '/tty4/s/^/#/'  /etc/inittab
sed  -i '/tty5/s/^/#/'  /etc/inittab
sed  -i '/tty6/s/^/#/'  /etc/inittab






#disable ipv6
cat << EOF
+--------------------------------------------------------------+
|         === Welcome to Disable IPV6 ===                      |
+--------------------------------------------------------------+
EOF
echo "alias net-pf-10 off" >> /etc/modprobe.conf
echo "alias ipv6 off" >> /etc/modprobe.conf
/sbin/chkconfig --level 35 ip6tables off
echo "ipv6 is disabled!"
#disable selinux
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config 
echo "selinux is disabled,you must reboot!"
#vim
echo  'alias vi=vim' >>  /etc/profile
echo 'syntax on' > /root/.vimrc
#zh_cn
sed -i -e 's/^LANG=.*/LANG="en_US.UTF-8"/'   /etc/sysconfig/i18n
#sshd_config
sed -i '/GSSAPICleanupCredentials yes/s/^#//'  /etc/ssh/sshd_config
sed -i '/GSSAPIAuthentication yes/s/^#//'  /etc/ssh/sshd_config
sed -i "s/#Port 22/Port 10020/"       /etc/ssh/sshd_config
sed -i "s/#UseDNS yes/UseDNS no/"     /etc/ssh/sshd_config
service sshd restart
echo "ssh is init is ok.............."




#tunoff services
#--------------------------------------------------------------------------------
cat << EOF
+--------------------------------------------------------------+
|         === Welcome to Tunoff services ===                   |
+--------------------------------------------------------------+
EOF
#---------------------------------------------------------------------------------
for i in `ls -l  /etc/rc3.d/S* |awk -F '/' '!/rc.local/{print $NF}'`
do
      case $i in
crond | irqbalance | microcode_ctl | lvm2-monitor | network | random | sshd | syslog)
echo "skip $i"
;;
*)
service $i stop
chkconfig $i off
;;
esac
done
echo "service is init is ok.............."





boot.txt
阅读(3221) | 评论(0) | 转发(0) |
0

上一篇:mysql的权限验证

下一篇:没有了

给主人留下些什么吧!~~