High-Availability cluster with Heartbeat/DRBD

gabriel

Joined
Jun 9, 2007
Messages
31
Likes
0
Points
0
#1
Can you please include heartbeat drbd kmod-drbd packages When I try to install I get:

--> Processing Dependency: kernel-i686 = 2.6.18-53.1.13.el5 for package: kmod-drbd
--> Finished Dependency Resolution
Error: Missing Dependency: kernel-i686 = 2.6.18-53.1.13.el5 is needed by package kmod-drbd

And I do not want to update the kernel because I have sangoma card and then is going to be pain :)

Thank you

Gabriel
 

nothings_found

Joined
Nov 5, 2007
Messages
72
Likes
0
Points
0
#2
I don't have an answer to your original question. But are you going to be nice and share you High-Availability Elastix Cluster setup with us?

:p I would Imagine to be pretty straight forward two identical servers etc and sync from Primary to Standby every few minutes.

:D
 

DStirrup

Joined
Jun 4, 2007
Messages
27
Likes
0
Points
0
#3
There is a Spanish doco that is pretty straight forward in the wiki here http://www.elastix.org/index.php?option ... elastix_es

There are a few things it doesn't cover but it is a solid enough start.

For the real info on how to get started have a look at the DRBD official site http://www.drbd.org/start.html

Be sure when searching for info that you date limit your results to the last year as V8 does things a little different.<br><br>Post edited by: DStirrup, at: 2008/03/07 19:36
 

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#4
I have read the doc.
The problem is that the files here http://repo.elastix.org/centos/5/ha/RPMS/repodata/ are not available.
And if you try to install the packages using yum you get this dependency error pointed out by gabriel.
Anyone knows where to download them??
 

zenny

Joined
Jan 20, 2008
Messages
65
Likes
0
Points
0
#5
Romancio:

I encountered the same problem like you have. I posted it here:http://www.elastix.org/index.php?option=com_joomlaboard&Itemid=26&func=view&id=5281&catid=1&limit=6&limitstart=6

Anyone could point where the packages have been moved?
 

gabriel

Joined
Jun 9, 2007
Messages
31
Likes
0
Points
0
#6
I will share with you guys :)) I want to build some howto stuff. Now I am really busy at work and also my girlfriend needs some attention. I have in mind to build few scenarios.

1. High-Availability cluster with Heartbeat/DRBD
2. Perfect PBX, file server with samba, vpn server, backup server for windows computers, firewall, dhcp server, dns etc :))
3. 4 location with with IAX2 trunks over VPN.


Gabe
 

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#7
So any info about where to find those packages??
Please admins!!
 

gabriel

Joined
Jun 9, 2007
Messages
31
Likes
0
Points
0
#8
Ok guys I can see elastix admins don`t care about us anymore :))


I create the files that you need but I don`t have where to upload. If anyone need it can email me at missnebun@gmail.com


Gabe
 

gabriel

Joined
Jun 9, 2007
Messages
31
Likes
0
Points
0
#9
Ok guys I can see elastix admins don`t care about us anymore :))


I create the files that you need but I don`t have where to upload. If anyone need it can email me at missnebun@gmail.com


Gabe
 

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#10
Hi gabriel,
Thanks a lot for the files.
I have installed them and I nearly got it.
I spent 7 hours making installation scripts for the ha cluster.
drbd is working and heartbeat too, but I see 2 main problems with the Elastix's howto. They don't include htppd nor hylafax in /etc/ha.d/haresources
So when I shutdown the primary box, the secondary takes its place, but the web interface and the faxes don't work.
I have added them myself, and I've put their folders in the drdb partition. I needed to add access in /etc/asterisk/manager.com to the real ips of the 2 machines, and it worked for some time, until I reboot one or two times. Then I get many errors because the drbd service starts too late, and asterisk, httpd mysqld and hylafax try to find their configs in an unmounted partition. I have tried to change /etc/rcX.d scripts to make drbd start previous to mysql, asterisk, hylafax, httpd, etc, and shut down the latest. But it doesn't work very well.
Can you give me some suggestions?
Do I have to change /etc/rcX.d scripts? Is that the right way?

