ofbiz企业级框架的云服务分析

ofbiz 多租户模式:sql

ofbiz支持多租户模式,那么是一个什么样的方式提供的呢:数据库

一、每个租户ofbiz 提供一套彻底隔离的库表,这样租户于租户之间不会相关影响。服务器

二、对于后台管理来讲,租户经过tenant 标示加 用户名,密码 登陆。登陆到本身租户的系统中。微信

三、ofbiz后台管理代码一致,这就要求后台管理具备通用性。spa

 

扩展前景分析:component

一、企业定制化:根据企业的特色开放不一样的企业用户权限。租户能够分为基础版、高级版等。xml

二、用户受权限制:get

三、目前多租户的电商化平台比较薄弱,如何会每一个多租户搭建电商门户、手机APP、微信应用值得考虑it

。。。。io

 

1. Multi-tenanct定义

 

多租户是可以运行单独的数据实例(租户)从单一OFBiz服务器。每一个数据实例保存在一个单独的数据库。

用户登陆数据实例(或租户)经过指定的承租者ID登陆。请注意,若是未选择承租者ID,使用默认数据库。

2. Tenant 数据库

 

² Tenant 的数据源是不在entityengine.xml 中定义。

 若是db不支持create=true,须要手动建立对应的数据库,如Mysql

3. 多租户模式配置

 

有以下3个地方须要修改对应的配置。

· OFBIZ-HOME/framework/entity/data/<yourTenantConfig>.xml

· OFBIZ-HOME/framework/entity/config/entityengine.xml

· OFBIZ-HOME/framework/entity/ofbiz-component.xml

 

1.3. yourTenantConfig.xml

 

能够在OFBIZ-HOME/framework/entity/data/配置对应的Tenant:

<entity-engine-xml>
    <!-- Search the Ofbiz Wiki for "Multitenancy support" to get instructions on how to setup multi-tenancy -->
    <Tenant tenantId="DEMO1" tenantName="Demo Tenant One"/>
    <TenantDataSource tenantId="DEMO1" entityGroupName="org.ofbiz" 
        jdbcUri="jdbc:derby:ofbiz_DEMO1;create=true" jdbcUsername="ofbiz" jdbcPassword="ofbiz"/>
    <TenantDataSource tenantId="DEMO1" entityGroupName="org.ofbiz.olap" 
        jdbcUri="jdbc:derby:ofbizolap_DEMO1;create=true" jdbcUsername="ofbiz" jdbcPassword="ofbiz"/>
    <!-- the org.ofbiz.tenant URI should be the same for ALL tenants, so don't create a TenantDataSource record for it, it will be ignored anyway -->
    <!-- See comments on entity def: <TenantUserLogin tenantId="DEMO1" userLoginId="admin" fromDate="2001-05-13 00:00:00.000" thruDate="" isManager="Y"/> -->

    <Tenant tenantId="DEMO2" tenantName="Demo Tenant Two"/>
    <TenantDataSource tenantId="DEMO2" entityGroupName="org.ofbiz" 
        jdbcUri="jdbc:derby:ofbiz_DEMO2;create=true" jdbcUsername="ofbiz" jdbcPassword="ofbiz"/>
    <TenantDataSource tenantId="DEMO2" entityGroupName="org.ofbiz.olap" 
        jdbcUri="jdbc:derby:ofbizolap_DEMO2;create=true" jdbcUsername="ofbiz" jdbcPassword="ofbiz"/>
    <!-- See comments on entity def: <TenantUserLogin tenantId="DEMO2" userLoginId="admin" fromDate="2001-05-13 00:00:00.000" thruDate="" isManager="N"/> -->
</entity-engine-xml>

1.4. ofbiz-component.xml

 

<entity-resource type="data" reader-name="tenant" loader="main" location="data/TenantDemoData.xml"/>

1.5. entityengine.xml

 

须要配置对应的tenant 的ofbiz、ofbiz_odbc、ofbiztenent、数据源

 

1.6. Loading Tenant.

 

执行 ant load-demo-multitenant.

 

这时定义在yourTenantConfig.xml里面的Demo1,Demo2数据库会有与ofbiz相同的表结构信息同时保存。

相关文章
相关标签/搜索