亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
12下一頁
最近訪問板塊 發(fā)新帖
查看: 13273 | 回復: 17
打印 上一主題 下一主題

drbd安裝使用指南 [復制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2008-01-08 22:24 |只看該作者 |倒序瀏覽
一:概述:

DRBD 是由內(nèi)核模塊和相關(guān)腳本而構(gòu)成,用以構(gòu)建高可用性的集群。其實現(xiàn)方式是通過網(wǎng)絡(luò)來鏡像整個設(shè)備。您可以把它看作是一種網(wǎng)絡(luò)RAID。 Drbd 負責接收數(shù)據(jù),把數(shù)據(jù)寫到本地磁盤,然后發(fā)送給另一個主機。另一個主機再將數(shù)據(jù)存到自己的磁盤中。   

源碼下載http://oss.linbit.com/drbd/0.7/drbd-0.7.19.tar.gz

核心參考文檔:http://www.drbd.org/drbd-howto.html



二:主要實現(xiàn)

假設(shè)有兩臺機器nannan:192.168.0.136 需要鏡像的硬盤:/dev/hdc3

IXDBA.NET社區(qū)論壇

  root:192.168.0.139 需要鏡像的硬盤:/dev/hdc2

主服務(wù)器為192.168.0.136 簡稱為136

備份服務(wù)器為192.168.0.139 簡稱為139

平常對數(shù)據(jù)讀寫都在136上實現(xiàn),當136 down掉后可以啟動139,實現(xiàn)數(shù)據(jù)的熱備份。

真正的熱切換需要才用HA 來實現(xiàn)。



三:下載安裝

安裝環(huán)境:Red Hat Enterprise Linux AS release 4,內(nèi)核版本:2.6.9-22.EL

確認內(nèi)核源碼存在,可到http://oss.linbit.com/drbd/去載.

下載源碼注意:當前最新的drbd-8.0pre3,配置文件無法正常配置,出現(xiàn)一大堆錯誤,所以下載以前的穩(wěn)定版本。tar源碼解包后

運行:

A、make KDIR=/usr/src/linux   /*內(nèi)核所在的位置*/

/*如果你沒有更改內(nèi)核可以直接運行make,軟件會直接到/lib/module里邊去尋找系統(tǒng)環(huán)境,如果是新的內(nèi)核需要對內(nèi)核進行編譯安裝,

否則make時候會錯誤中斷掉*/

B、make install

安裝完主要生成命令:drbdsetup ,drbdadmin

和配置文件:/etc/drbd.conf ,啟動文件,/etc/init.d/drbd

模塊文件:drbd.ko(在編譯好的安裝包目錄下的drbd下可以找到)

所有命令和配置文件都可以在源碼包編譯成功的目錄下面找到。

./scripts/drbd.conf是最原始的配置文件,當/etc/drbd.conf被破壞,可以直接拷貝覆蓋掉。

C、創(chuàng)建硬件設(shè)備drbd

mknod /dev/drbd0 b 147 0

mknod /dev/drbd1 b 147 1

mknod /dev/drbd2 b 147 2

或者用shell來建立多個:

#for i in $(seq 0 15) ; do mknod /dev/drbd$i b 147 $i ; done

D、DRBD 協(xié)議說明

    A 數(shù)據(jù)一旦寫入磁盤并發(fā)送到網(wǎng)絡(luò)中就認為完成了寫入操作。

    B 收到接收確認就認為完成了寫入操作。

    C 收到寫入確認就認為完成了寫入操作。

    您還可以選擇其它參數(shù)來將數(shù)據(jù)傳輸給磁盤和網(wǎng)絡(luò)選項。更多詳情,請參見drbdsetup 手冊頁。

四:配置drbd

修改/etc/drbd.conf

主要修改了:機器名和設(shè)備名ip地址

==================================================

  on web1{

    device     /dev/drbd0;

    disk       /dev/hdc3;

    address    192.168.0.136:7788;

    meta-disk  internal;

# meta-disk is either 'internal' or '/dev/ice/name [idx]'

    #

    # You can use a single block device to store meta-data

    # of multiple DRBD's.

    # E.g. use meta-disk /dev/hde6[0]; and meta-disk /dev/hde6[1];

    # for two different resources. In this case the meta-disk

    # would need to be at least 256 MB in size.

    #

    # 'internal' means, that the last 128 MB of the lower device

    # are used to store the meta-data.

    # You must not give an index with 'internal'.

  }

on web2 {

    device    /dev/drbd0;

    disk      /dev/hdc2;

    address   192.168.0.139:7788;

    meta-disk internal;

  }

==================================================

下面是整個drbd.conf的配置文件:

注意:配置的版本是drbd-0.7.19.tar.gz,不同版本無法兼容。修改的地方就以上幾個地方和注釋,還有把除了resource r0 外的其他配置塊如resource r1等全部去掉。

也就是說

/****

on root {

    device    /dev/drbd0;

    disk      /dev/hdc2;

    address   192.168.0.139:7788;

    meta-disk internal;

  }

}

****/

后面的所有內(nèi)容全部去掉,



下面是一個完整的配置好的drbd.conf

#

# drbd.conf example

#

skip {

  As you can see, you can also comment chunks of text

  with a 'skip[optional nonsense]{ skipped text }' section.

  This comes in handy, if you just want to comment out

  some 'resource <some name> {...}' section:

  just precede it with 'skip'.

  The basic format of option assignment is

  <option name><linear whitespace><value>;

  

  It should be obvious from the examples below,

  but if you really care to know the details:

  

  <option name> :=

        valid options in the respective scope

  <value>  := <num>|<string>|<choice>|...

              depending on the set of allowed values

              for the respective option.

  <num>    := [0-9]+, sometimes with an optional suffix of K,M,G

  <string> := (<name>|\"([^\"\\\n]*|\\.)*\")+

  <name>   := [/_.A-Za-z0-9-]+

}

# global {

    # use this if you want to define more resources later

    # without reloading the module.

    # by default we load the module with exactly as many devices

    # as configured mentioned in this file.

    #

    # minor-count 5;

    # The user dialog counts and displays the seconds it waited so

    # far. You might want to disable this if you have the console

    # of your server connected to a serial terminal server with

    # limited logging capacity.

    # The Dialog will print the count each 'dialog-refresh' seconds,

    # set it to 0 to disable redrawing completely. [ default = 1 ]

    #

    # dialog-refresh 5; # 5 seconds

    # You might disable one of drbdadm's sanity check.

    # disable-ip-verification;

# }

#

# this need not be r#, you may use phony resource names,

# like "resource web" or "resource mail", too

#

resource r0 {

  protocol C;

# what should be done in case the cluster starts up in

  # degraded mode, but knows it has inconsistent data.

  incon-degr-cmd "echo '!DRBD! pri on incon-degr' | wall ; sleep 60 ; halt -f";

  startup {

    degr-wfc-timeout 120;    # 2 minutes.

  }

  disk {

  }

  net {

  }

  syncer {

    rate 10M;

    group 1;

    al-extents 257;

  }

  on web1{

    device     /dev/drbd0;

    disk       /dev/hdc3;

    address    192.168.0.136:7788;

    meta-disk  internal;

  }

  on web2 {

    device    /dev/drbd0;

    disk      /dev/hdc2;

    address   192.168.0.139:7788;

    meta-disk internal;

  }

}

=================================================



五、啟動drbd

先確認兩臺要鏡像的機器是否正常,之間的網(wǎng)絡(luò)是否通暢,需要加載的硬盤是否處于umount狀態(tài)。

A、 drbd采用的是模塊控制的方式

所以先要加載drbd.ko 模塊

在136服務(wù)器執(zhí)行:

#insmod drbd.ko 或者modprobe drbd

drbd.ko可以在編譯好的源碼包里找到。

判斷是否加載成功可以使用lsmod來查看:

#lsmod

Module     size    Used by

drbd     143088   -

有的話表示加載模塊成功

#drbdadm up all

啟動drbd服務(wù),使他掛在后臺狀態(tài)下運行.

可以使用命令netstat -an查看

有啟動端口7788,同時也監(jiān)聽對方的7788端口,來實現(xiàn)數(shù)據(jù)交換。

netstat -ant的輸出結(jié)果里有一行:

#netstat -ant

tcp        0      0 192.168.0.136:7789          0.0.0.0:*                   LISTEN



B:在139服務(wù)器執(zhí)行

#modprobe drbd

#/etc/rc.d/init.d/drbd start

netstat -atn的輸出結(jié)果,說明兩臺虛擬機的drbd服務(wù)已經(jīng)連接上了:

#netstat -ant

tcp        0      0 192.168.0.136:7789          192.168.0.139:32845         ESTABLISHED

tcp        0      0 192.168.0.136:32770         192.168.0.139:7789          ESTABLISHED

六:設(shè)置權(quán)限

drbd的基本服務(wù)都起來了,現(xiàn)在需要對主的服務(wù)器也就使192.168.0.136這臺服務(wù)器進行配置,讓他能夠?qū)rbd0設(shè)備進行讀寫。

在136機器上運行

#drbdadm -- --do-what-I-say  primary all   #設(shè)置136服務(wù)器為同步主目錄,也就是同步以136的這個分區(qū)為準.

注意命令格式需要一樣,沒有任何提示的話表示基本上成功了

#sfdisk -s

可以看見有一個硬件設(shè)備:/dev/drbd0

此時,兩臺設(shè)備之間就建立起一個鏡像,您可以查看/proc/drbd 進行核實。

# cat /proc/drbd

如果原來硬盤沒有文件系統(tǒng)的話,現(xiàn)在您可以在設(shè)備/dev/drbd0上創(chuàng)建一個文件系統(tǒng),然后把它加載到136上。

#mkfs.ext3 -j /dev/drbd0

#mkdir /mnt/gaojf

# mount /dev/drbd  /mnt/gaojf

現(xiàn)在/dev/drbd0就等于你服務(wù)器上面的一個硬件設(shè)備,你可以對他進行任何的讀寫操作。

七:drbd測試:

1:在136主服務(wù)器上:

#drbdadm primary all

#touch /mnt/gaojf/gaojf

完后,在執(zhí)行

#umount /mnt/gaojf

#drbdadm secondary all

2:接著到139備用服務(wù)器上執(zhí)行

#drbdadm primary all

#mkdir -p /mnt/gaojf

#mount /dev/drbd0 /mnt/gaojf

#ls -l /mnt/gaojf/gaojf

gaojf

Ok,沒問題,可以看到數(shù)據(jù)在136服務(wù)器寫入,在139馬上可以看到.



幾點注意的地方:

1. mount drbd設(shè)備以前必須把設(shè)備切換到primary狀態(tài)。

2. 兩個節(jié)點中,同一時刻只能有一臺處于primary狀態(tài),另一臺處于secondary狀態(tài)。

3. 處于secondary狀態(tài)的服務(wù)器上不能加載drbd設(shè)備。

4. 主備服務(wù)器同步的兩個分區(qū)大小最好相同,這樣不至于浪費磁盤空間,因為drbd磁盤鏡像相當于網(wǎng)絡(luò)raid 1.

5: 在配置過程中,如果出現(xiàn)下面錯誤

Missing argument 'meta_data_dev'

USAGE:

disk lower_dev meta_data_dev meta_data_index [{--size|-d} 0 ... 8587575296]

     [{--on-io-error|-e} {pass_on|call-local-io-error|detach}]

     [{--fencing|-f} {dont-care|resource-only|resource-and-stonith}] [{--use-bmbv|-b}]

那么就還要初始化meta-data area

drbdadm create-md r0

更詳細的參考:http://www.ixdba.net/article/5c/125.html

論壇徽章:
0
2 [報告]
發(fā)表于 2008-01-08 22:48 |只看該作者
螞蟻。我用821測試過了。這玩意兒目前來說不太可靠!

論壇徽章:
0
3 [報告]
發(fā)表于 2008-01-08 22:50 |只看該作者
確實有一定問題,對于關(guān)鍵的,大型的應(yīng)用的確不太適合,一般的應(yīng)用還是可以的。

論壇徽章:
0
4 [報告]
發(fā)表于 2008-01-09 09:02 |只看該作者
也許這個方法能解決你們說的不太可靠的問題。:)
在這種方法中我遇到的一個問題就是當集群中主節(jié)點down機或拔掉網(wǎng)線的時候,從可以順利接管主服務(wù)器,實現(xiàn)高可用,但這個時候如果你往現(xiàn)在的主(原來的從)的drbd磁盤上寫入數(shù)據(jù),那么在另一臺機器重新啟動或插上網(wǎng)線的時候,就會發(fā)生“split brain” ,這個時候drbd的數(shù)據(jù)就不是同步的了,想要同步就必須手工恢復。很奇怪的是如果沒有mount drbd就很少發(fā)生這種情況。這就好像一個半自動的高可用,我們需要經(jīng)常去監(jiān)視他是否斷掉了,那怕是重啟一臺機器都經(jīng)常會發(fā)生“split brain”,我看了drbd的文檔,里面有很多策略應(yīng)該可以避免我上面的情況,可惜我的實驗全部失敗了。希望有成功的指點我一下。
我的e文不太好,我這段幫助貼上來,e文好的自己看吧。
       -A, --after-sb-0pri asb-0p-policy
              possible policies are:

              disconnect
                     No automatic resynchronisation, simply disconnect.

              discard-younger-primary
                     Auto sync from the node that was primary before the split-  brain situation occurred.

              discard-older-primary
                     Auto sync from the node that became primary as second during the split-brain situation.

              discard-zero-changes
                     In case one node did not write anything since the split brain became evident, sync from the node that wrote something to the node that did
                     not write anything. In case none wrote anything this policy uses a random decission to perform a "resync" of 0 blocks. In case  both  have
                     written something this policy disconnects the nodes.

              discard-least-changes
                     Auto sync from the node that touched more blocks during the split brain situation.

              discard-node-NODENAME
                     Auto sync to the named node.
       -B, --after-sb-1pri asb-1p-policy
              possible policies are:

              disconnect
                     No automatic resynchronisation, simply disconnect.

              consensus
                     Discard the version of the secondary if the outcome of the after-sb-0pri algorithm would also destroy the current secondary’s data. Other-
                     wise disconnect.

              discard-secondary
                     Discard the secondary’s version.

              call-pri-lost-after-sb
                     Always honour the outcome of the after-sb-0pri
                      algorithm. In case it decides the current secondary has the right data, call the pri-lost-after-sb on the current primary.

              violently-as0p
                     Always honour the outcome of the after-sb-0pri
                      algorithm. In case it decides the current secondary has the right data, accept a possible instantaneous change of the primary’s data.

       -C, --after-sb-2pri asb-2p-policy
              possible policies are:

              disconnect
                     No automatic resynchronisation, simply disconnect.

              call-pri-lost-after-sb
                     Always honour the outcome of the after-sb-0pri
                      algorithm. In case it decides the current secondary has the right data, call the pri-lost-after-sb on the current primary.

              violently-as0p
                     Always honour the outcome of the after-sb-0pri
                      algorithm. In case it decides the current secondary has the right data, accept a possible instantaneous change of the primary’s data.