master.sh
tar xfv rpms.tar
cd rpms
rpm -Uvh drbd-8.2.5-3.i386.rpm
rpm -Uvh drbd-km-2.6.18_8.el5-8.2.5-3.i386.rpm
rpm -Uvh OpenIPMI-libs-2.0.6-5.el5.4.i386.rpm
rpm -Uvh heartbeat-pils-2.1.3-3.el5.centos.i386.rpm
rpm -Uvh heartbeat-stonith-2.1.3-3.el5.centos.i386.rpm
rpm -Uvh PyXML-0.8.4-4.i386.rpm
rpm -Uvh heartbeat-2.1.3-3.el5.centos.i386.rpm
# This gives me this error:
# useradd: user hacluster exists
# error: %pre(heartbeat-2.1.3-3.el5.centos.i386) scriptlet failed, exit status 9
# error: install: %pre scriptlet failed (2), skipping heartbeat-2.1.3-3.el5.centos
# but if I run it a second time it installs ok.
rpm -Uvh heartbeat-2.1.3-3.el5.centos.i386.rpm

# Change the hostname
mv /etc/sysconfig/network /etc/sysconfig/network.backup
sed "s/HOSTNAME=elastix.example.com/HOSTNAME=master-elastix.example.com/g" /etc/sysconfig/network.backup > /etc/sysconfig/network

cat << EOF > /etc/drbd.conf
global { usage-count no; }
common { syncer { rate 100M; } }
resource "r0" {
protocol A;
disk { on-io-error pass_on; }
startup { wfc-timeout 5; degr-wfc-timeout 3; }
on master-elastix.example.com {
device /dev/drbd0;
disk /dev/sda3;
address 192.168.160.101:7789;
meta-disk internal;
}
on slave-elastix.example.com {
device /dev/drbd0;
disk /dev/sda3;
address 192.168.160.102:7789;
meta-disk internal;
}
}
EOF

drbdadm create-md r0
service drbd restart
service drbd status

drbdsetup /dev/drbd0 primary -o
drbdadm primary r0 # This does not work for me without the previous order
service drbd status
drbdadm state r0

mke2fs -j /dev/drbd0
mkdir /replica
cat << EOF >> /etc/fstab
/dev/drbd0 /replica ext3 defaults,noauto 0 0
EOF
mount /dev/drbd0

cd /replica
tar -zcvf etc-asterisk.tgz /etc/asterisk
tar -zxvf etc-asterisk.tgz
rm -rf /etc/asterisk
ln -s /replica/etc/asterisk /etc/asterisk
tar -zcvf var-lib-asterisk.tgz /var/lib/asterisk
tar -zxvf var-lib-asterisk.tgz
rm -rf /var/lib/asterisk
ln -s /replica/var/lib/asterisk /var/lib/asterisk
tar -zcvf usr-lib-asterisk.tgz /usr/lib/asterisk
tar -zxvf usr-lib-asterisk.tgz
rm -rf /usr/lib/asterisk
ln -s /replica/usr/lib/asterisk /usr/lib/asterisk
tar -zcvf var-spool-asterisk.tgz /var/spool/asterisk
tar -zxvf var-spool-asterisk.tgz
rm -rf /var/spool/asterisk
ln -s /replica/var/spool/asterisk /var/spool/asterisk
tar -zcvf var-lib-mysql.tgz /var/lib/mysql
tar -zxvf var-lib-mysql.tgz
rm -rf /var/lib/mysql
ln -s /replica/var/lib/mysql /var/lib/mysql
tar -zcvf var-spool.tgz /var/spool/
tar -zxvf var-spool.tgz
rm -rf /var/spool
ln -s /replica/var/spool /var/spool
tar -zcvf var-www-html.tgz /var/www/html
tar -zxvf var-www-html.tgz
rm -rf /var/www/html
ln -s /replica/var/www/html /var/www/html

cp /usr/share/doc/heartbeat-2.1.3/ha.cf /etc/ha.d/
cp /usr/share/doc/heartbeat-2.1.3/haresources /etc/ha.d/
cp /usr/share/doc/heartbeat-2.1.3/authkeys /etc/ha.d/

# Modify /etc/ha.d/ha.cf
mv /etc/ha.d/ha.cf /etc/ha.d/ha.cf.orig
cat << EOF > /etc/ha.d/ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 20
warntime 10
initdead 40
udpport 694
bcast eth0 # Linux
auto_failback on
node master-elastix.example.com
node slave-elastix.example.com
EOF

# Modify /etc/ha.d/haresources
cat << EOF > /etc/ha.d/haresources
master-elastix.example.com drbddisk::r0 Filesystem::/dev/drbd0::/replica::ext3 IPaddr::192.168.160.103/24/eth0/192.168.160.255 asterisk zaptel mysqld hylafax httpd
EOF

# Finalmente el archivo /etc/ha.d/authkeys, agregamos al final la linea:
cat << EOF > /etc/ha.d/authkeys
auth 1
1 sha1 elastix
EOF

