HI,大家好。
好久没来发帖了。来了就发个自己玩的小站——我的前任是极品.点开 http://istandout.com.cn .
看到一个脚本不错,发给大家,这个脚本可以在REDHAT,CENTOS 下用。
1.将数据盘加载到/home
2.将REDHAT的yum 更新换成163的啦。你懂的,为什么要换。
3.如何使用,我说下把:a. vim aliyun.sh;b,把以下代码粘贴到aliyun.sh里;c,chmod -R 777 aliyun.sh;d. ./aliyun.sh 就是这样了。。
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH
if [ $(id -u) != "0" ]; then
printf "Error: You must be root to run this script!"
exit 1
fi
#echo "---------- Check the distribution ----------"
if cat /proc/version | grep -qi redhat;then
DISTRIBUTION="redhat"
elif cat /proc/version | grep -qi centos;then
DISTRIBUTION="centos"
else
exit 0
fi
echo "---------- Set the software repos ----------"
if [ "$DISTRIBUTION" = "redhat" ];then
sed -i 's#\[main\]#\[main\]\nmultilib_policy=best#g' /etc/yum.conf
mv /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/rhel-debuginfo.repo.bak
wget -c http://mirrors.163.com/.help/CentOS5-Base-163.repo -P /etc/yum.repos.d/
sed -i 's/$releasever/5/g' /etc/yum.repos.d/CentOS5-Base-163.repo
sed -i 's/$basearch/x86_64/g' /etc/yum.repos.d/CentOS5-Base-163.repo
yum makecache
/etc/init.d/iptables stop
chkconfig iptables off
elif [ "$DISTRIBUTION" = "centos" ];then
sed -i 's/^exclude/#exclude/' /etc/yum.conf
yum makecache
/etc/init.d/iptables stop
chkconfig iptables off
fi
echo "---------- Set the sysctl ----------"
if [ "$DISTRIBUTION" = "redhat" ] || [ "$DISTRIBUTION" = "centos" ];then
cat >> /etc/sysctl.conf <<EOF
fs.file-max=65535
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 5
net.ipv4.tcp_syn_retries = 5
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
#net.ipv4.tcp_keepalive_time = 120
net.ipv4.ip_local_port_range = 1024 65535
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 5010 641280 5010 128
net.core.wmem_default=262144
net.core.wmem_max=262144
net.core.rmem_default=4194304
net.core.rmem_max=4194304
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_window_scaling = 0
net.ipv4.tcp_sack = 0
EOF
sysctl -p
fi
echo "---------- Set the ulimit ----------"
cat >> /etc/security/limits.conf <<EOF
* soft nofile 65535
* hard nofile 65535
EOF
echo "---------- fdisk disk ----------"
if [ -e /dev/xvdb ];then
fdisk /dev/xvdb << EOF
n
p
1
wq
EOF
mkfs.ext3 /dev/xvdb1
echo '/dev/xvdb1 /home ext3 defaults 1 2' >> /etc/fstab
mount -a
fi
-------------------------
-------------------------
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。