Contenido del curso

Install an Odoo 11 Stack on Ubuntu 16.04

Install an Odoo 11 Stack on Ubuntu 16.04 using Linode

What is Odoo?Permalink

Odoo聽(formerly known as OpenERP) is a self-hosted suite of over 10,000 open source applications for a variety of business needs, including CRM, eCommerce, accounting, inventory, point of sale, and project management. These applications are all fully integrated and can be installed and accessed through a web interface, making it easy to automate and manage your company鈥檚 processes.

For simple installations, Odoo and its dependencies can be installed on a single Linode (see our聽Install Odoo 10 on Ubuntu聽guide for details). However, this single-server setup is not suited for production deployments. This guide covers how to configure a production Odoo 11 cluster in which the Odoo server and PostgreSQL database are hosted on separate Linodes, with database replication for added performance and reliability.

System RequirementsPermalink

The setup in this guide requires the following聽minimal聽Linode specifications:

  • PostgreSQL databases (master and slave) - Linode聽2GB
  • Odoo 11 web application - Linode聽1GB

Keep in mind that your implementation may need more nodes or higher-memory plans depending on the number of end-users you want to serve and the number of modules you plan to incorporate.

All examples in this guide are for Ubuntu 16.04. If you plan to use a different operating system, adapt the commands as necessary.

Before You BeginPermalink

  1. Familiarize yourself with our聽Getting Started聽guide and complete the steps for setting your Linode鈥檚 hostname and timezone.

  2. This guide will use聽sudo聽wherever possible. Complete the sections of our聽Securing Your Server聽to create a standard user account, harden SSH access and remove unnecessary network services.

  3. Update your system:

    sudo apt-get update && sudo apt-get upgrade
  4. Install聽software-properties-common:

    sudo apt install software-properties-common

Configure Firewall Rules for OdooPermalink

If you want to configure a firewall for your Linodes, open the following ports:

NodeOpen TCP Ports
Odoo 11 application22, 6010, 5432, 8070
PostgreSQL database (Master & Slave)22, 6010, 5432

Ports聽22,聽80, and聽5432聽are the defaults for SSH, HTTP and PostgreSQL communications respectively. Port聽6010聽is used for Odoo communications and port聽8070聽is used by Odoo鈥檚 webserver. To open a particular port you can use:

sudo ufw allow 22/tcp

For more detailed information about firewall setup please read our guide聽How to Configure a Firewall with UFW.

Hostname AssignmentPermalink

In order to simplify communication between Linodes, set hostnames for each server. You can use private IPs if the Linodes are all in the same data center, or Fully Qualified Domain Names (FQDNs) if available. This guide will use the following FQDN and hostname conventions:

  1. PostgreSQL Master:

    5       localhost   masterdb    slavedb       odoo
  2. PostgreSQL Slave:

    5       localhost    slavedb   masterdb       odoo
  3. Odoo 11 server:

    5       localhost       odoo   masterdb    slavedb

FQDNs will be used throughout this guide whenever possible to avoid confusion.

Set up PostgreSQLPermalink

Configure the database backend. A聽Master聽node will be in charge of all transactions and additionally will stream to a secondary server: the聽Slave.

Install PostgreSQLPermalink

PostgreSQL version 9.6 offers significant improvements for database replication, but unfortunately, it is not included in the default Ubuntu 16.04 repositories. Install the newest version on all database nodes.

  1. Add the official PostgreSQL-Xenial repository to your system:

    sudo add-apt-repository "deb xenial-pgdg main"
  2. Import the repository key:

    wget --quiet -O - | sudo apt-key add -
  3. Update聽apt聽cache:

    sudo apt update
  4. Install PostgreSQL 9.6 in the database nodes:

    sudo apt install postgresql-9.6 postgresql-server-dev-9.6

Create PostgreSQL UsersPermalink

