码迷,mamicode.com
首页 > 其他好文 > 详细

脚本编译安装DRBD

时间:2016-04-07 18:47:37      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:drbd

很粗糙的一个脚本,慢慢会进步的!


#!/bin/bash
SSH="ssh server"
for A in {1..2};do
       $SSH$A "wget http://oss.linbit.com/drbd/8.4/drbd-8.4.6.tar.gz"
       E=‘echo $?‘
      if [ E -eq 0 ];then
         $SSH$A "cd /root;wget http://oss.linbit.com/drbd/8.4/drbd-8.4.6.tar.gz;
           wget http://oss.linbit.com/drbd/drbd-utils-8.9.3.tar.gz;
         tar xf drbd-8.4.6.tar.gz;cd drbd-8.4.6;
         tar -xf drbd-utils-8.9.3.tar.gz;cd cd drbd-8.4.6;
         make KDIR=/usr/src/kernels/2.6.32-573.22.1.el6.x86_64/;
         make install;cd /root/drbd-utils-8.9.3;
         ./configure --prefix=/usr/local/drbd  --without-83support;make;make install; 
         cp /usr/local/drbd/etc/rc.d/init.d/drbd /etc/rc.d/init.d/;modprobe drbd;
         chkconfig --add drbd;chkconfig  --level2345 drbd on;ln -s /usr/local/drbd/sbin/* /usr/bin/";
     else
         $SSH$A "yum -y install wget;cd /root;wget http://oss.linbit.com/drbd/8.4/drbd-8.4.6.tar.gz;
         wget http://oss.linbit.com/drbd/drbd-utils-8.9.3.tar.gz;
         tar xf drbd-8.4.6.tar.gz;tar -xf drbd-utils-8.9.3.tar.gz;
         cd /root/drbd-8.4.6;make KDIR=/usr/src/kernels/2.6.32-573.22.1.el6.x86_64/; 
         make install;cd /root/drbd-utils-8.9.3;
         ./configure --prefix=/usr/local/drbd  --without-83support;make;make install;
         cp /usr/local/drbd/etc/rc.d/init.d/drbd /etc/rc.d/init.d/;modprobe drbd;
         chkconfig --add drbd;chkconfig  --level2345 drbd on;ln -s /usr/local/drbd/sbin/* /usr/bin/";
     fi
      D=‘echo $?‘
     if [ D -eq 0 ];then
         $SSH$A "sed -i ‘ s/^#pri-on-incon-degr/pri-on-incon-degr/‘ /etc/drbd.d/global_common.conf; 
                sed -i ‘s/^#pri-lost-after-sb/pri-lost-after-sb/‘ /etc/drbd.d/global_common.conf; 
                sed -i ‘s/^#local-io-error/local-io-error/‘ /etc/drbd.d/global_common.conf;
             sed -i ‘/#fencing[ ]resource-only/a on-io-error detach‘ /etc/drbd.d/global_common.conf;
             sed -i ‘/net[ ]{/a cram-hmac-alg "sha1";\nshared-secret "mydrbdlab";‘ /etc/drbd.d/global_common.conf";
             fi
     for H in {1..2};do
     $SSH$H ‘touch /root/leamon.res‘;
     J="echo $?"
        if [ $J -eq 0 ];then  
            echo "resource leamon {
                  on server1.com.cn {
                  device    /dev/drbd0;
                  disk      /dev/sdb1;
                  address   10.11.22.155:7789;
                  meta-disk internal;
            }
            on server2.com.cn {
                 device    /dev/drbd0;
                 disk      /dev/sdb1;
                 address   10.11.22.59:7789;
                 meta-disk internal;
            }
        }" > /root/leamon.res;
     fi
      done
       for I in {1..2};do
           $SSH$I ‘
            echo "n
            p
            1
            
            +2G
            w" | fdisk /dev/sdb‘;
       done
      for K in {1..2};do
           $SSH$k "drbdadm create-md leamon;/etc/init.d/drbd start";
     done
done

脚本编译安装DRBD

标签:drbd

原文地址:http://leamonzhang.blog.51cto.com/11334931/1761332

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!