You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Mark Ellul <ma...@catalystic.com> on 2008/02/26 20:24:15 UTC

Multitenant via Host Name

Hi,

I was just wondering if anyone can think of a way I could change the
datasource on a user per user basis...

Basically what I am trying to do is this... When User A goes to
www.myerp.com they go to my ofbiz instance running on my server... but based
on the url they are going to, their datasource is set to the myerp database.

When user B goes to www.yourerp.com they go to the same ofbiz instance
running on my server with the same code base but based on the URL their
datasource is the yourerp database...

My aim is to have one tomcat and one code base service many URLs each with
their own database, hopefully not having to change the datasource in each
service.

Sorry if I am not making myself clear...

Any thoughts would be appreciated

Regards

Mark

Re: Multitenant via Host Name

Posted by Mark Ellul <ma...@catalystic.com>.
Hi Vince and Vijay,

Thanks for your responses...

I am thinking that I will follow your way Vijay as I assumed it would
require multiple delegators and different datasource names... I did not know
about the sequence-id-prefix.

Most of my application really only uses the services and entity model in the
ofbiz framework, as we want our own UI.

If you do know which files I would need to look at apart from the
entity-engine.xml, it would be muchly appreciated if you send the names, the
rest I will figure out myself.

When this becomes a prime requirement in our system, and I have to do it, I
will blog about it and send the blog address on this list so it could help
other users going forward.

Thanks and Regards

Mark

On Wed, Feb 27, 2008 at 3:23 PM, Vijay <st...@gmail.com> wrote:

> Hello Mark,
>
> I agree with Vince's both schemes, However it is also possible to have a
> common Tomcat and different databases.
> But this requires a lot of changes in many of the files importantly
> beginning with
> entityengine.xml. Here 1st and foremost you will have to:
>
> 1) Assign different delegators for different hosted  entities
> 2) Assign different  datasource-names
> 3) Different sequenced-id-prefix=""  for each,
>
> besides you will also have to change some other files related to job. Then
> lot of ftl files will get changed {those that access the url}.
> So in a way Mr. Vince is correct in saying that as it is - ofbiz does not
> directly support multi-tenancy but it can be done with tweaks!!
>
> Regards
>
>
> On Wed, Feb 27, 2008 at 6:48 PM, Vince M. Clark <vc...@globalera.com>
> wrote:
>
> > Mark, what want to do is not possible. The database connection is
> > initiated during startup based on the settings in entityengine.xml. In
> > order to setup multiple instances each instance must have its own app
> server
> > and database.
> >
> > You can accomplish this on the same physical server two ways:
> > 1. Use virtualization technology such as vserver, Xen, or VMWare
> > 2. Use different ports on each instance (8080,8443,etc.)
> >
> > The database is not a problem. Most DBMS support multiple databases
> > (sometimes referred to as schemas or users) under the same installation
> of
> > the DBMS.
> >
> > ----- Original Message -----
> > From: "Mark Ellul" <ma...@catalystic.com>
> > To: user@ofbiz.apache.org
> > Sent: Wednesday, February 27, 2008 2:18:33 AM (GMT-0700) America/Denver
> > Subject: Re: Multitenant via Host Name
> >
> > Hi Vijay,
> >
> > I guess it would be good to know if I could run it off the same
> > tomcat/ofbiz
> > instance....
> >
> > so in essence www.myerp.com and www.yourerp.com would both go
> > https://x.y.z.m:PPPP/app/control/main. However the main would look at
> host
> > headers and set the datasource name based on the host headers... and
> > basically set the datasource name for the session.
> >
> > Is that possible?
> >
> > Our aim by doing this is to set up a sandbox and production site on the
> > same
> > server using the same codebase and just different databases.
> >
> > Your thoughts are appreciated
> >
> > Regards
> >
> > Mark
> >
> >
> > On Wed, Feb 27, 2008 at 8:46 AM, Vijay <st...@gmail.com> wrote:
> >
> > > You will have to change the datasource names.
> > > Are you mapping the url's "www.myerp.com" and others to ofbiz specific
> > > urls'
> > > of https://x.y.z.m:PPPP/app/control/main ?
> > >
> > > The case you are trying out is perfectly possible.
> > >
> > > On Wed, Feb 27, 2008 at 12:54 AM, Mark Ellul <ma...@catalystic.com>
> > wrote:
> > >
> > > > Hi,
> > > >
> > > > I was just wondering if anyone can think of a way I could change the
> > > > datasource on a user per user basis...
> > > >
> > > > Basically what I am trying to do is this... When User A goes to
> > > > www.myerp.com they go to my ofbiz instance running on my server...
> but
> > > > based
> > > > on the url they are going to, their datasource is set to the myerp
> > > > database.
> > > >
> > > > When user B goes to www.yourerp.com they go to the same ofbiz
> instance
> > > > running on my server with the same code base but based on the URL
> > their
> > > > datasource is the yourerp database...
> > > >
> > > > My aim is to have one tomcat and one code base service many URLs
> each
> > > with
> > > > their own database, hopefully not having to change the datasource in
> > > each
> > > > service.
> > > >
> > > > Sorry if I am not making myself clear...
> > > >
> > > > Any thoughts would be appreciated
> > > >
> > > > Regards
> > > >
> > > > Mark
> > > >
> > >
> >
>