我理解的意思就是 split brain, after - sb (不知道你會不會和我的理解一樣……)
這里我解決的辦法是用一個腳本來檢測 split brain ,并自動判斷同步。
shell.1 發(fā)到啟動組里面
#!/bin/sh
PATH=$PATH:/sbin:/usr/sbin:/usr/local/bin
[ -f /proc/drbd ] || exit 1
if ( grep 'Secondary/Unknown' /proc/drbd );then
        drbdadm disconnect all
        drbdadm -- --discard-my-data connect all
        (sleep 1;echo 'drbd';sleep 2;echo 'drbd';sleep 3)|telnet 192.16.1.22
fi
shell.2 由heartbeat執(zhí)行。
#! /bin/bash
#
# chkconfig: 345 15 88
# description: Linux High availability services .

# Source function library.
. /etc/init.d/functions
[ ! -f /etc/sysconfig/network ] && exit 1
. /etc/sysconfig/network

# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0

# if the ip configuration utility isn't around we can't function.
[ -x /sbin/ip ] || exit 1;[ -f /proc/drbd ] || exit 1
DRBDSTATE=$(drbdadm state all)
while $(grep -E "SyncSource.*Inconsistent" /proc/drbd >/dev/null 2<&
   do
        sleep 10
   done

start () {
        sleep 5
        ip addr add 192.16.1.20/24 brd 192.16.3.255 dev bond0
        /etc/init.d/portmap start
        drbdadm primary all
        mount -t ext3 -o rw /dev/drbd0 /mnt/disk0
        mount -t ext3 -o rw /dev/drbd1 /mnt/disk1
        /etc/init.d/nfs start
        /etc/init.d/nfslock start
        exportfs -avr
        return $RETVAL
}
stop () {
        ip addr del 192.16.1.20/24 brd 192.16.1.255 dev bond0
        /etc/init.d/nfs stop
        /etc/init.d/nfslock stop
        umount /mnt/disk0
        umount /mnt/disk1
        drbdadm secondary all
        /etc/init.d/portmap stop
        if ( grep 'Secondary/Unknown' /proc/drbd );then
        exec /etc/rc.d/my-shell.sh;fi
        return $RETVAL
}

# See how we were called.
case "$1" in
  start|stop)
        $1
        ;;
  restart|reload)
        /etc/init.d/$0 stop
        /etc/init.d/$0 start
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload}"
        exit 1