Begin with the PostgreSQL user needed for Odoo communications. Create this user on both聽Master聽and聽Slave聽nodes.

  1. Switch to the聽postgres聽user and create the database user聽odoo聽in charge of all operations. Use a strong password and save it in a secure location, you will need it later:

    sudo -u postgres createuser odoo -U postgres -dRSP

    Use the same password for the Odoo聽postgres聽user on all nodes. Odoo is not aware of database replication, so it will be easier to trigger an eventual failover procedure if both servers share the same information.

  2. Now you need to create the聽replicauser聽on the聽Master聽node:

    sudo -u postgres createuser replicauser -U postgres -P --replication

    Set a strong password that you鈥檒l remember.

    The聽replicauser聽user has fewer privileges than the聽odoo聽user because the聽replicauser鈥檚 only purpose is to allow the聽Slave聽to read information from the聽Master聽nodes. The聽--replication聽option grants the required privilege that聽replicauser聽need to perform its job.

Configure Host Based AuthenticationPermalink

  1. Stop the PostgreSQL service on all nodes:

    sudo systemctl stop postgresql
  2. Edit聽pg_hba.conf聽to allow PostgreSQL nodes to communicate with each other. Add the following lines to the聽Master聽database server:

    host    replication     replicauser         md5
    host    all             odoo               md5

    Each line provides the client authentication permissions to connect to a specific database. For example, the first line allows the聽Slave聽to connect to the聽Master聽node using聽replicauser, and the second line grants the聽odoo聽user the rights connect to聽all聽databases within this server.

  3. Add a similar configuration to the聽Slave聽node, this will make it easier to promote it to聽master聽status if necessary:

    host    all             odoo               md5

The settings in the聽pg_hba.conf聽file are:

  • host: Enables connections using Unix-domain sockets.
  • replication: Specifies a replication connection for the given user. No database name is required for this type of connection.
  • replicauser: The user created in the previous section.
  • md5: Make use of client-supplied MD5-encrypted password for authentication.
  • all: Match all databases in the server. You could provide specific Odoo database names (separated by commas if more than one) if you know them beforehand.
  • odoo: The Odoo user responsible for application/database communications.

Configure Archiving and ReplicationPermalink

On the Master node

  1. Create an聽archive聽directory for WAL files:

    sudo mkdir -p /var/lib/postgresql/9.6/main/archive/
  2. Change the聽archive聽directory permissions to allow the聽postgres聽user to read and write:

    sudo chown postgres: -R /var/lib/postgresql/9.6/main/archive/
  3. Edit聽postgresql.conf, and uncomment lines as necessary:

    listen_addresses = '*'
    #From WRITE AHEAD LOG Section
    wal_level = replica
    min_wal_size = 80MB
    max_wal_size = 1GB
    archive_mode = on
    archive_command = 'cp %p /var/lib/postgresql/9.6/main/archive/%f'
    archive_timeout = 1h
    #From REPLICATION Section
    max_wal_senders = 3
    wal_keep_segments = 10

On the Slave node

Edit the聽Slave鈥檚postgresql.conf:

listen_addresses = '*'
wal_level = replica
max_wal_senders = 3
wal_keep_segments = 10
hot_standby = on

These settings are:

  • listen_addresses: What IP addresses lo listen on. The聽'*'聽means that the server will listen to all IP addresses. You can limit this to only include the IP addresses that you consider safe.
  • wal_level: Set to聽replica聽to perform the required operations.
  • min_wal_size: Minimum size the transaction log will be.
  • max_wal_size: Actual target size of WAL at which a new checkpoint is triggered.
  • archive_mode: Set to聽on聽to activate the archive storage (see below).
  • archive_timeout: Forces the server to send a WAL segment periodically (even if聽min_wal_size聽is not reached). This is useful if you expect little WAL traffic.
  • archive_command: Local shell command to execute in order to archive a completed WAL file segment.
  • max_wal_senders: Maximum number of concurrent connections from the聽Slave聽node.
  • wal_keep_segments: Minimum number of past log file segments kept in the聽pg_xlog聽directory, in case a standby server (Slave聽node) needs to fetch them for streaming replication.
  • hot_standby = on: Specifies that the聽Slave聽server can connect and run queries during recovery.