chmod 600 /etc/ha.d/authkeys

#Configuramos heartbeat con soporte chkconfig, asi:
fuser -mk /dev/drbd0
sleep 2
umount /dev/drbd0
drbdadm secondary r0
drbdadm state r0
service drbd restart
service drbd status
chkconfig --add heartbeat
chkconfig heartbeat on
service heartbeat start
drbdadm primary r0
drbdadm state r0
reboot
slave.sh
tar xfv rpms.tar
cd rpms
rpm -Uvh drbd-8.2.5-3.i386.rpm
rpm -Uvh drbd-km-2.6.18_8.el5-8.2.5-3.i386.rpm
rpm -Uvh OpenIPMI-libs-2.0.6-5.el5.4.i386.rpm
rpm -Uvh heartbeat-pils-2.1.3-3.el5.centos.i386.rpm
rpm -Uvh heartbeat-stonith-2.1.3-3.el5.centos.i386.rpm
rpm -Uvh PyXML-0.8.4-4.i386.rpm
rpm -Uvh heartbeat-2.1.3-3.el5.centos.i386.rpm
# This gives me this error:
# useradd: user hacluster exists
# error: %pre(heartbeat-2.1.3-3.el5.centos.i386) scriptlet failed, exit status 9
# error: install: %pre scriptlet failed (2), skipping heartbeat-2.1.3-3.el5.centos
# but if I run it a second time it installs ok.
rpm -Uvh heartbeat-2.1.3-3.el5.centos.i386.rpm

# Change the hostname
mv /etc/sysconfig/network /etc/sysconfig/network.backup
sed "s/HOSTNAME=elastix.example.com/HOSTNAME=slave-elastix.example.com/g" /etc/sysconfig/network.backup > /etc/sysconfig/network

cat << EOF > /etc/drbd.conf
global { usage-count no; }
common { syncer { rate 100M; } }
resource "r0" {
protocol A;
disk { on-io-error pass_on; }
startup { wfc-timeout 5; degr-wfc-timeout 3; }
on master-elastix.example.com {
device /dev/drbd0;
disk /dev/sda3;
address 192.168.160.101:7789;
meta-disk internal;
}
on slave-elastix.example.com {
device /dev/drbd0;
disk /dev/sda3;
address 192.168.160.102:7789;
meta-disk internal;
}
}
EOF

drbdadm create-md r0
service drbd restart
sleep 2
service drbd restart
drbdadm wait-connect r0
service drbd restart
chkconfig drbd on
mv /etc/rc1.d/???drbd /etc/rc1.d/K99drbd
mv /etc/rc2.d/???drbd /etc/rc2.d/S11drbd
mv /etc/rc3.d/???drbd /etc/rc3.d/S11drbd
mv /etc/rc4.d/???drbd /etc/rc4.d/S11drbd
mv /etc/rc5.d/???drbd /etc/rc5.d/S11drbd
mv /etc/rc6.d/???drbd /etc/rc6.d/K99drbd
chmod +x /etc/init.d/drbd
service drbd restart
service drbd status
drbdadm state r0

mkdir /replica
cat << EOF >> /etc/fstab
/dev/drbd0 /replica ext3 defaults,noauto 0 0
EOF

rm -rf /etc/asterisk
ln -s /replica/etc/asterisk /etc/asterisk
rm -rf /var/lib/asterisk
ln -s /replica/var/lib/asterisk /var/lib/asterisk
rm -rf /usr/lib/asterisk
ln -s /replica/usr/lib/asterisk /usr/lib/asterisk
rm -rf /var/lib/mysql
ln -s /replica/var/lib/mysql /var/lib/mysql
rm -rf /var/spool
ln -s /replica/var/spool /var/spool
rm -rf /var/www/html
ln -s /replica/var/www/html /var/www/html

cp /usr/share/doc/heartbeat-2.1.3/ha.cf /etc/ha.d/
cp /usr/share/doc/heartbeat-2.1.3/haresources /etc/ha.d/
cp /usr/share/doc/heartbeat-2.1.3/authkeys /etc/ha.d/

# Ahora vamos a editar el archivo /etc/ha.d/ha.cf y quedaria asi:

mv /etc/ha.d/ha.cf /etc/ha.d/ha.cf.orig
cat << EOF > /etc/ha.d/ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 20
warntime 10
initdead 40
udpport 694
bcast eth0 # Linux
auto_failback on
node master-elastix.example.com
node slave-elastix.example.com
EOF

