High availability server dengan heartbeat + drbd di centos 6.x | Part 1

1
2302

Halo semua 😀 akhirnya waktu yang ditunggu-tunggu yaitu pembuatan tutorial untuk drbd dan heartbeat, yang mana fungsi dari dua plugin ini adalah untuk mirroring dan failover, atau banyak disebut high availability server, oke langsung saja tanpa basa-basi saya akan memaparkan apa yang sudah saya pelajari beberapa minggu ini :p hehe.

berikut ini ip yang akan digunakan pada masing-masing server

floating ip      : 192.168.1.5     <<– ip ini adalah ip bayangan biar lebih paham ikutin aja tutorialnya 😀

node1.akbar : 192.168.1.10   <<– node1.akbar adalah nama hostname dari server1

node2.akbar : 192.168.1.20   <<– node2.akbar adalah nama hostname dari server2

tambahkan repo ini pada kedua server:

su -
rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm  <<-- repo ini dibutuhkan untuk install drbd
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm  <<-- repo ini dibutuhkan untuk install heartbeat
yum update -y  <<-- jalankan untuk perintah update

install ntp jangan pada kedua server, agar waktu di kedua server sama.

yum install ntp -y
ntpdate 0.id.pool.ntp.org

setting file /etc/hosts dan tambahkan kode seperti dibawah pada server 1.

192.168.1.10	node1.akbar node1
192.168.1.20	node2.akbar node2
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

jika sudah copykan file /etc/hosts dari server1 ke server2 dengan cara seperti ini

scp /etc/hosts root@192.168.1.20:/etc/

matika selinux di kedua server, konfigurasi ada file /etc/selinux/config, rubah isinya menjadi seperti dibawah

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

install  mode text tool di kedua server, tutorialnya ada disini

jika sudah restart ke 2 server.

lalu jika sudah di restart matikan firewall, dengan cara ketikkan command setup

[root@node1 ~]# setup

lalu pilih Firewall configuration => hilangkan bintang pada [*] Enabled => ok => yes => Quit

pastikan ketika anda menginstall linux sisakan space yang tidak terpartisi pada kedua server agar bisa digunakan untuk keperluan heartbeat nanti, sisakan saja sekitar 4GB.

buat partisi baru dari space yang kita sisakan saat proses installasi centos atau dari hardisk baru yang kita pasang untuk meletakkan file yang akan di proses oleh drbd, lakukan ini pada kedua server, ingat ukuran size disknya harus sama.

[root@node1 ~]# fdisk -cu /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x9a998475.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x9a998475

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-16777215, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-16777215, default 16777215): +2G

Command (m for help): p

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x9a998475

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     4196351     2097152   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@node1 ~]#

 Last sector, +sectors or +size{K,M,G} (2048-16777215, default 16777215): +2G

+2G diatas maksudnya adalah 2Gb, setelah itu restart server.

untuk melihat partinya bisa dengan command fdisk -l dibawah ini

[root@node1 ~]# fdisk -l

Disk /dev/sda: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000dd3c9

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1785    14336000   83  Linux
/dev/sda2            1785        1916     1048576   82  Linux swap / Solaris
/dev/sda3            1916        2018      823985   83  Linux

Disk /dev/sdb: 8589 MB, 8589934592 bytes
54 heads, 48 sectors/track, 6472 cylinders
Units = cylinders of 2592 * 512 = 1327104 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x9a998475

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1619     2097152   83  Linux

yaps proses pertama selesai, jika sudah silahkan melanjutkan ke part2 .

😀 selamat mencoba

1 COMMENT