Friday, July 23, 2010

DRBD

 DRBD dùng để tạo mirror. Có nghĩa là bình thường có primary, lưu data trên đó, đồng thời nó sẽ tự động lưu sang secondary. Khi mirror die, chỉ cần active secondary lên là có ngay data.
Dùng để tích hợp vs HeartBeat ( tự động active) + Mysql

Step 1: Add Hard disks

Step 2: Copy keys from server1 to db1 db2

scp -r .ssh/ 192.168.1.51:/root/
scp -r .ssh/ 192.168.1.52:/root/

Step 3: Edit hosts file
vim /etc/hosts
192.168.1.10    server1.hbn.local       server1
192.168.1.20    server2.hbn.local       server2
192.168.1.41    web1.hbn.local          web1
192.168.1.42    web2.hbn.local          web2
192.168.1.50    db.hbn.local            db
192.168.1.51    db1.hbn.local           db1
192.168.1.52    db2.hbn.local           db2
127.0.0.1       localhost.localdomain   localhost
::1             localhost6.localdomain6 localhost6

Copy:
scp /etc/hosts db1:/etc/
scp /etc/hosts db2:/etc/

Step 4: Config LVM
fdisk -l
Create partion LVM (hex code is 8e)
Install DRBD
yum install -y drbd kmod-drbd
Config: 
vi /etc/drbd.conf
resource r0 {
    # Specify A or B or C
    protocol C;
    syncer {
        rate 50M;
    }
    disk {
        on-io-error detach;
    }
    on db1.hbn.local {
        device /dev/drbd0;
        disk /dev/sdb1;
        address 192.168.1.51:7788;
        meta-disk internal;
    }
     on db2.hbn.local {
        device /dev/drbd0;
        disk /dev/sdb1;
        address 192.168.1.52:7788;
        meta-disk internal;
    }
}
Start:
Create meta data:
modprobe drbd
dd if=/dev/zero of=/dev/sdb1 bs=1M count=128
drbdadm create-md r0
Start Service
/etc/rc.d/init.d/drbd start
cat /proc/drbd
Step 5: Test
primary:
drbdsetup /dev/drbd0 primary -o
mkfs -t ext3 /dev/drbd0
mkdir /mnt/drbd
mount /dev/drbd0 /mnt/drbd
touch /mnt/drbd/test.txt

Secondary: Mirror of Primary
On Primary:
umount /mnt/drbd
drbdadm secondary r0

Sencondary:
drbdadm primary r0
mkdir /mnt/drbd
mount /dev/drbd0 /mnt/drbd
ll /mnt/drbd
test.txt is available
Tut txt: http://www.mediafire.com/?x9cd3f9chta3o04
------------------------------------------------------------
Thanks for reading
--------------------------------------------------------------------------
All my Lab:
Linux Lab -- window and Cisco Lab
to be continued - I will update more.  
 

No comments:

Install Xposed Inspector and Frida on Genymotion

Today i had some work with android. So i need trace application. I found 2 nice tool can help me: Xposed Inspector and Frida. To setup ther...