开发者社区> 问答> 正文

我的前任是极品 + aliyun 加载数据盘脚本

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






展开
收起
ap1598f4m 2012-11-24 20:27:58 11461 0
8 条回答
写回答
取消 提交回答
  • Re我的前任是极品aliyun加载数据盘脚本
    其实按照官方的教程也很简单。只要把MNT目录改成HOME就可以了
    2012-12-11 16:26:41
    赞同 展开评论 打赏
  • Re我的前任是极品aliyun加载数据盘脚本
    不错 多宣传
    2012-11-26 21:17:52
    赞同 展开评论 打赏
  • 回 楼主(ap1598f4m) 的帖子
    楼主,这个有什么用?
    2012-11-26 15:38:08
    赞同 展开评论 打赏
  • Re我的前任是极品aliyun加载数据盘脚本
    嗯,挂载上了,要是升级套餐 把硬盘升级了.是不是又多一块数据盘啊..而且aliyun规定不能超过3块数据盘
    2012-11-26 15:11:21
    赞同 展开评论 打赏
  • 虽觉厉,仍不明
    2012-11-24 23:08:03
    赞同 展开评论 打赏
  • 看不懂的代码
    2012-11-24 22:57:11
    赞同 展开评论 打赏
  • 一个普通程序员
    广告呀
    2012-11-24 22:56:34
    赞同 展开评论 打赏
  • 没人?

    -------------------------

    回 4楼(ap6214f2r) 的帖子
    我倒~
    很煎蛋的。

    -------------------------

    回 7楼(lxy1979) 的帖子
    挂载数据。。
    2012-11-24 21:42:27
    赞同 展开评论 打赏
滑动查看更多
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载