Synchronize Master and Slave Node DataPermalink

  1. Confirm that the聽Slave聽PostgreSQL service is not running:

    sudo systemctl status postgresql
  2. Start the聽Master聽PostgreSQL service:

    sudo systemctl start postgresql
  3. Rename the聽Slave鈥檚聽data directory before continuing:

    sudo mv /var/lib/postgresql/9.6/main /var/lib/postgresql/9.6/main_old
  4. From the聽Slave聽node, enter the following to transfer all of the聽Master鈥檚聽data over:

    sudo -u postgres pg_basebackup -h --xlog-method=stream \
     -D /var/lib/postgresql/9.6/main/ -U replicauser -v -P

    You will be prompted with the聽replicauser聽password. Once the transfer is complete your聽Slave聽will be synchronized with the聽Master聽database. This puts an exact replica of the Master database on the Slave.

Do not start the Slave鈥檚 PostgreSQL service until Step 3 of the next section, when all configuration is complete.

Create the Recovery File on the Slave NodePermalink

  1. Copy the sample recovery file as a template for your requirements:

    sudo cp -avr /usr/share/postgresql/9.6/recovery.conf.sample \
  2. Edit the new copy of the recovery file:

    standby_mode = 'on'
    primary_conninfo = ' port=5432 user=replicauser password=REPLICAUSER_PWD'
    restore_command = 'cp /var/lib/postgresql/9.6/main/archive/%f %p'
    trigger_file = '/tmp/postgresql.trigger.5432'
  3. Start the PostgreSQL service on the聽Slave聽node:

    sudo systemctl start postgresql

These parameters configure your聽Slave聽to restore data. Failover and more options are described in the聽PostgreSQL documentation for recovery.

Test ReplicationPermalink

Test your setup to check that everything works as expected.

  1. In the聽Master聽server change to the聽postgres聽user and verify the replication status:

    sudo -u postgres psql -x -c "select * from pg_stat_replication;"
    -[ RECORD 1 ]----+------------------------------
    pid              | 6005
    usesysid         | 16385
    usename          | replicauser
    application_name | walreceiver
    client_addr      |
    client_hostname  |
    client_port      | 36676
    backend_start    | 2018-01-23 19:14:26.573184+00
    backend_xmin     |
    state            | streaming
    sent_location    | 0/6000F60
    write_location   | 0/6000F60
    flush_location   | 0/6000F60
    replay_location  | 0/6000F60
    sync_priority    | 0
    sync_state       | async
  2. To see the replication in action, create a test database on your聽Master聽server with the聽odoo聽user:

    sudo createdb -h localhost -p 5432 -U odoo helloworld
  3. On the聽Slave, check the presence of the new database you just created using the聽postgres聽user and聽psql:

    sudo -u postgres psql
  4. List all databases:

  5. Exit聽psql:


This test not only confirms that replication is working, but also that the聽odoo聽user is ready to perform database operations.

Enable PostgreSQL on StartupPermalink

Enable the聽postgresql聽service on both聽masterdb聽and聽slavedb:

sudo systemctl enable postgresql

Odoo 11 SetupPermalink

Configure your Odoo 11 web application to work with the PostgreSQL database backend.

Create the Odoo UserPermalink

In order to separate Odoo from other services, create a new Odoo system user to run its processes:

sudo adduser --system --home=/opt/odoo --group odoo

Configure LogsPermalink

The examples in this guide use a separate file for logging Odoo activity:

sudo mkdir /var/log/odoo