Re: Multitenant via Host Name

Posted by Vijay <st...@gmail.com>.
Hello Mark,

I agree with Vince's both schemes, However it is also possible to have a
common Tomcat and different databases.
But this requires a lot of changes in many of the files importantly
beginning with
entityengine.xml. Here 1st and foremost you will have to:

1) Assign different delegators for different hosted  entities
2) Assign different  datasource-names
3) Different sequenced-id-prefix=""  for each,

besides you will also have to change some other files related to job. Then
lot of ftl files will get changed {those that access the url}.
So in a way Mr. Vince is correct in saying that as it is - ofbiz does not
directly support multi-tenancy but it can be done with tweaks!!

Regards


On Wed, Feb 27, 2008 at 6:48 PM, Vince M. Clark <vc...@globalera.com>
wrote:

> Mark, what want to do is not possible. The database connection is
> initiated during startup based on the settings in entityengine.xml. In
> order to setup multiple instances each instance must have its own app server
> and database.
>
> You can accomplish this on the same physical server two ways:
> 1. Use virtualization technology such as vserver, Xen, or VMWare
> 2. Use different ports on each instance (8080,8443,etc.)
>
> The database is not a problem. Most DBMS support multiple databases
> (sometimes referred to as schemas or users) under the same installation of
> the DBMS.
>
> ----- Original Message -----
> From: "Mark Ellul" <ma...@catalystic.com>
> To: user@ofbiz.apache.org
> Sent: Wednesday, February 27, 2008 2:18:33 AM (GMT-0700) America/Denver
> Subject: Re: Multitenant via Host Name
>
> Hi Vijay,
>
> I guess it would be good to know if I could run it off the same
> tomcat/ofbiz
> instance....
>
> so in essence www.myerp.com and www.yourerp.com would both go
> https://x.y.z.m:PPPP/app/control/main. However the main would look at host
> headers and set the datasource name based on the host headers... and
> basically set the datasource name for the session.
>
> Is that possible?
>
> Our aim by doing this is to set up a sandbox and production site on the
> same
> server using the same codebase and just different databases.
>
> Your thoughts are appreciated
>
> Regards
>
> Mark
>
>
> On Wed, Feb 27, 2008 at 8:46 AM, Vijay <st...@gmail.com> wrote:
>
> > You will have to change the datasource names.
> > Are you mapping the url's "www.myerp.com" and others to ofbiz specific
> > urls'
> > of https://x.y.z.m:PPPP/app/control/main ?
> >
> > The case you are trying out is perfectly possible.
> >
> > On Wed, Feb 27, 2008 at 12:54 AM, Mark Ellul <ma...@catalystic.com>
> wrote:
> >
> > > Hi,
> > >
> > > I was just wondering if anyone can think of a way I could change the
> > > datasource on a user per user basis...
> > >
> > > Basically what I am trying to do is this... When User A goes to
> > > www.myerp.com they go to my ofbiz instance running on my server... but
> > > based
> > > on the url they are going to, their datasource is set to the myerp
> > > database.
> > >
> > > When user B goes to www.yourerp.com they go to the same ofbiz instance
> > > running on my server with the same code base but based on the URL
> their
> > > datasource is the yourerp database...
> > >
> > > My aim is to have one tomcat and one code base service many URLs each
> > with
> > > their own database, hopefully not having to change the datasource in
> > each
> > > service.
> > >
> > > Sorry if I am not making myself clear...
> > >
> > > Any thoughts would be appreciated
> > >
> > > Regards
> > >
> > > Mark
> > >
> >
>

Re: Multitenant via Host Name

Posted by "Vince M. Clark" <vc...@globalera.com>.
Mark, what want to do is not possible. The database connection is initiated during startup based on the settings in entityengine.xml. In order to setup multiple instances each instance must have its own app server and database. 

You can accomplish this on the same physical server two ways: 
1. Use virtualization technology such as vserver, Xen, or VMWare 
2. Use different ports on each instance (8080,8443,etc.) 

The database is not a problem. Most DBMS support multiple databases (sometimes referred to as schemas or users) under the same installation of the DBMS. 

----- Original Message ----- 
From: "Mark Ellul" <ma...@catalystic.com> 
To: user@ofbiz.apache.org 
Sent: Wednesday, February 27, 2008 2:18:33 AM (GMT-0700) America/Denver 
Subject: Re: Multitenant via Host Name 

Hi Vijay, 

I guess it would be good to know if I could run it off the same tomcat/ofbiz 
instance.... 

so in essence www.myerp.com and www.yourerp.com would both go 
https://x.y.z.m:PPPP/app/control/main. However the main would look at host 
headers and set the datasource name based on the host headers... and 
basically set the datasource name for the session. 

Is that possible? 

Our aim by doing this is to set up a sandbox and production site on the same 
server using the same codebase and just different databases. 

Your thoughts are appreciated 

Regards 

Mark 


On Wed, Feb 27, 2008 at 8:46 AM, Vijay <st...@gmail.com> wrote: 

> You will have to change the datasource names. 
> Are you mapping the url's "www.myerp.com" and others to ofbiz specific 
> urls' 
> of https://x.y.z.m:PPPP/app/control/main ? 
> 
> The case you are trying out is perfectly possible. 
> 
> On Wed, Feb 27, 2008 at 12:54 AM, Mark Ellul <ma...@catalystic.com> wrote: 
> 
> > Hi, 
> > 
> > I was just wondering if anyone can think of a way I could change the 
> > datasource on a user per user basis... 
> > 
> > Basically what I am trying to do is this... When User A goes to 
> > www.myerp.com they go to my ofbiz instance running on my server... but 
> > based 
> > on the url they are going to, their datasource is set to the myerp 
> > database. 
> > 
> > When user B goes to www.yourerp.com they go to the same ofbiz instance 
> > running on my server with the same code base but based on the URL their 
> > datasource is the yourerp database... 
> > 
> > My aim is to have one tomcat and one code base service many URLs each 
> with 
> > their own database, hopefully not having to change the datasource in 
> each 
> > service. 
> > 
> > Sorry if I am not making myself clear... 
> > 
> > Any thoughts would be appreciated 
> > 
> > Regards 
> > 
> > Mark 
> > 
> 

Re: Multitenant via Host Name

Posted by Mark Ellul <ma...@catalystic.com>.
Hi Vijay,

I guess it would be good to know if I could run it off the same tomcat/ofbiz
instance....

so in essence www.myerp.com and www.yourerp.com would both go
https://x.y.z.m:PPPP/app/control/main. However the main would look at host
headers and set the datasource name based on the host headers...  and
basically set the datasource name for the session.

Is that possible?

Our aim by doing this is to set up a sandbox and production site on the same
server using the same codebase and just different databases.

Your thoughts are appreciated

Regards

Mark


On Wed, Feb 27, 2008 at 8:46 AM, Vijay <st...@gmail.com> wrote:

> You will have to change the datasource names.
> Are you mapping the url's "www.myerp.com" and others to ofbiz specific
> urls'
> of https://x.y.z.m:PPPP/app/control/main ?
>
> The case you are trying out is perfectly possible.
>
> On Wed, Feb 27, 2008 at 12:54 AM, Mark Ellul <ma...@catalystic.com> wrote:
>
> > Hi,
> >
> > I was just wondering if anyone can think of a way I could change the
> > datasource on a user per user basis...
> >
> > Basically what I am trying to do is this... When User A goes to
> > www.myerp.com they go to my ofbiz instance running on my server... but
> > based
> > on the url they are going to, their datasource is set to the myerp
> > database.
> >
> > When user B goes to www.yourerp.com they go to the same ofbiz instance
> > running on my server with the same code base but based on the URL their
> > datasource is the yourerp database...
> >
> > My aim is to have one tomcat and one code base service many URLs each
> with
> > their own database, hopefully not having to change the datasource in
> each
> > service.
> >
> > Sorry if I am not making myself clear...
> >
> > Any thoughts would be appreciated
> >
> > Regards
> >
> > Mark
> >
>

Re: Multitenant via Host Name

Posted by Vijay <st...@gmail.com>.
You will have to change the datasource names.
Are you mapping the url's "www.myerp.com" and others to ofbiz specific urls'
of https://x.y.z.m:PPPP/app/control/main ?

The case you are trying out is perfectly possible.

On Wed, Feb 27, 2008 at 12:54 AM, Mark Ellul <ma...@catalystic.com> wrote:

> Hi,
>
> I was just wondering if anyone can think of a way I could change the
> datasource on a user per user basis...
>
> Basically what I am trying to do is this... When User A goes to
> www.myerp.com they go to my ofbiz instance running on my server... but
> based
> on the url they are going to, their datasource is set to the myerp
> database.
>
> When user B goes to www.yourerp.com they go to the same ofbiz instance
> running on my server with the same code base but based on the URL their
> datasource is the yourerp database...
>
> My aim is to have one tomcat and one code base service many URLs each with
> their own database, hopefully not having to change the datasource in each
> service.
>
> Sorry if I am not making myself clear...
>
> Any thoughts would be appreciated
>
> Regards
>
> Mark
>