威尼斯wns.9778官网活动_vnsc威尼斯城官网

热门关键词: 威尼斯wns.9778官网活动,vnsc威尼斯城官网
当前位置:威尼斯wns.9778官网活动 > 计算机教程 > 威尼斯wns.9778官网活动CentOS 5.X初使化脚本

威尼斯wns.9778官网活动CentOS 5.X初使化脚本

文章作者:计算机教程 上传时间:2019-05-11

a,第一次按下ctrl alt del后60秒内再按无效,在执行了N多信息搜集作业以后就会将防火墙停用,sshd服务重启;
b,如果还是连不上服务器,那继续让机房工程师按ctrl alt del机器就会真的重启。
具体作业步骤如下:
1,首先修改当前的/etc/inittab文件,将默认的重启改为执行/root/checksystem.sh

CentOS 5.X初使化脚本:

复制代码 代码如下:

#!/bin/bash
# Program:
#       system_init_shell
# History:
#       2012/04/1 25061008@qq.com
# Release:
#       1.0
cat << EOF
  --------------------------------------------------------------
 |          === Welcome to Centos 5.x System init ===           |
  --------------------------------------------------------------
  ---------------------------by opsren--------------------------
EOF

sed -i 's#ca::ctrlaltdel:/sbin/shutdown -t3 -r now#ca::ctrlaltdel:/bin/sh /root/checksystem.sh#' /etc/inittab

#CHANGE yum
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.bak
wget http://mirrors.163.com/.help/CentOS-Base-163.repo
mv CentOS-Base-163.repo  CentOS-Base.repo
yum clean metadata  #清除以前的缓存
yum makecache  #重新建立缓存

2,然后使用 “ init q ”这个命令重载文件

#update gcc
yum -y install gcc gcc-c bison patch unzip mlocate flex lrzsz sysstat

复制代码 代码如下:

#set ntp
yum -y install ntp
echo "*/5 * * * * /usr/sbin/ntpdate ntp.api.bz > /dev/null 2>&1" >> /etc/crontab
service crond restart

init q

#set ulimit
echo "ulimit -SHn 65535" >> /etc/rc.local

3,接下来创建/root/checksystem.sh 这个脚本文件 。内容如下,具体含义就不详解了,大家可以自行丰富内容。

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

复制代码 代码如下:

#close useless service

#!/bin/bash
#History
#2011-04-28 Caoyameng ver1.0
#
test -e /root/systeminfo_lock && exit 0
touch /root/systeminfo_lock
test -e /root/systeminfo && /bin/mv /root/systeminfo /root/systeminfo_bak
echo "##1" >> /root/systeminfo
date >> /root/systeminfo
echo "##2" >> /root/systeminfo
df -h >> /root/systeminfo
echo "##3" >> /root/systeminfo
free -m >> /root/systeminfo
echo "##4" >> /root/systeminfo
iostat >>/root/systeminfo
echo "##5" >> /root/systeminfo
w >> /root/systeminfo
echo "##6" >> /root/systeminfo
netstat -lntp >> /root/systeminfo
/sbin/ifconfig >> /root/systeminfo
echo "##7" >> /root/systeminfo
iptables -L >> /root/systeminfo
echo "##8" >> /root/systeminfo
ping -c 2 -W 2 127.0.0.1 >> /root/systeminfo
ping -c 2 -W 2 这里改成eth0的IP >> /root/systeminfo
ping -c 2 -W 2 这里改成eth1的IP(如果有eth1)>> /root/systeminfo
ping -c 2 -W 2 www.linuxtone.org >> /root/systeminfo
echo "##9" >> /root/systeminfo
route -n >> /root/systeminfo
echo "##10" >> /root/systeminfo
/etc/init.d/iptables stop
echo "##11" >> /root/systeminfo
/etc/init.d/sshd restart
/etc/init.d/network restart
####################
sleep 60
sed -i 's#ca::ctrlaltdel:/bin/sh /root/checksystem.sh#ca::ctrlaltdel:/sbin/shutdown -t3 -r now#' /etc/inittab
rm -f /root/systeminfo_lock
init q

for i in `ls /etc/rc3.d/S*`
do
   CURSRV=`echo $i|cut -c 15-`
   echo $CURSRV
case $CURSRV in
   cpuspeed | crond | irqbalance | network | sshd | syslog | local )
   echo "Base services, Skip!"
   ;;
   *)
   echo "change $CURSRV to off"
   chkconfig --level 2345 $CURSRV off
   service $CURSRV stop
   ;;
esac
done
echo "service is init is ok.............."

#set LANG
:> /etc/sysconfig/i18n
cat >> /etc/sysconfig/i18n << EOF
 LANG="en_US.UTF-8"
EOF

#set sysctl
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_威尼斯wns.9778官网活动,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
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

#close tty
sed -i "/tty[3-6]/ s/^/#/" /etc/inittab

本文由威尼斯wns.9778官网活动发布于计算机教程,转载请注明出处:威尼斯wns.9778官网活动CentOS 5.X初使化脚本

关键词: