Sohaib's Tech Blog

Something for every one

Openerp Automated Install on Centos 6.3 — 2013

Openerp Automated Install on Centos 6.3

This script installs OpenERP v7.0 on a Centos 6.3 server (minimal i386) with PostgreSQL 9.2

# Modified script from Carlos E. Fonseca Zorrilla
yum -y install wget unzip
rpm -ivh
rpm -ivh
yum -y install python-psycopg2 python-lxml PyXML python-setuptools libxslt-python pytz
python-matplotlib python-babel python-mako python-dateutil python-psycopg2
pychart pydot python-reportlab python-devel python-imaging python-vobject
hippo-canvas-python mx python-gdata python-ldap python-openid
python-werkzeug python-vatnumber pygtk2 glade3 pydot python-dateutil
python-matplotlib pygtk2 glade3 pydot python-dateutil python-matplotlib
python python-devel python-psutil python-docutils make
automake gcc gcc-c++ kernel-devel byacc flashplugin-nonfree poppler-utils pywebdav
yum -y install postgresql92-libs postgresql92-server postgresql92
service postgresql-9.2 initdb
chkconfig postgresql-9.2 on
service postgresql-9.2 start
su – postgres -c “createuser  –superuser openerp”
cd /tmp
rm -rf
cd gdata*
python install
cd /tmp
adduser openerp
DIR=”/var/run/openerp /var/log/openerp”
for NAME in $DIR
if [ ! -d $NAME ]; then
mkdir $NAME
chown openerp.openerp $NAME
rm -rf openerp*
tar -zxvf openerp-7.0-latest.tar.gz  –transform ‘s!^[^/]+($|/)!openerp1!’
cd openerp
python install
rm -rf /usr/local/bin/openerp-server
cp openerp-server /usr/local/bin
cp install/openerp-server.init /etc/init.d/openerp
cp install/openerp-server.conf /etc
chown openerp:openerp /etc/openerp-server.conf
chmod u+x /etc/init.d/openerp
chkconfig openerp on
service  openerp start


Credit goes to Openerp FORUM

Configuring a failover cluster with heartbeat + pacemaker — 2013

Configuring a failover cluster with heartbeat + pacemaker

I am going to show of how you configure heartbeat with pacemaker Active / Passive Cluster in easy word if one server goes offline second one kicks right back up.

We are using Apache2 to monitor and using Ubuntu 12.04 precise edition

Our Configuration :-



Virtual IP  ( this is our virtual IP and this is where we will point our A record in DNS )

Configuring heartbeat

1.- Edit /etc/hosts: ns1192.168.1.12 ns2

2.- Install heartbeat and pacemaker:

apt-get install heartbeat pacemaker

3.- Edit /etc/ha.d/ :

Please note file in second node must have IP of your first node so .3 IP must change.

debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694
ucast eth0
node ns1 ns2
crm respawn

On Second Node

debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694
ucast eth0
node ns1 ns2
crm respawn

4.- Edit /etc/ha.d/authkeys:

auth 1
1 crc
#2 sha1 HI!
#3 md5 Hello!

5.- Set correct file permissions to autkeys:

chmod 600 authkeys

6.- restart heartbeat:

service heartbeat restart

Configuration of pacemaker

1.- Verify the status of cluster:

crm status

root@ns1:/etc/ha.d# crm status
Last updated: Wed Jun 26 07:34:16 2013
Last change: Wed Jun 26 07:33:58 2013 via crmd on ns2
Stack: Heartbeat
Current DC: ns2 (784f096b-d035-4ef3-9b28-4d258ae52f2f) – partition with quorum
Version: 1.1.6-9971ebba4494012a93c03b40a2c58ec0eb60f50c
2 Nodes configured, unknown expected votes
0 Resources configured.

Online: [ ns1 ns2 ]

Once you have above status – its a green light to run the following commands 

crm configure property stonith-enabled=false

crm configure property expected-quorum-votes=”2″

crm configure property no-quorum-policy=ignore

crm configure rsc_defaults resource-stickiness=100

I will explain what each commands are :-

2.- Disable stonith:

crm configure property stonith-enabled=false

3.- Number of nodes for the quorum:

crm configure property expected-quorum-votes=”2″

4.- To have quorum, more than half of the total number of cluster nodes need to be online (number of nodes / 2)+1. Is not the case when a node failure occurs in a 2-node cluster.
If you want to allow the remaining node to provide all the cluster services, you need to set the no-quorum-policy to ignore:

crm configure property no-quorum-policy=ignore

5.- To prevent failback of a resource:

crm configure rsc_defaults resource-stickiness=100

6.- List of scripts for the class ocf:

crm ra list ocf

7.- Information for a script:

crm ra info ocf:IPaddr2

8.- Add an VIP to our cluster:

crm configure primitive havip1 ocf:IPaddr2 params ip= cidr_netmask=32 nic=eth1 op monitor interval=30s

9.- Check status and see that the resource havip1 is started in the first node

crm status

Adding a daemon to our cluster

1.- See the script details:

crm ra info ocf:anything

2.- Adding apache daemon to our cluster:

crm configure primitive apacheha lsb::apache2 op monitor interval=15s

3.- Setting up the resource VIP and apache are in the same node:

crm configure colocation apacheha-havip1 INFINITY: havip1 apacheha

4.- See the status of our cluster:

crm status

havip1 (ocf::heartbeat:IPaddr2): Started ns2

apacheha (lsb:apache2): Started penguin-ha2

Configuring the order of boot of the services

crm configure order ip-apache mandatory: havip1 apacheha

Migrate a resource to another node

havip1 (ocf::heartbeat:IPaddr2): Started ns1

apacheha (lsb:apache2): Started ns2

See cluster configuration:

crm configure show

Openerp Automated Install Script v7.0 — 2013

Openerp Automated Install Script v7.0

I will assume you have installed Ubuntu 12.04 precise.

There are PLENTY of resources on the web if you need detailed help with that!

Simple Openerp Installation to make your life easier

Start by updating the package index:

yes | sudo apt-get update


Then, upgrade any outdated packages:

yes| sudo apt-get upgrade


Once you have done this, you will be able to copy and paste the following into your console, or paste it into a script to run:

#create the install directory for OpenERP

sudo mkdir /opt/openerp
sudo chown ubuntu /opt/openerp
sudo chgrp ubuntu /opt/openerp
cd /opt/openerp

#install PostgreSQL

yes | sudo apt-get install postgresql

#create a postgres user for OpenERP

sudo su postgres
createuser -s -e ubuntu

#install Python dependencies

yes | sudo apt-get install python-dateutil python-docutils python-feedparser python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid python-psycopg2 python-psutil python-pybabel python-pychart python-pydot python-pyparsing python-reportlab python-simplejson python-tz python-unittest2 python-vatnumber python-vobject python-webdav python-werkzeug python-xlwt python-yaml python-zsi poppler-utils

#install GDATA

tar zxvf gdata-2.0.17.tar.gz
cd gdata-2.0.17/
sudo python install
cd ..

#install bazaar

yes | sudo apt-get install bzr
yes | sudo apt-get install bzrtools

#install the three OpenERP branches this process wil take 15 to 20 minutes

bzr co lp:openerp-web/7.0 web
bzr co lp:openobject-server/7.0 server
bzr co lp:openobject-addons/7.0 addons

#setup logfile

sudo mkdir /var/log/openerp
sudo chown ubuntu:root /var/log/openerp

#setup configuration file

sudo cp /opt/openerp/server/install/openerp-server.conf /etc/
sudo chown ubuntu: /etc/openerp-server.conf
sudo chmod 640 /etc/openerp-server.conf
sudo sed -i'' 's/db_user = .*/db_user = ubuntu/g' /etc/openerp-server.conf
sudo echo "logfile = /var/log/openerp/openerp-server.log" >> /etc/openerp-server.conf
sudo echo "addons_path=/opt/openerp/addons,/opt/openerp/web/addons" >> /etc/openerp-server.conf

#setup auto-startup

cd /etc/init.d
sudo curl -O
sudo sed -i'' 's/USER=.*/USER=ubuntu/g' /etc/init.d/openerp-server

sudo chmod 755 /etc/init.d/openerp-server
sudo chown root: /etc/init.d/openerp-server
sudo update-rc.d openerp-server defaults
sudo /etc/init.d/openerp-server start

chmod -R 777 /opt/openerp/server/openerp/

sudo reboot -h now


Full Installation will take approx 20/30 minutes let it run and grap a coffee, once its done simply login to your webserver oh yea and make sure to allow port 8069


If you see the following, it worked!



Thanks to Ursainfosystems

DRBD+Heartbeat+Mysql — 2013


MySQL high availability cluster with DRBD+Heartbeat+MySQL – You can also download the cleaner version of this document by clicking here – Download here

1) Set up hostnames and network

On all Nodes. Please copy this file on all servers/nodes

Run this on db1 and db2 server

nano /etc/hosts

##### IP’s of MySQL DB servers ##### db1 db2

Run this on db1 and db2 server

ssh-copy-id root@db2
ssh-copy-id root@db1

In my configuration I, Installed CentOS with just one hard drive on both servers and the drive I just to boot centos was 10GB therefore I have added another drive with 10GB Space space, please note each server hard drive must be identical in size other wise you will run into problems.

I am assuming you have already added a secondary disk with 10GB so lets start some serious configuration and feel yourself proud.

Following these steps and you will thank me later

[root@db1 ~]# nano /etc/selinux/config


chkconfig iptables off

Make sure your firewall is OFF – you can also do that by running setup command on your shell and follow the steps

Partion setup on both server identical same with fdisk

Once I added a drive my drive was named as /dev/sdb – please verify that before you do any thing

So in my server after I added an additional disk my drive was named as /dev/sdb which you can also verify by running fdisk –l

Lets create partition

fdisk /dev/sdb

primary partition – press p

Partition number (1-4): 1


Press t and type 8e – HIT ENTER
TYPE w to write  once done simply type


Secondary we will create some logical volume

pvcreate /dev/sdb1

vgcreate vgdb /dev/sdb1

Create Logical volume partition

lvcreate -L +10000M -n lvdb vgdb

RUN ABOVE STEP ON BOTH DB1 & DB2 Server and please make sure the drive size are exact and accurate.

Once everything is done simply reboot your server

Now the fun part J YEA BABY

rpm -Uvh

nano /etc/yum.repos.d/elrepo.repo

[elrepo] Community Enterprise Linux Repository – el6







rpm –Uvh

yum –enablerepo=elrepo install drbd83-utils kmod-drbd83 mysql mysql-server heartbeat heartbeat-pils heartbeat-stonith –y

Once installed simply run the following command as we don’t want mysql to start on boot time

chkconfig mysqld off
chkconfig heartbeat off
chkconfig drbd off

now reboot your server – PLEASE NOTE ALL ABOVE COMMANDS MUST BE RUN ON BOTH DB1 and DB2 Server.

Now your servers are up and running do the following

[root@db1 ~]modprobe drbd

[root@db2 ~]modprobe drbd

[root@db1 ~]echo “modprobe drbd” > /etc/rc.local

[root@db2 ~]echo “modprobe drbd” > /etc/rc.local

[root@db1 ~] nano /etc/drbd.conf

and delete all the lines from your current drbd.conf file and copy the following

global {usage-count no;


common {

syncer {

rate 3M;



resource r0 {

protocol C;

handlers {

split-brain “/usr/lib/drbd/ root”;

pri-on-incon-degr “/usr/lib/drbd/; /usr/lib/drbd/; echo b > /proc/sysrq-trigger ; reboot -f”;

pri-lost-after-sb “/usr/lib/drbd/; /usr/lib/drbd/; echo b > /proc/sysrq-trigger ; reboot -f”;

local-io-error “/usr/lib/drbd/; /usr/lib/drbd/; echo o > /proc/sysrq-trigger ; halt -f”;


startup {

degr-wfc-timeout 120;


disk {

on-io-error detach;


net {

# The following lines are dedicated to handle

# split-brain situations (e.g., if one of the nodes fails)

after-sb-0pri discard-zero-changes; # If both nodes are secondary, just make one of them primary

after-sb-1pri discard-secondary; # If one is primary, one is not, trust the primary node

after-sb-2pri call-pri-lost-after-sb; # If there are two primaries, make the unchanged one secondary

rr-conflict disconnect;


syncer {

rate 3M;

al-extents 257;


on {

device /dev/drbd0;

disk /dev/vgdb/lvdb;

address; #DEFINE YOUR DB1 IP

flexible-meta-disk internal;


on {

device /dev/drbd0;

disk /dev/vgdb/lvdb;

address; #DEFINE YOUR DB2 IP

flexible-meta-disk internal;




Once above file is saved – now simply copy that file to DB2 server

scp /etc/drbd.conf db2:/etc/

Run the following on both servers

echo “modprobe drbd” >> /etc/rc.local

now lets start drbd on both db1 and db2

service drbd start

Run the following commands on both db1 & db2

drbdadm create-md r0

drbdadm attach r0

drbdadm syncer r0

drbdadm connect r0

On Primary Node only

[root@db1 ~]#drbdadm — –overwrite-data-of-peer primary r0

On both Nodes: 

[root@db1 ~]#drbdadm up all

[root@db2 ~]#drbdadm up all

On Primary Node only

[root@db1 ~]#drbdadm — primary all #### ON Node one Only ####

You are done with DRBD Part – now check the sync status by

[root@db1 ~]#watch cat /proc/drbd

only on db1 ########## Primary Node ########

[root@db1 ~]#mkfs.ext3 /dev/drbd0

[root@db1 ~]#mkdir /data/

[root@db1 ~]#mount /dev/drbd0 /data/

On db2 ####### Secondry Node #######

[root@db2 ~]#mkdir /data

[root@db1 ~] nano /etc/ha.d/ ## Create this file and copy this text ##

logfacility local0
keepalive 2
#deadtime 30 # USE THIS!!!
deadtime 10
bcast eth0
#serial /dev/ttyS0
baud 19200
auto_failback off


Server db1 

 [root@db1 ~]#vi /etc/ha.d/haresources IPaddr:: drbddisk::r0 Filesystem::/dev/drbd0::/data::ext3 mysqld

Server db2:

 [root@db2 ~]#vi /etc/ha.d/haresources IPaddr:: drbddisk::r0 Filesystem::/dev/drbd0::/data::ext3 mysqld

On Both Servers:

 [root@db1 ~]#vi /etc/ha.d/authkeys

auth 3
3 md5 wcws

[root@db1 ~]#chmod 600 /etc/ha.d/authkeys

[root@db1 ~]#scp /etc/ha.d/authkeys db2:/etc/ha.d/authkeys

[root@db1 ~]#chkconfig heartbeat on

Mysql Configuration. 


cp /etc/my.cnf /etc/my.cnf.orig


vi /etc/my.cnf



# datadir=/var/lib/mysql




# Default to using old password format for compatibility with mysql 3.x

# clients (those using the mysqlclient10 compatibility package).
















Run the following command on both servers db1 & db2

chkconfig drbd on

Copy my.cnf file on db2 server

scp /etc/my.cnf db2:/etc/

 Now simply restart your server and connect your web server to your FLOATING IP which we define in haresource file i.e. – Connect to MYSQL setup your root password after you create your database In MySQL simply run this command to give grant access to your DB


In my case 212 IP is – IP of my web server


One last thing

nano /etc/aliases

go at the very bottom and on both db1 & db2 server and change root  like this


– Congrats you just setup a DRBD HIGH AVAILABILITY

Please do leave me comments and let me know what you think about this tutorial and if that help’s you – I would love to get your feedbacks.