esac

exit 0
添加用戶 drbd
passwd
drbd:105:105RBD:/home/drbd:/sbin/drbdsh
drbdsh文件
#!/bin/sh
# Variables and Function definition
PATH=$PATH:/sbin:/usr/sbin:/usr/local/bin

#Program Main
[ -f /proc/drbd ] || exit 1
TEMP=$(drbdadm state all)
D_STATE=(${TEMP//\// })
if ( echo ${D_STATE[@]}|grep Primary >/dev/null 2<&- ) && \
   ( echo ${D_STATE[@]}|grep Unknown >/dev/null 2<&- );then
        drbdadm connect all
        else exit 1
fi
exit 0
啟動 telnet
在 hosts.deny 里添加 in.telnet :ALL :ALL EXCEPT 192.16.1.22
這樣就可以保證每次啟動后數(shù)據(jù)的同步了。
下面是我的部分配置文件:
drbd.conf
global { usage-count yes; }
common { syncer { rate 10M; } }
resource r0 {
        protocol C;
        handlers { pri-on-incon-degr "halt -f"; }
        disk { on-io-error detach; }
        net {
                cram-hmac-alg sha1;
                shared-secret "800hr_disk_0";
        }
        on test01 {
                device          /dev/drbd0;
                disk            /dev/sda6;
                address         192.16.1.21:7789;
                meta-disk       internal;
        }
        on test02 {
                device          /dev/drbd0;
                disk            /dev/sda6;
                address         192.16.1.22:7789;
                meta-disk       internal;
        }
}

[ 本帖最后由 xinyv 于 2008-1-9 09:03 編輯 ]

論壇徽章:
0
5 [報告]
發(fā)表于 2008-01-09 11:57 |只看該作者
我目前也沒弄明白怎么保證數(shù)據(jù)完整性的。呵呵!所以還是等有了商業(yè)應(yīng)用看看別人用的效果吧!

[ 本帖最后由 molecar 于 2008-1-9 12:12 編輯 ]

論壇徽章:
0
6 [報告]
發(fā)表于 2008-01-19 16:28 |只看該作者
net {
        after-sb-0pri discard-older-primary;
        after-sb-1pri call-pri-lost-after-sb;
        after-sb-2pri call-pri-lost-after-sb;
}
在drbd.conf中配置如上參數(shù),也許能解決各位所遇到的split brain問題

論壇徽章:
0
7 [報告]
發(fā)表于 2008-01-21 09:43 |只看該作者
split brain是很正常的現(xiàn)象
主節(jié)點當機后,輔節(jié)點成為primary,并且有數(shù)據(jù)的改動
然后主節(jié)點重啟后,默認肯定是primary,但是又由于數(shù)據(jù)的不一致性,于是兩個primary就開始split brain了。

論壇徽章:
0
8 [報告]
發(fā)表于 2008-02-04 13:21 |只看該作者
推薦一下,這個是螞蟻原創(chuàng)的?煞窨紤]設(shè)置為精華

論壇徽章:
0
9 [報告]
發(fā)表于 2008-03-04 11:15 |只看該作者

DRBD

剛好我手上有一個菲律賓的博彩項目。數(shù)據(jù)庫采用的是MYSQL 5.0.41.用戶要求在不增加投資情況下提供高可用性。我初步測試了HEARTBEAT+DRBD+NFS+MYSQL+MON這個組合。(HEARTBEAT 2.0.8;DRBD 8.2.4,Red Hat Enterprise Linux AS release 4,內(nèi)核版本:2.6.9-34.EL

計劃滿足以下要求:
1)  service heartbeat stop
2)  kiallall heartbeat
3)  reboot
4)  拔掉生產(chǎn)網(wǎng)絡(luò)網(wǎng)線
5)  拔掉主服務(wù)器的電源線
在以上情況下,集群可以自動進行集群ip和mysql切換,同時保證數(shù)據(jù)完整性。
我參照mysql公司提供的mysql+drbd集群文檔進行了配置,同時參考了你的設(shè)置。
結(jié)論是
service heartbeat stop;kiallall heartbeat;拔掉生產(chǎn)網(wǎng)絡(luò)網(wǎng)線
以上情況是滿足我的要求的。
但是當拔掉主服務(wù)器的電源線后,備份服務(wù)器heartbeat不能啟動相應(yīng)資源。
錯誤信息:return code 20 from /etc/ha.d/resource.d/drbddisk
我分析DRBD需要兩個節(jié)點cs處于connected狀態(tài)才能設(shè)置primary狀態(tài),進而掛載/dev/drbd0設(shè)備。當拔掉主服務(wù)器的電源線后,cs肯定不是connected狀態(tài),因此不能將備份服務(wù)器drbd設(shè)置為primary狀態(tài)。從而造成heartbeat服務(wù)不能啟動相應(yīng)資源。
按照我的測試,heartbeat+mysql是可以滿足以上五個要求的(測試時未考慮數(shù)據(jù)完整性。)
我的drbd.conf
on web1{

    device     /dev/drbd0;

    disk       /dev/drbd0;

    address    10.10.10.1:7788;(使用的是心跳網(wǎng)線)

    meta-disk  internal;

  }
net {
        after-sb-0pri discard-older-primary;
        after-sb-1pri call-pri-lost-after-sb;
        after-sb-2pri call-pri-lost-after-sb;
}
ha.cf
使用ipfail,dopd同步進程
Haresources
Local139 192.168.30.249 drbddisk::r0 filesystem::.dev/drbd0::/opt/mysql/data portmap nfslock nfs mysqld
在我這里拔掉生產(chǎn)網(wǎng)絡(luò)網(wǎng)線的數(shù)據(jù)完整性已經(jīng)可以保證了。數(shù)據(jù)沒有問題。
你們在配置drbd+和heartbeat過程中能滿足我的全部用戶要求嗎?

論壇徽章:
0
10 [報告]
發(fā)表于 2008-03-12 16:18 |只看該作者
最好能讓mysql server帶數(shù)據(jù),同是正在寫入或讀取數(shù)據(jù)的時候宕機!然后再檢驗數(shù)據(jù)
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP