How To Cluster Odoo 12 With PostgreSQL Streaming Replication For High Availability - Severalnines
How To Cluster Odoo 12 With PostgreSQL Streaming Replication For High Availability - Severalnines
Login / Sign up
PRODUCT
DOWNLOAD
PRICING PLANS
RESOURCES
SUPPORT
BLOG
ABOUT US
LOGIN / SIGN UP
SUBSCRIBE FOR NEWSLETTER
Back to Home Page Filters Subscribe
Blog
How to Cluster Magento, nginx Odoo (formerly known as OpenERP) is a suite of open-source business apps. It
and MySQL on Multiple Servers
for High Availability comes in two versions - community and enterprise. Some of the most popular
apps (and free!) integrated within this platform are Discuss, CRM, Inventory,
Blog
Scaling Wordpress and MySQL
Website, Employee, Leaves, Recruitment, Expenses, Accounting, Invoicing, Point of
on Multiple Servers for
Sale and many more.
Performance
In this blog post, we’ll look at how to cluster Odoo to achieve high availability and
Blog
Scaling Drupal on Multiple scalability. This post is similar to our previous posts on scaling Drupal, WordPress,
Servers with Galera Cluster for
MySQL Magento. The softwares used are Odoo 12, HAProxy 1.8.8, Keepalived 1.3.9,
PostgreSQL 11 and OCFS2 (Oracle Cluster File System).
odoo1 - 192.168.55.111
odoo2 - 192.168.55.112
All nodes are running on Ubuntu 18.04.2 LTS (Bionic). We will be using
ClusterControl to deploy and manage PostgreSQL, Keepalived and HAProxy as it’ll
save us a bunch of work. ClusterControl will be co-located with HAProxy on lb1
while we will add an additional disk to lb2 to be used as a shared storage provider.
This disk will be mounted using a clustered file system called OCFS2 as a shared
directory. A virtual IP address, 192.168.55.100 acts as the single endpoint for our
database service.
https://severalnines.com/database-blog/how-cluster-odoo-12-postgresql-streaming-replication-high-availability 1/13
8/26/2021 How to Cluster Odoo 12 with PostgreSQL Streaming Replication for High Availability | Severalnines
Login / Sign up
PRODUCT
DOWNLOAD
PRICING PLANS
RESOURCES
SUPPORT
BLOG
ABOUT US
LOGIN / SIGN UP
SUBSCRIBE FOR NEWSLETTER
Back to Home Page Filters Subscribe
1 $ wget severalnines.com/downloads/cmon/install-cc
2 $ chmod 755 ./install-cc
3 $ sudo ./install-cc
Follow the installation wizard, you will need to answer some questions during the
process.
Setup passwordless SSH from ClusterControl node (lb1) to all nodes that will be
managed by ClusterControl, which is lb1 (itself), lb2, postresql1 and postgresql2.
But first, generate a SSH key:
1 $ whoami
2 ubuntu
3 $ ssh-keygen -t rsa # press Enter on all prompts
Then copy the key to all target nodes using ssh-copy-id tool:
1 $ whoami
2 ubuntu
3 $ ssh-copy-id ubuntu@lb1
4 $ ssh-copy-id ubuntu@lb2
5 $ ssh-copy-id ubuntu@postgresql1
6 $ ssh-copy-id ubuntu@postgresql2
https://severalnines.com/database-blog/how-cluster-odoo-12-postgresql-streaming-replication-high-availability 2/13
8/26/2021 How to Cluster Odoo 12 with PostgreSQL Streaming Replication for High Availability | Severalnines
Login / Sign up
PRODUCT
DOWNLOAD
PRICING PLANS
RESOURCES
SUPPORT
BLOG
ABOUT US
LOGIN / SIGN UP
SUBSCRIBE FOR NEWSLETTER
Back to Home Page Filters Subscribe
User: postgres
Password: s3cr3t
Version: 11
Under the last section "Deployment Summary" you have an option to enable
synchronous replication. Since we will use the slave only for failover purposes (the
slave won't serve any read operations), we just leave the default value as it is.
https://severalnines.com/database-blog/how-cluster-odoo-12-postgresql-streaming-replication-high-availability 3/13
8/26/2021 How to Cluster Odoo 12 with PostgreSQL Streaming Replication for High Availability | Severalnines
Then, press "Deploy" to start the database cluster deployment. You may monitor
Login / Sign up
PRODUCT
DOWNLOAD
PRICING PLANS
RESOURCES
Cluster: ABOUT US
LOGIN / SIGN UP
SUBSCRIBE FOR NEWSLETTER
Back to Home Page Filters Subscribe
Meanwhile, grab some coffee and the cluster deployment should be completed
within 10~15 minutes.
The next step is to deploy the load balancer tier for our database, which allows us
to tie it up virtual IP address and provide single endpoint for the application. We
will configure the HAProxy deployment options as the below:
The application does not support read-write splitting natively so we will use active-
passive method to achieve high availability. The best load balancing algorithm is
https://severalnines.com/database-blog/how-cluster-odoo-12-postgresql-streaming-replication-high-availability 4/13
8/26/2021 How to Cluster Odoo 12 with PostgreSQL Streaming Replication for High Availability | Severalnines
the "source" policy, since we are only using one PostgreSQL node at a time.
Login / Sign up
PRODUCT
DOWNLOAD
PRICING PLANS
RESOURCES
SUPPORT
BLOG
ABOUT US
Repeat the same step for the other load balancer, lb2. Change the "Server
LOGIN / SIGN UP
SUBSCRIBE FOR NEWSLETTER
Back to Home Page Address" to 192.168.55.102 instead. Here is what it looks
Filters like it after the
Subscribe
The red line on the first listener is expected where HAProxy shows postgresql2
(192.168.55.122) is down because the health check script returns the node is up
but not a master. The second listener with blue line (haproxy_5434_ro) shows the
node is UP but in "backup" state. This listener can be ignored though since the
application does not support read-write splitting.
Next, we deploy Keepalived instances on top of these load balancers to tie them
up with a single virtual IP address. Go to Manage -> Load Balancer -> Keepalived ->
Deploy Keepalived and specify the first and second HAProxy instances, then the
virtual IP address and network interface to listen to:
https://severalnines.com/database-blog/how-cluster-odoo-12-postgresql-streaming-replication-high-availability 5/13
8/26/2021 How to Cluster Odoo 12 with PostgreSQL Streaming Replication for High Availability | Severalnines
PRODUCT
DOWNLOAD
PRICING PLANS
RESOURCES
SUPPORT
BLOG
ABOUT US
The
LOGIN / SIGN UPstorage
server (lb2)
SUBSCRIBE needs to export
FOR NEWSLETTER a disk through iSCSI so it can be mounted
Back to Home Page Filters Subscribe
on both Odoo application servers (odoo1 and odoo2). iSCSI basically tells your
kernel you have a SCSI disk, and it transports that access over IP. The “server” is
called the “target” and the “client” that uses that iSCSI device is the “initiator”.
It is preferred to have a separate disk for file system clustering. Thus, we are going
to use another disk mounted in lb2 (/dev/sdb) to be shared among application
servers (odoo1 and odoo2). Firstly, create an iSCSI target using tgtadm tool:
1 $ sudo tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2019-02.lb2:odcfs2
Then, assign the block device /dev/sdb to logical unit number (LUN) 1 together
with target ID 1:
1 $ sudo tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sdb
Then, allow the initiator nodes on the same network to access this target:
1 $ sudo tgtadm --lld iscsi --op bind --mode target --tid 1 --initiator-address 192.1
Use tgt-admin tool to dump the iSCSI configuration lines and save it as a
configuration file to make it persistent across restart:
If you
LOGIN / SIGN UP
seeSUBSCRIBE
similar result as above, it means we can see and able to connect to the
FOR NEWSLETTER
Back to Home Page Filters Subscribe
iSCSI target. Use the following command to connect to the iSCSI target on lb2:
Make sure you can see the new hard disk (/dev/sdb) listed under /dev directory:
1 $ sudo ls -1 /dev/sd*
2 /dev/sda
3 /dev/sda1
4 /dev/sda2
5 /dev/sda3
6 /dev/sdb
Our shared disk is now mounted on both application servers (odoo1 and odoo2).
OCFS2 allows for file system to be mounted more than one place. Install OCFS2
tools on both odoo1 and odoo2 servers:
Create a partition by using following sequences in the cfdisk wizard: New > Primary
> accept Size > Write > yes > Quit.
1 # /etc/ocfs2/cluster.conf
2 cluster:
https://severalnines.com/database-blog/how-cluster-odoo-12-postgresql-streaming-replication-high-availability 7/13
8/26/2021 How to Cluster Odoo 12 with PostgreSQL Streaming Replication for High Availability | Severalnines
3 node_count = 2
Login / Sign up
4 name = ocfs2
5 node:
PRODUCT
DOWNLOAD
6
PRICING PLANS
ip_port = 7777
RESOURCES
SUPPORT
BLOG
ABOUT US
7 ip_address = 192.168.55.111
LOGIN / SIGN UP8
number
SUBSCRIBE FOR = 1
NEWSLETTER
Back to Home Page 9 name = odoo1 Filters Subscribe
10 cluster = ocfs2
11 node:
12 ip_port = 7777
13 ip_address = 192.168.55.112
14 number = 2
15 name = odoo2
16 cluster = ocfs2
Note that the attributes under the node or cluster clause need to be after a tab.
** The following steps should be performed on odoo1 and odoo2 unless specified
otherwise.
Get the block ID for the /dev/sdb1 device. UUID is recommended in fstab if you
use iSCSI device:
Use the UUID value when adding the following line into /etc/fstab:
Register the ocfs2 cluster and mount the filesystem from fstab:
Verify with:
If you can see the above line on all application servers, we are a good to install
Odoo.
https://severalnines.com/database-blog/how-cluster-odoo-12-postgresql-streaming-replication-high-availability 8/13
8/26/2021 How to Cluster Odoo 12 with PostgreSQL Streaming Replication for High Availability | Severalnines
PRODUCT
DOWNLOAD
PRICING PLANS
RESOURCES
SUPPORT
BLOG
ABOUT US
By default, the above command will automatically install PostgreSQL server on the
same host as part of Odoo dependencies. We probably want to stop it because we
are not going to use the local server anyway:
1 $ sudo -i
2 $ su - postgres
3 $ createuser --createrole --createdb --pwprompt odoo
Specify a password in the prompt. Then on both postgresql1 and postgresql2, add
the following line inside pg_hba.conf to allow the application and load balancer
nodes to connect. As in our case, it's located at
/etc/postgresql/11/main/pg_hba.conf:
1 $ su - postgres
2 $ /usr/lib/postgresql/11/bin/pg_ctl reload -D /var/lib/postgresql/11/main/
1 [options]
2 ; This is the password that allows database operations:
3 admin_passwd = admins3cr3t
4 db_host = 192.168.55.100
5 db_port = 5433
6 db_user = odoo
7 db_password = odoopassword
8 ;addons_path = /usr/lib/python3/dist-packages/odoo/addons
The, open Odoo on one of the application servers via web browser. In this
example, we connected to odoo1, thus the URL is http://192.168.55.111:8069/ and
you should see the following initial page:
Specify the "Master Password" identical with the admin_passwd value defined in
Odoo configuration file. Then fill up all the required information for the new
company that going to use this platform.
https://severalnines.com/database-blog/how-cluster-odoo-12-postgresql-streaming-replication-high-availability 9/13
8/26/2021 How to Cluster Odoo 12 with PostgreSQL Streaming Replication for High Availability | Severalnines
Once done, wait for a moment until the initialization finishes. You will be
Login / Sign up
PRODUCT
DOWNLOAD
redirected
to PRICING
the OdooPLANS
RESOURCES
administration
SUPPORT
dashboard: BLOG
ABOUT US
LOGIN / SIGN UP
SUBSCRIBE FOR NEWSLETTER
Back to Home Page Filters Subscribe
At this point, Odoo installation is complete and you can start configuring the
business apps for this company. All the file changes made by this application
server will be stored inside the clustered file system located at
"/var/lib/odoo/.local" (which also mounted to another application server, odoo2),
while changes to the database will be happening on the PostgreSQL master node.
Despite running on two different host, take note that Odoo application itself is not
load-balanced in this writing. You may use the HAProxy instances deployed for the
database cluster to achieve better availability just like the database service. Plus,
the shared disk file system (OCFS2) used by both application servers is still
exposed to single-point of failure, since they are all using the same iSCSI device on
lb2 (imagine if lb2 is inaccessible).
If the old master comes back up, the PostgreSQL service will be shut down
automatically and the next thing user has to do is to resync the old master back
from the new master by going to Node Actions > Rebuild Replication Slave:
The old master will then become a slave to the new master after the syncing
operation completes:
https://severalnines.com/database-blog/how-cluster-odoo-12-postgresql-streaming-replication-high-availability 10/13
8/26/2021 How to Cluster Odoo 12 with PostgreSQL Streaming Replication for High Availability | Severalnines
read more by:
Login / Sign up
Ashraf Sharif
PRODUCT
DOWNLOAD
PRICING PLANS
RESOURCES
SUPPORT
BLOG
ABOUT US
LOGIN / SIGN UP
SUBSCRIBE FOR NEWSLETTER
Back to Home Page Filters Subscribe
Ashraf Sharif is System Support Engineer at Severalnines. He was
previously involved in hosting world and LAMP stack, where he worked as
principal consultant and head of support team and delivered clustering
solutions for large websites in the South East Asia region. His professional
interests are on system scalability and high availability.
https://severalnines.com/database-blog/how-cluster-odoo-12-postgresql-streaming-replication-high-availability 11/13
8/26/2021 How to Cluster Odoo 12 with PostgreSQL Streaming Replication for High Availability | Severalnines
Login / Sign up
PRODUCT
severalnines
DOWNLOAD
PRICING
🔒 Disqus' PLANS
RESOURCES
SUPPORT
BLOG
ABOUT US
LOGIN / SIGN
Recommend 1
UP
t Tweet SUBSCRIBE
f Share FOR NEWSLETTER Sort by Best
Back to Home Page Filters Subscribe
LOG IN WITH
OR SIGN UP WITH DISQUS ?
Name
it's load balanced, should have a better performance after that. how do i test this ?
1△ ▽ • Reply • Share ›
Also any thought on performance issue between nfs or using ocfs2? Also how bout glusterfs
△ ▽ • Reply • Share ›
To me, NFS should work pretty well in active-passive setup (where one Odoo instance is
active at one time). OCFS2 is a cluster-aware FS which means you will get a better
performance if you opt for an active-active setup with central locking management and
block-level storage. However it's much hassle to implement if compared to NFS. Based
on my experience, GlusterFS is much simpler to implement but only suitable for large
static files that don't change. I could be wrong on this though. Anyway, always test your
application before making such a claim.
△ ▽ • Reply • Share ›
In your opinion, which clustered FS is best suitable for the Odoo instances?
GlusterFS? OCFS2? NFS? Ceph?
△ ▽ • Reply • Share ›
database infrastructure.
Learn more
https://severalnines.com/database-blog/how-cluster-odoo-12-postgresql-streaming-replication-high-availability 12/13
8/26/2021 How to Cluster Odoo 12 with PostgreSQL Streaming Replication for High Availability | Severalnines
Login / Sign up
PRODUCT
DOWNLOAD
PRICING PLANS
RESOURCES
SUPPORT
BLOG
ABOUT US
LOGIN / SIGN UP
SUBSCRIBE FOR NEWSLETTER
Back to Home Page Filters Subscribe
Certification
BLOG ABOUT US
Configuration Management
MySQL Careers
PostgreSQL Customers
MariaDB Partners
MongoDB
TimescaleDB
Docker
Your e-mail
Subscribe
© Copyright 2014-2021 Severalnines AB. All rights reserved. Website Policies Sitemap
https://severalnines.com/database-blog/how-cluster-odoo-12-postgresql-streaming-replication-high-availability 13/13