cat << EOF > /etc/ha.d/haresources
master-elastix.example.com drbddisk::r0 Filesystem::/dev/drbd0::/replica::ext3 IPaddr::192.168.160.103/24/eth0/192.168.160.255 asterisk zaptel mysqld hylafax httpd
EOF

# Finalmente el archivo /etc/ha.d/authkeys, agregamos al final la linea:
cat << EOF > /etc/ha.d/authkeys
auth 1
1 sha1 elastix
EOF

chmod 600 /etc/ha.d/authkeys

chkconfig --add heartbeat
service drbd restart
service heartbeat start
drbdadm state r0
<br><br>Post edited by: ramoncio, at: 2008/03/19 05:21
 

gabriel

Joined
Jun 9, 2007
Messages
31
Likes
0
Points
0
#11
grate job. I will show you how to built point to point vpn between location and how to create IAX trunks between sites over the vpn :) I don`t have time to create howto stuff but you are better then me on this :)) I use yahoo messengers and my ID is gabriel25ny so fell free to add me as a friend and we go from there :))


Gabe
 

gabriel

Joined
Jun 9, 2007
Messages
31
Likes
0
Points
0
#12
Ok let me come out with a script thats going to check drbd service if thats is started then start httpd mysql etc


Gabe
 

zenny

Joined
Jan 20, 2008
Messages
65
Likes
0
Points
0
#13
gabriel:

That would be wonderful. Look forward to!
 

gabriel

Joined
Jun 9, 2007
Messages
31
Likes
0
Points
0
#14
Go to /etc/rc.d/ and you'll notice rcX.d folders. The X in those directory names represent runlevels. Go to the runlevel you want to edit and you'll notice a whole bunch of files in the format SXXservice and KXXservice. The S files represent startup files and the K files represent the kill files. The important thing to note here is the XX number in those files. Those represent the order in which those files are executed. Simply make the number higher or lower to move the service around in startup or shutdown.


Hope this help and I will create the script anyway then I will have time to install DRBD.


Gabe
 

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#15
I have it working quite well now.
You must change the scripts to your needs.
drbd partition is /dev/sda3 ext you must create it previously.
You must assign ips to the nodes 192.168.160.101 and 192.168.160.102, before running the scripts.
I have done all my tests in vmware 6 using Elastix 1.0.9beta.
You will need the file rpms.tar with the needed rpms compiled by Gabriel (Thank you!). If somebody is interested let me know so I can email them (9,35mb)
Here are my latest scripts:

master.sh
Code:
# Download and install rpms
cd /usr/src/
wget --no-check-certificate http://192.168.160.222/rpms.tar
tar xfv rpms.tar
cd rpms
rpm -Uvh drbd-8.2.5-3.i386.rpm
rpm -Uvh drbd-km-2.6.18_8.el5-8.2.5-3.i386.rpm
rpm -Uvh OpenIPMI-libs-2.0.6-5.el5.4.i386.rpm
rpm -Uvh heartbeat-pils-2.1.3-3.el5.centos.i386.rpm
rpm -Uvh heartbeat-stonith-2.1.3-3.el5.centos.i386.rpm
rpm -Uvh PyXML-0.8.4-4.i386.rpm
rpm -Uvh heartbeat-2.1.3-3.el5.centos.i386.rpm
# This  gives me this error:   
# useradd: user hacluster exists
# error: %pre(heartbeat-2.1.3-3.el5.centos.i386) scriptlet failed, exit status 9
# error:   install: %pre scriptlet failed (2), skipping heartbeat-2.1.3-3.el5.centos
# but if I run it a second time it installs ok.
rpm -Uvh heartbeat-2.1.3-3.el5.centos.i386.rpm

# Change the hostname
echo  "master-elastix.example.com" >> /etc/hostname
mv /etc/sysconfig/network /etc/sysconfig/network.backup
sed "s/HOSTNAME=elastix.example.com/HOSTNAME=master-elastix.example.com/g" /etc/sysconfig/network.backup > /etc/sysconfig/network 
mv /etc/hosts /etc/hosts.backup
sed "s/HOSTNAME=elastix.example.com/HOSTNAME=master-elastix.example.com/g" /etc/hosts.backup > /etc/hosts 
sudo /bin/hostname -F /etc/hostname

# Configure /etc/drbd.conf
rm -rf /etc/drbd.conf
cat << EOF >> /etc/drbd.conf
global { usage-count no; }
common { syncer { rate 100M; } }   
resource "r0" {
protocol C; # There are A, B and C protocols. Stick with C.
#  incon-degr-cmd "echo 'DRBD Degraded!' | wall; sleep 60 ; halt -f";
# If a cluster starts up in degraded mode, it will echo a message to all
# users. It'll wait 60 seconds then halt the system.
on master-elastix.example.com {
device /dev/drbd0; # The name of our drbd device.
disk /dev/sda3;    # Partition we wish drbd to use.
address 192.168.160.101:7789; # node0 IP address and port number.
meta-disk internal; # Stores meta-data in lower portion of sdb1.
}
on slave-elastix.example.com {
device /dev/drbd0; # Our drbd device, must match node0.
disk /dev/sda3;    # Partition drbd should use.
address 192.168.160.102:7789; # IP address of node1, and port number.
meta-disk internal; #Stores meta-data in lower portion of sdb1.
}
disk { on-io-error detach; # What to do when the lower level device errors.
}

net { max-buffers 2048; #datablock buffers used before writing to disk.
ko-count 4; # Peer is dead if this count is exceeded.
#on-disconnect reconnect; # Peer disconnected, try to reconnect.
}

syncer {
rate 10M; # Synchronization rate, in megebytes. Good for 100Mb network.
#group 1;  # Used for grouping resources, parallel sync.
al-extents 257; # Must be prime, number of active sets.
}
startup {
wfc-timeout 0; # drbd init script will wait infinitely on resources.
degr-wfc-timeout 120; # 2 minutes.
}
} # End of resource r0
EOF

# Create drbd node
drbdadm create-md r0
service drbd restart 
service drbd status

# Make primary drbd node
drbdsetup /dev/drbd0 primary -o
drbdadm primary r0                     #   This does not work for me without the previous command
service drbd status
drbdadm state r0 

# Create filesystem, add it to fstab, and mount it
mke2fs -j /dev/drbd0 
mkdir /replica 
cat << EOF >>  /etc/fstab
/dev/drbd0              /replica                ext3    defaults,noauto   0 0
EOF
mount /dev/drbd0

# Create replica folder and move the data there
cd /replica 
service asterisk stop
service zaptel stop
service httpd stop
service mysqld stop
service postfix stop
tar -zcvf etc-asterisk.tgz /etc/asterisk 
tar -zxvf etc-asterisk.tgz 
rm -rf /etc/asterisk 
ln -s /replica/etc/asterisk /etc/asterisk 
tar -zcvf var-lib-asterisk.tgz /var/lib/asterisk 
tar -zxvf var-lib-asterisk.tgz 
rm -rf /var/lib/asterisk
ln -s /replica/var/lib/asterisk /var/lib/asterisk 
tar -zcvf usr-lib-asterisk.tgz /usr/lib/asterisk 
tar -zxvf usr-lib-asterisk.tgz 
rm -rf /usr/lib/asterisk
ln -s /replica/usr/lib/asterisk /usr/lib/asterisk 
tar -zcvf var-lib-mysql.tgz /var/lib/mysql 
tar -zxvf var-lib-mysql.tgz 
rm -rf /var/lib/mysql
ln -s /replica/var/lib/mysql /var/lib/mysql
tar -zcvf var-spool.tgz /var/spool/ 
tar -zxvf var-spool.tgz 
rm -rf /var/spool
ln -s /replica/var/spool /var/spool
tar -zcvf var-www-html.tgz /var/www/html 
tar -zxvf var-www-html.tgz 
rm -rf /var/www/html
ln -s /replica/var/www/html /var/www/html
tar -zcvf etc-postfix.tgz /etc/postfix
tar -zxvf etc-postfix.tgz 
rm -rf /etc/postfix
ln -s /replica/etc/postfix /etc/postfix
rm -rf *.tgz
service asterisk restart
service zaptel restart
service httpd restart
service mysqld restart
service postfix restart

# Make changes in /etc/asterisk/manager.conf to let both nodes manage asterisk
echo "permit=192.168.160.101/255.255.255.0" >> /etc/asterisk/manager.conf
echo "permit=192.168.160.102/255.255.255.0" >> /etc/asterisk/manager.conf
# Make changes in mysql to let both nodes manage mysqld
mysql --user=root --password=eLaStIx.2oo7 -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.160.%'"

# Copy config files samples
cp /usr/share/doc/heartbeat-2.1.3/ha.cf /etc/ha.d/ 
cp /usr/share/doc/heartbeat-2.1.3/haresources /etc/ha.d/ 
cp /usr/share/doc/heartbeat-2.1.3/authkeys /etc/ha.d/ 

# Configure /etc/ha.d/ha.cf
rm -rf /etc/ha.d/ha.cf
cat << EOF >> /etc/ha.d/ha.cf
keepalive 1                    # Interval between heartbeat (HB«») packets.
deadtime 10                   # How quickly HB determines a dead node.
warntime 5                    # Time HB will issue a late HB.
initdead 120                  # Time delay needed by HB to report a dead node.
udpport 694                  # UDP port HB uses to communicate between nodes.
ping 192.168.160.103       # Ping virtual host to simulate network resource.
bcast eth0                    # Which interface to use for HB packets.
auto_failback on         # Auto promotion of primary node upon return to cluster.
node master-elastix.example.com 
node slave-elastix.example.com
respawn hacluster /usr/lib/heartbeat/ipfail
# Specifies which programs to run at startup
#use_logd yes                  # Use system logging.
logfacility     local0     # This is deprecated
debugfile /var/log/ha-debug 
logfile /var/log/ha-log 
EOF

# Configure /etc/ha.d/haresources
rm -rf /etc/ha.d/haresources
cat << EOF >> /etc/ha.d/haresources
master-elastix.example.com IPaddr::192.168.160.103/24 drbddisk::r0 Filesystem::/dev/drbd0::/replica::ext3::defaults httpd asterisk zaptel mysqld postfix
EOF

# Configure  /etc/ha.d/authkeys
rm -rf /etc/ha.d/authkeys
cat << EOF >> /etc/ha.d/authkeys
auth 1 
1 sha1 unabuenapass
EOF
chmod 600 /etc/ha.d/authkeys

# Add drbd and heartbeat to init scipts
chkconfig --add drbd
chkconfig drbd on
chkconfig --add heartbeat 
chkconfig heartbeat on

# Create a script for ha-log quick access
echo "tail -f /var/log/ha-log" >> /usr/bin/ha
chmod a+x /usr/bin/ha

# Resort init.d scripts
mv /etc/rc1.d/???drbd /etc/rc1.d/K96drbd
mv /etc/rc2.d/???drbd /etc/rc2.d/S57drbd
mv /etc/rc3.d/???drbd /etc/rc3.d/S57drbd
mv /etc/rc4.d/???drbd /etc/rc4.d/S57drbd
mv /etc/rc5.d/???drbd /etc/rc5.d/S57drbd
mv /etc/rc6.d/???drbd /etc/rc6.d/K96drbd
mv /etc/rc1.d/???heartbeat /etc/rc1.d/K01heartbeat
mv /etc/rc2.d/???heartbeat /etc/rc2.d/S59heartbeat
mv /etc/rc3.d/???heartbeat /etc/rc3.d/S59heartbeat
mv /etc/rc4.d/???heartbeat /etc/rc4.d/S59heartbeat
mv /etc/rc5.d/???heartbeat /etc/rc5.d/S59heartbeat
mv /etc/rc6.d/???heartbeat /etc/rc6.d/K01heartbeat

# Show some info
service drbd status
cat /proc/drbd
service heartbeat start
service drbd status
cat /proc/drbd
slave.sh
Code:
# Download and install rpms
cd /usr/src/
wget --no-check-certificate http://192.168.160.222/rpms.tar
tar xfv rpms.tar
cd rpms
rpm -Uvh drbd-8.2.5-3.i386.rpm
rpm -Uvh drbd-km-2.6.18_8.el5-8.2.5-3.i386.rpm
rpm -Uvh OpenIPMI-libs-2.0.6-5.el5.4.i386.rpm
rpm -Uvh heartbeat-pils-2.1.3-3.el5.centos.i386.rpm
rpm -Uvh heartbeat-stonith-2.1.3-3.el5.centos.i386.rpm
rpm -Uvh PyXML-0.8.4-4.i386.rpm
rpm -Uvh heartbeat-2.1.3-3.el5.centos.i386.rpm
# This  gives me this error:   
# useradd: user hacluster exists
# error: %pre(heartbeat-2.1.3-3.el5.centos.i386) scriptlet failed, exit status 9
# error:   install: %pre scriptlet failed (2), skipping heartbeat-2.1.3-3.el5.centos
# but if I run it a second time it installs ok.
rpm -Uvh heartbeat-2.1.3-3.el5.centos.i386.rpm

# Change the hostname
echo  "slave-elastix.example.com" >> /etc/hostname
mv /etc/sysconfig/network /etc/sysconfig/network.backup
sed "s/HOSTNAME=elastix.example.com/HOSTNAME=slave-elastix.example.com/g" /etc/sysconfig/network.backup > /etc/sysconfig/network 
mv /etc/hosts /etc/hosts.backup
sed "s/HOSTNAME=elastix.example.com/HOSTNAME=slave-elastix.example.com/g" /etc/hosts.backup > /etc/hosts 
sudo /bin/hostname -F /etc/hostname

# Configure /etc/drbd.conf
rm -rf /etc/drbd.conf
cat << EOF >> /etc/drbd.conf
global { usage-count no; }
common { syncer { rate 100M; } }   
resource "r0" {
protocol C; # There are A, B and C protocols. Stick with C.
#  incon-degr-cmd "echo 'DRBD Degraded!' | wall; sleep 60 ; halt -f";
# If a cluster starts up in degraded mode, it will echo a message to all
# users. It'll wait 60 seconds then halt the system.
on master-elastix.example.com {
device /dev/drbd0; # The name of our drbd device.
disk /dev/sda31;    # Partition we wish drbd to use.
address 192.168.160.101:7789; # node0 IP address and port number.
meta-disk internal; # Stores meta-data in lower portion of sdb1.
}
on slave-elastix.example.com {
device /dev/drbd0; # Our drbd device, must match node0.
disk /dev/sda3;    # Partition drbd should use.
address 192.168.160.102:7789; # IP address of node1, and port number.
meta-disk internal; #Stores meta-data in lower portion of sdb1.
}
disk { on-io-error detach; # What to do when the lower level device errors.
}

net { max-buffers 2048; #datablock buffers used before writing to disk.
ko-count 4; # Peer is dead if this count is exceeded.
#on-disconnect reconnect; # Peer disconnected, try to reconnect.
}

syncer {
rate 10M; # Synchronization rate, in megebytes. Good for 100Mb network.
#group 1;  # Used for grouping resources, parallel sync.
al-extents 257; # Must be prime, number of active sets.
}
startup {
wfc-timeout 0; # drbd init script will wait infinitely on resources.
degr-wfc-timeout 120; # 2 minutes.
}
} # End of resource r0
EOF

# Create node and sync with master drbd node
drbdadm create-md r0
service drbd restart
sleep 2
drbdadm wait-connect r0
service drbd restart
chkconfig --add drbd
chkconfig drbd on
service drbd status
drbdadm state r0

# Create filesystem, add it to fstab, but don't mount it
mkdir /replica 
cat << EOF >> /etc/fstab
/dev/drbd0              /replica                ext3    defaults,noauto   0 0
EOF

# Delete folders and create links to the drbd partition
rm -rf /etc/asterisk 
ln -s /replica/etc/asterisk /etc/asterisk 
rm -rf /var/lib/asterisk
ln -s /replica/var/lib/asterisk /var/lib/asterisk 
rm -rf /usr/lib/asterisk
ln -s /replica/usr/lib/asterisk /usr/lib/asterisk 
rm -rf /var/lib/mysql
ln -s /replica/var/lib/mysql /var/lib/mysql
rm -rf /var/spool
ln -s /replica/var/spool /var/spool
rm -rf /var/www/html
ln -s /replica/var/www/html /var/www/html
rm -rf /etc/postfix
ln -s /replica/etc/postfix /etc/postfix

# Copy config files samples
cp /usr/share/doc/heartbeat-2.1.3/ha.cf /etc/ha.d/ 
cp /usr/share/doc/heartbeat-2.1.3/haresources /etc/ha.d/ 
cp /usr/share/doc/heartbeat-2.1.3/authkeys /etc/ha.d/ 

# Configure /etc/ha.d/ha.cf
rm -rf /etc/ha.d/ha.cf
cat << EOF >> /etc/ha.d/ha.cf
keepalive 1                    # Interval between heartbeat (HB«») packets.
deadtime 10                   # How quickly HB determines a dead node.
warntime 5                    # Time HB will issue a late HB.
initdead 120                  # Time delay needed by HB to report a dead node.
udpport 694                  # UDP port HB uses to communicate between nodes.
ping 192.168.160.103       # Ping virtual host to simulate network resource.
bcast eth0                    # Which interface to use for HB packets.
auto_failback on         # Auto promotion of primary node upon return to cluster.
node master-elastix.example.com 
node slave-elastix.example.com
respawn hacluster /usr/lib/heartbeat/ipfail
# Specifies which programs to run at startup
#use_logd yes                  # Use system logging.
logfacility     local0     # This is deprecated
debugfile /var/log/ha-debug 
logfile /var/log/ha-log 
EOF
   
# Configure /etc/ha.d/haresources
rm -rf /etc/ha.d/haresources
cat << EOF >> /etc/ha.d/haresources
master-elastix.example.com IPaddr::192.168.160.103/24 drbddisk::r0 Filesystem::/dev/drbd0::/replica::ext3::defaults httpd asterisk zaptel mysqld postfix
EOF

# Configure  /etc/ha.d/authkeys
rm -rf /etc/ha.d/authkeys
cat << EOF >> /etc/ha.d/authkeys
auth 1 
1 sha1 unabuenapass
EOF
chmod 600 /etc/ha.d/authkeys

# Create a script for ha-log quick access
echo "tail -f /var/log/ha-log" >> /usr/bin/ha
chmod a+x /usr/bin/ha

# Configure heartbeat with chkconfig
chkconfig --add heartbeat 
service drbd restart
service heartbeat start
drbdadm state r0

# Resort init.d scripts
mv /etc/rc1.d/???drbd /etc/rc1.d/K96drbd
mv /etc/rc2.d/???drbd /etc/rc2.d/S57drbd
mv /etc/rc3.d/???drbd /etc/rc3.d/S57drbd
mv /etc/rc4.d/???drbd /etc/rc4.d/S57drbd
mv /etc/rc5.d/???drbd /etc/rc5.d/S57drbd
mv /etc/rc6.d/???drbd /etc/rc6.d/K96drbd
mv /etc/rc1.d/???heartbeat /etc/rc1.d/K01heartbeat
mv /etc/rc2.d/???heartbeat /etc/rc2.d/S59heartbeat
mv /etc/rc3.d/???heartbeat /etc/rc3.d/S59heartbeat
mv /etc/rc4.d/???heartbeat /etc/rc4.d/S59heartbeat
mv /etc/rc5.d/???heartbeat /etc/rc5.d/S59heartbeat
mv /etc/rc6.d/???heartbeat /etc/rc6.d/K01heartbeat
I have some problems with email and fax in Elastix.
They are not stored in mysql databases.
Can somebody tell me wich files and services should I include in the drbd disk for these to work??
I have problems with hylafax too, so I haven't included the service in the heartbeat config files.
I think it is because when you stop the service doesn't completely close all the fax subprocesses or something like that...

Any help will be appreciated.<br><br>Post edited by: ramoncio, at: 2008/03/20 12:28
 

mesbah

Joined
Jul 10, 2008
Messages
3
Likes
0
Points
0
#16

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#17
Hi mesbah,
I have tried to email you the files but I get an error saying it exceeds your mailbox limits.
The zip file is less than 9mb.
If you give me another email address with more capacity I'll send them to you.
 

mesbah

Joined
Jul 10, 2008
Messages
3
Likes
0
Points
0
#18

gah242s

Joined
Aug 11, 2008
Messages
9
Likes
0
Points
0
#19
ramoncio,

Awesome job on the scripts. They look clean and simple to implement. Are they working with the 1.1 ISO files still? Also did you get the fax and e-mail bugs worked out? I would love to get a copy if it is still working.

Also, just a couple of minor suggestions. First off, what about changing the scripts to ask for the ip addresses of the master and slave boxes when the script starts? Also, utilizing ssh/scp, it should be possible to run both the master and slave scripts from the master server. This could even be put into a web front end, very easily I would imagine, by someone who is familiar with the web programming. (Although, running a script from a web page as root could get a little tricky.) This would make a slick, easy configuration of redundant boxes and put Elastix even further up the top of the mountain as the best pre-configured Asterisk solution.

Secondly, what would it take to make it so that the script wasn't so dependent on those exact versions of software? Could the config files be written in a patch style or maybe make the changes via a grep/awk line?

I know enough to know that these are some pretty monumental steps to take, maybe more even in the idea of upkeep than original creation. However, I do believe that this would go a long way towards making Elastix and even Asterisk a much stronger force. Being a new Elastix downloader, I am not sure how much help I would be, especially since it has been a few years since I have done any serious programming. But I would do what little I could.

Thanks,

Greg Harris
 

techieg

Joined
Oct 8, 2007
Messages
81
Likes
0
Points
0
#20
ramoncio said:
Hi mesbah,
I have tried to email you the files but I get an error saying it exceeds your mailbox limits.
The zip file is less than 9mb.
If you give me another email address with more capacity I'll send them to you.
Hey Ramoncio,

Can you please post a link to the files so others can download and use as well as for the Elastix developers to be able to integrate this feature into Elastix.

Thanx.
 

Members online

Latest posts

Forum statistics

Threads
30,902
Messages
130,887
Members
17,566
Latest member
Fpino
Top