Install Odoo 11Permalink

  1. Install git:

    sudo apt install git
  2. Use Git to clone the Odoo files onto your server:

    sudo git clone --depth 1 \
    --branch 11.0 --single-branch /opt/odoo
    Odoo 11 application now uses Python 3.x instead of Python 2.7. If you are using Ubuntu 14.04 this may mean additional steps for your installation. Dependencies are now grouped to highlight the new changes.
  3. Enforce the use of POSIX locale this will prevent possible errors during installation (this has nothing to do with the Odoo language):

    export LC_ALL=C
  4. Install new Python3 dependencies:

    sudo apt-get install python3 python3-pip python3-suds python3-all-dev \
    python3-dev python3-setuptools python3-tk
  5. Install global dependencies (common to Odoo version 10):

    sudo apt install git libxml2-dev libxslt1-dev libevent-dev libsasl2-dev libldap2-dev \
    pkg-config libtiff5-dev libjpeg8-dev libjpeg-dev zlib1g-dev libfreetype6-dev \
    liblcms2-dev liblcms2-utils libwebp-dev tcl8.6-dev tk8.6-dev libyaml-dev fontconfig
  6. Install Odoo 11 specific Python dependencies:

    sudo -H pip3 install --upgrade pip
    sudo -H pip3 install -r /opt/odoo/doc/requirements.txt
    sudo -H pip3 install -r /opt/odoo/requirements.txt
  7. Install Less CSS via Node.js and npm:

    sudo curl -sL | sudo -E bash - \
    && sudo apt-get install -y nodejs \
    && sudo npm install -g less less-plugin-clean-css
  8. Download the聽wkhtmltopdf聽stable package. Replace the version number聽0.12.4聽in this command with the latest release on聽Github:

    cd /tmp
  9. Extract the package:

    tar -xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
  10. To ensure that聽wkhtmltopdf聽functions properly, move the binaries to a location in your executable path and give them the necessary permission for execution:

    sudo mv wkhtmltox/bin/wk* /usr/bin/ \
    && sudo chmod a+x /usr/bin/wk*

Configure the Odoo ServerPermalink

  1. Copy the included configuration file to聽/etc/聽and change its name to聽odoo-server.conf

    sudo cp /opt/odoo/debian/odoo.conf /etc/odoo-server.conf
  2. Modify the configuration file. The complete file should look similar to the following, depending on your deployment needs:

    admin_passwd = admin
    db_host =
    db_port = False
    db_user = odoo
    db_password = odoo_password
    addons_path = /opt/odoo/addons
    logfile = /var/log/odoo/odoo-server.log
    xmlrpc_port = 8070
  • admin_passwd: The password that allows administrative operations within Odoo GUI. Be sure to change聽admin聽to something more secure.
  • db_host: The聽masterdb聽FQDN.
  • db_port: Odoo uses PostgreSQL鈥檚 default port聽5432, change this only if you鈥檙e using custom PostgreSQL settings.
  • db_user: Name of the PostgreSQL database user.
  • db_password: Use the PostgreSQL聽odoo聽user password you created previously.
  • addons_path: Default addons path, you can add custom paths separating them with commas:聽</path/to/custom/modules>
  • logfile: Path to your Odoo logfiles.
  • xmlrpc_port: Port that Odoo will listen on.

Create an Odoo ServicePermalink

Create a systemd unit called聽odoo-server聽to allow your application to behave as a service. Create a new file at聽/lib/systemd/system/odoo-server.service聽and add the following:

Description=Odoo Open Source ERP and CRM

ExecStart=/opt/odoo/odoo-bin --config=/etc/odoo-server.conf --addons-path=/opt/odoo/addons/


Change File Ownership and PermissionsPermalink

  1. Change the聽odoo-server聽service permissions and ownership so only root can write to it, while the聽odoo聽user will only be able to read and execute it:

    sudo chmod 755 /lib/systemd/system/odoo-server.service \
    && sudo chown root: /lib/systemd/system/odoo-server.service
  2. Since the聽odoo聽user will run the application, change its ownership accordingly:

    sudo chown -R odoo: /opt/odoo/
  3. Set the聽odoo聽user as the owner of log directory as well:

    sudo chown odoo:root /var/log/odoo
  4. Protect the server configuration file. Change its ownership and permissions so no other non-root user can access it:

    sudo chown odoo: /etc/odoo-server.conf \
    && sudo chmod 640 /etc/odoo-server.conf

