our clients in one OFBiz instance Multi-Tenancy

Multi-tenancy support and how to use it

Introduction

Multi-tenancy has been introduced in OFBiz at rev 927271. Multi-tenancy is the ability to run separate data instances (tenants) from a single copy of OFBiz. Each data instance is kept in a separate database. A user logs into a data instance (or tenant) by specifying the tenant ID in the login form. Note that a default database is still used.

Tenant Databases

The datasources (= database references) are defined in the TenantDataSouces Entity not in the entityengine.xml (description below).

DBMS which does not support the “;create=true” syntax used OOTB with Derby (eg Postgres, MySql, etc.) we need to create the tenant(s) DB(s) and credentials before running the tenant(s) data installation.

Displaying the tenant Id field for connection

in framework/common/config/general.properties, change the multitenant option to Y
This will show the TenantID for login.

download general.properties file

Configuring for Multi-Tenant

The configuration files that need to be touched are the following:

  • OFBIZ-HOME/framework/entity/data/TenantDemoData.xml

download TenantDemoData.xml file


TenantDemoData.xml

Per Tenant add the following: “the following code creates 3 tenants CUSTOMER1, and CUSTOMER2”

<!– CUSTOMER1 tenant configuration –>

<Tenant tenantId=”CUSTOMER1″ tenantName=”CUSTOMER1″/>

<TenantDataSource

tenantId=”CUSTOMER1″

entityGroupName=”org.ofbiz”

jdbcUri=”jdbc:postgresql://127.0.0.1/customer1_db”

jdbcUsername=”postgres”

jdbcPassword=”root” />

<TenantDataSource tenantId=”CUSTOMER1″

entityGroupName=”org.ofbiz.olap”

jdbcUri=”jdbc:postgresql://127.0.0.1/ofbizolap_customer1″

jdbcUsername=”postgres”

jdbcPassword=”root” />

<!– end of CUSTOMER1 tenant configuration –>

<!– CUSTOMER2 tenant configuration –>

<Tenant tenantId=”CUSTOMER2″ tenantName=”CUSTOMER2″/>

<TenantDataSource

tenantId=”CUSTOMER2″

entityGroupName=”org.ofbiz”

jdbcUri=”jdbc:postgresql://127.0.0.1/customer2_db”

jdbcUsername=”postgres”

jdbcPassword=”root” />

<TenantDataSource tenantId=”CUSTOMER2″

entityGroupName=”org.ofbiz.olap”

jdbcUri=”jdbc:postgresql://127.0.0.1/ofbizolap_customer2″

jdbcUsername=”postgres”

jdbcPassword=”root” />

<!– end of CUSTOMER2 tenant configuration –>


and so on for every tenant.

Loading Tenant.

To set up the databases for multi-tenancy and load the seed data only, do the following:

$ ant load-demo

$ java \-Xmx512m \-XX:MaxPermSize=128m \-jar ofbiz.jar \-install \-readers=seed \-delegator=default

$ java -Xmx512m -XX:MaxPermSize=128m -jar ofbiz.jar -install -readers=seed -delegator=default#CUSTOMER1

$ java -Xmx512m -XX:MaxPermSize=128m -jar ofbiz.jar -install -readers=seed -delegator=default#CUSTOMER2

Then load a demo product store for each tenant by the following:

$ java -Xmx512m -XX:MaxPermSize=128m -jar ofbiz.jar -install -readers=seed,demo -delegator=default#CUSTOMER1

$ java -Xmx512m -XX:MaxPermSize=128m -jar ofbiz.jar -install -readers=seed,demo -delegator=default#CUSTOMER2

and then, start OFBiz

$ java -Xmx1024M -jar ofbiz.jar

Test

success

configure_multiple_tenants customer1_home_page enable_multi_tenant_in_general_properties_file login_page_with_tenant_id

//

6 thoughts on “our clients in one OFBiz instance Multi-Tenancy

  1. infobusime May 11, 2013 at 11:34 pm Reply

    it seams we can not create new business at the run-time? business= talent .

    can we make themes for each business/talent separately ?

    we need the customize the demo: start-up data for each talent so when we create new business we add the correct data in the enrollment

    how to make enrollment process instead demo data or what are the demo data that can use and what the data that need to enter in the enrollment stage?

    how to change the look-and-feel for the login page, is it inside the default theme? how to choose/configure the default theme?

    how to add the business logo and icon dynamically?

    can we configure the email/counties/language per talent?

  2. infobusime May 26, 2013 at 12:20 pm Reply

    Please, review the post of “OFBiz Production Setup” for installing the required data for the Enrollment Stage

    OFBiz Production Setup

  3. infobusime May 26, 2013 at 12:39 pm Reply

    login page’s look and feel is depending on the styles sheet of default theme.
    to change default theme find “general.properties” property file at
    /ofbiz-home/framework/common/config/general.properties
    and find property “VISUAL_THEME”
    default value is
    VISUAL_THEME=TOMAHAWK

    we can change default value to be
    VISUAL_THEME=FLAT_GREY

  4. infobusime May 27, 2013 at 9:31 am Reply

    Email / Countries / Language configuration per tenant is not currently supported
    kindly, view the following for more details
    http://ofbiz.135035.n4.nabble.com/proposal-overriding-property-setting-per-tenant-td4332720.html

  5. infobusime May 27, 2013 at 10:22 am Reply

    OFBiz logo can be changed dynamically via the profile screen of party
    but, this function is not working properly, so i created an issue at ASF at
    https://issues.apache.org/jira/browse/OFBIZ-5202

  6. infobusime June 5, 2013 at 10:51 am Reply

    OFBiz Visual Themes are shared between all OFBiz applications.
    and there are 2 types of themes
    themes for OFBiz applications “back office” themes
    and others for “ecommerce” application

Leave a comment