web cluster debian

debian 7

drbd + heartbeat + drbdlinks + php5 + mysql 5.5 + apache + nginx + memcached + eAcceleration

0. vim /etc/apt/sources.list

deb http://packages.dotdeb.org wheezy all
deb-src http://packages.dotdeb.org wheezy all

 

wget http://www.dotdeb.org/dotdeb.gpg
sudo apt-key add dotdeb.gpg
sudo apt-get update

 

1. Настройка Сети
vim /etc/network/interfaces

Node1

# The secondary network interface work
allow-hotplug eth1
iface eth1 inet static
address 192.168.0.51
netmask 255.255.255.0
network 192.168.0.255
gateway 192.168.0.254
dns-nameservers 192.168.0.254

Node2

# The secondary network interface
allow-hotplug eth1
iface eth1 inet static
address 192.168.0.52
netmask 255.255.255.0
gateway 192.168.0.254
dns-nameservers 192.168.0.254

vim /etc/hosts

Node1

127.0.0.1 localhost
127.0.1.1 node1
192.168.0.50 nodewww
192.168.0.51 node1
192.168.0.52 node2

Node2

127.0.0.1 localhost
127.0.1.1 node2
192.168.0.50 nodewww
192.168.0.51 node1
192.168.0.52 node2

2. SSH frendly — делаем аналогично allnode

NOTE: You dont have to create an interface and set this IP or make a IP alias. Heartbeat
will take care of it. Automaticaly.

Now exchange and save authorized keys between node1 and node2.

Key exchange:

On node1:

Generate the key:

[root@hb_test1 ~]# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
9f:5d:47:6b:2a:2e:c8:3e:ee:8a:c2:28:5c:ad:57:79 root@hb_test1.lap.work

Pass the key to node2:
[root@hb_test1 ~]# scp .ssh/id_dsa.pub hb_test2.lap.work:/root/.ssh/authorized_keys

On node2:

Generate the key:

[root@hb_test2 ~]# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
40:66:t8:bd:ac:bf:68:38:22:60:d8:9f:18:7d:94:21 root@hb_test2.lap.work

Pass the key to node1:
[root@hb_test2 ~]# scp .ssh/id_dsa.pub hb_test1.lap.work:/root/.ssh/authorized_keys

2. Настройка времени — allnode

apt-get ntpdate ntp

tzselect, date

 

3. DRBD

vim  /etc/drbd.conf нужно разнести на несколько томов, новый том = новый порт.

apt-get install drbd8-utils drbdlinks

!!!!!!!!!! modprobe drbd >>> /etc/rc.local -на ОБЕИХ нодах.

 

global {usage-count no;
        }
common {
}

resource r0 {
        protocol C;

handlers {
        #split-brain “/usr/lib/drbd/notify-split-brain.sh root”;
        #pri-on-incon-degr “/usr/lib/drbd/notify-pri-on-incon-degr.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f”;
        #pri-lost-after-sb “/usr/lib/drbd/notify-pri-lost-after-sb.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f”;
        #local-io-error “/usr/lib/drbd/notify-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o > /proc/sysrq-trigger ; halt -f”;
}

startup {
        degr-wfc-timeout 120;
        }

disk {
        on-io-error detach;
        }
net {
#       after-sb-0pri disconnect;
#       after-sb-1pri disconnect;
#       after-sb-2pri disconnect;
#       rr-conflict disconnect;
        max-buffers 2048;
        ko-count 4;
}

syncer {
        rate 30M;
        al-extents 257;
        }

on node1 {
        device /dev/drbd0;
        disk /dev/sdb1;
        address 192.168.0.51:7788;
        flexible-meta-disk internal;
        }

on node2 {
        device /dev/drbd0;
        disk /dev/sdb1;
        address 192.168.0.52:7788;
        flexible-meta-disk internal;
        }
}

4.  Drbdlinks start | stop | status | list | monitor

vim  /etc/drbdlinks.conf

mountpoint('/drbd')
link('/etc/apache2')
link('/var/www')
#link('/usr/lib/cgi-bin')
link('/var/lib/mysql')
link('/etc/mysql')
link('/etc/php5')
link('/etc/phpmyadmin')

5.  Heartbeat

apt-get install heartbeat

vim  /etc/ha.d/ha.cf

debugfile       /var/log/ha-debug
logfile         /var/log/ha-log
logfacility     local0
keepalive       2
deadtime        10
warntime        30
initdead        60
udpport         694
auto_failback   off
node    node1
node    node2
debug   1
ucast eth1 192.168.0.52
#bcast eth1
ping 192.168.0.254

vim  /etc/ha.d/haresources

#Node1 

node1 IPaddr::192.168.0.50/24/eth1:1 drbddisk Filesystem::/dev/drbd0::/drbd::ext3 mysql apache2 drbdlinks

#Node2

node2 IPaddr::192.168.0.50/24/eth1:1 drbddisk Filesystem::/dev/drbd0::/drbd::ext3 mysql apache2 drbdlinks

vim /etc/ha.d/authkeys — на обеих нодах

auth 3
3 md5 specialshop

 

 

Источник: bestphuket.ru
  1. Пока комментариев нет.

  1. Пока что обратных ссылок нет.