Test your Odoo StackPermalink

Confirm that everything is working as expected.

  1. Start the Odoo server:

    sudo systemctl start odoo-server
  2. Confirm that聽odoo-server聽is running:

    sudo systemctl status odoo-server
  3. In a browser, navigate to聽odoo.yourdomain.com聽or the IP address of the聽odoo聽Linode. If your proxy and your DNS configuration are working properly a login screen will appear.

  4. Click on the聽Manage Databases聽link:

    Odoo 11 Login Screen

    Now you can see the test database you created earlier.

  5. Click聽Create Database聽and fill out the form with a test database. Check the聽Load demonstation data聽box to populate your database with sample data.

    Odoo 11 Create Database

  6. In the browser, you should see a list of available apps, indicating that database creation was successful:

    Odoo 11 Welcome Screen

    The first time you create a database, Odoo may take several minutes to load all of its add-ons. Do not reload the page during this process.

Enable the Odoo ServicePermalink

  1. Enable the聽odoo-server聽service to start automatically on reboot:

    sudo systemctl enable odoo-server
  2. Reboot your Linode from the Linode Manager.

  3. Check the Odoo logs to verify that the Odoo server is running:

    sudo cat /var/log/odoo/odoo-server.log

Back Up Odoo DatabasesPermalink

If all components of the Odoo stack are running on a single server, it is simple to back up your databases using the Odoo web interface. However, this will not work with the configuration in this guide, since PostgreSQL was not installed on the聽odoo聽Linode.

You have two options to backup or transfer your production database:

  1. You can install PostgreSQL 9.6 on the聽odoo聽server using the procedure used for聽masterdb聽and聽slavedb. This will install聽pg_dump聽and other utilities, allowing you to use the Odoo GUI as before. Since Odoo configuration is explicit about database connection you will not have to worry about anything else. This method will restore the database to the聽masterdb聽server rather than聽odoo.

  2. You can also use a procedure similar to the one in聽Synchronize Master and Slave Node Data. Instead of synchronizing with a slave node, you can synchronize to a test or backup database server:

    1. Edit聽/etc/postgresql/9.6/main/pg_hba.conf聽on聽masterdb聽to allow the test server to connect to it.
    2. On the test server, stop the PostgreSQL service, move/rename/delete its current data, and run the聽pg_basebackup聽command as before:

      sudo systemctl stop postgresql
      sudo mv /var/lib/postgresql/9.6/main /var/lib/postgresql/9.6/main_old
      sudo -u postgres pg_basebackup -h <masterdb public ip> --xlog-method=stream -D /var/lib/postgresql/9.6/main/ -U replicauser -v -P

Update Odoo ModulesPermalink

Once you have restored, transferred, or synchronized your production database to the testing server you can update Odoo modules.

From your test server restart the Odoo service using the following flags to instruct the system to search for updates and apply any changes to modules:

sudo service odoo-server restart -u all -d <production_database_name>

Update your SystemPermalink

If all your tests pass, you can safely update your installation.

  1. From your Linode download the new code from source:

    cd /opt/odoo \
    && sudo git fetch origin 11.0
  2. Apply the changes to your repository:

    sudo git reset --hard origin/11.0
Do not confuse the Odoo system update with an Odoo聽version聽upgrade. With the method explained above, you are updating your Odoo application within the same version rather than聽upgrading聽to a newer Odoo version. Migrating from one version to another often requires several tests and manual modifications on the PostgreSQL database which are highly dependent on the version of Odoo you are upgrading from.

More InformationPermalink

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

177 N煤mero de vistas
2 Vistas de miembros
175 Vistas p煤blicas
0 Gustos
0 No me gusta
0 Comentarios
Compartir en redes sociales
Compartir enlace
Usar un enlace permanente para compartir en redes sociales
Compartir por correo

Por favor iniciar sesi贸n para compartir esto webpage por correo.