Foros de discusión

Liferay: Databes Setup for two instances

thumbnail
AlexV AlexV, modificado hace 15 años.

Liferay: Databes Setup for two instances

New Member Mensajes: 13 Fecha de incorporación: 3/05/06 Mensajes recientes
Good day to you,

I currently have an issue, which bothers me for a while.

When I try to setup a liferay portal running 2 instances on one server, everything runs well except they both use the same database.

Is it possible to configure a second db connector and define in the properties the $companyid access to it instead of using the global jdbc/LiferayPool connector?

Currently the only way to have different instances on the same server is to copy the folder and start different tomcats with different settings, which isn't the thing we want actually.

With portal-$companyid.properties we can configure the different instance settings and therefore my question, is it possible with a second database to and how?

kind regards

Alexander Vollberg
thumbnail
nek konstantopoulos, modificado hace 15 años.

RE: Liferay: Databes Setup for two instances

New Member Mensajes: 6 Fecha de incorporación: 3/10/07 Mensajes recientes
Hi Alexander

I try this too but unfortunely with no luck

If you find any solution for this issue please keep me inform

Regards
thumbnail
James Min, modificado hace 15 años.

RE: Liferay: Databes Setup for two instances

Expert Mensajes: 293 Fecha de incorporación: 14/08/06 Mensajes recientes
It is *possible* but do you want to configure a second DB Pool (datasource) that points to the same exact database on the DB server? or do you actually want two separate datasources pointing to two separate databases?

Just want to clarify.

The LiferayPool datasource is in the source code (5.1.2) in infrastructure-spring.xml :

<!--?xml version="1.0" encoding="UTF-8"?-->

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
	<bean id="liferayDataSource" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
		<property name="targetDataSource" ref="liferayDataSourceTarget" />
	</bean>
	<bean id="liferayDataSourceTarget" class="com.liferay.portal.spring.jndi.JndiObjectFactoryBean">
		<property name="jndiName" value="jdbc/LiferayPool" />
	</bean>
	<bean id="mailSession" class="com.liferay.portal.spring.jndi.JndiObjectFactoryBean">
		<property name="jndiName" value="mail/MailSession" />
	</bean>
	<bean id="com.liferay.portal.kernel.util.InfrastructureUtil" class="com.liferay.portal.kernel.util.InfrastructureUtil">
		<property name="dataSource" ref="liferayDataSource" />
		<property name="mailSession" ref="mailSession" />
	</bean>
</beans>



and hibernate-spring.xml :


<!--?xml version="1.0" encoding="UTF-8"?-->

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
	<bean id="liferayHibernateSessionFactory" class="com.liferay.portal.spring.hibernate.PortalHibernateConfiguration">
		<property name="dataSource">
			<ref bean="liferayDataSource" />
		</property>
	</bean>
	<bean id="liferaySessionFactory" class="com.liferay.portal.dao.orm.hibernate.SessionFactoryImpl">
		<property name="sessionFactoryImplementor">
			<ref bean="liferayHibernateSessionFactory" />
		</property>
	</bean>
	<bean id="liferayTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="dataSource">
			<ref bean="liferayDataSource" />
		</property>
		<property name="globalRollbackOnParticipationFailure" value="false" />
		<property name="sessionFactory">
			<ref bean="liferayHibernateSessionFactory" />
		</property>
	</bean>
</beans>


and also referenced in base spring.xml .

You would have to redfine this or override it, and I suppose you could do that in EXT through the spring config files there. It's been done to some extent or another but, I can't officially *recommend* it without knowing what problem you are trying to address. To do the above is definitely not a trivial task.

Is it just a second datasource that you want, or a second datasource pointing to a second DB? What about doing this on the back end by pointing LiferayPool to a different DB name at the app server level?

Just throwing it out there....
thumbnail
Alex V., modificado hace 15 años.

RE: Liferay: Databes Setup for two instances

New Member Mensajes: 13 Fecha de incorporación: 3/05/06 Mensajes recientes
James Min:
It is *possible* but do you want to configure a second DB Pool (datasource) that points to the same exact database on the DB server? or do you actually want two separate datasources pointing to two separate databases?

Just want to clarify.
...snipp...

Is it just a second datasource that you want, or a second datasource pointing to a second DB? What about doing this on the back end by pointing LiferayPool to a different DB name at the app server level?

Just throwing it out there....


Thank you for your reply

**or do you actually want two separate datasources pointing to two separate databases?**
My thoughts on this are, that it would be nice to have an option to configure a second DB with a second Connector for each instance.

Something like having different instances running with different connectors:

Portalinstance A -> DB A (Connector A)
Portalinstance B -> DB A (Connector A)
Portalinstance C -> DB C (Connector C)

**What about doing this on the back end by pointing LiferayPool to a different DB name at the app server level?**
Is ist possible to overwrite the serverconfiguration as LiferayPool on ext-level?
I thought that way too, but didn't found a proper solution.

We are currently in the evaluation phase for a multiinstance portal server, so if our approach isn't the best way and already solved without copying the tomcat server for each instance I would appreciate any help.

kind regards
Alexander
thumbnail
James Min, modificado hace 15 años.

RE: Liferay: Databes Setup for two instances

Expert Mensajes: 293 Fecha de incorporación: 14/08/06 Mensajes recientes
Maybe I am missing something here, but why can't you just define a different database name in the datasource definition file?

So for example. in tomcat this would be in tomcat/conf/Catalina/locahost/ROOT.xml

By default the Loiferay database is "lportal"


	<!-- MySQL -->



	<resource name="jdbc/LiferayPool" auth="Container" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/lportal?useUnicode=true&amp;characterEncoding=UTF-8&amp;useFastDateParsing=false" username="root" password="asdf" maxActive="20" />


in your other instances you can have them point to different databases:


	<!-- MySQL -->



	<resource name="jdbc/LiferayPool" auth="Container" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/lportalA?useUnicode=true&amp;characterEncoding=UTF-8&amp;useFastDateParsing=false" username="root" password="asdf" maxActive="20" />


in another:


	<!-- MySQL -->



	<resource name="jdbc/LiferayPool" auth="Container" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/lportalB?useUnicode=true&amp;characterEncoding=UTF-8&amp;useFastDateParsing=false" username="root" password="asdf" maxActive="20" />


and so forth... Just want to know how this would not address your issue,

I have this setup with multiple instance of Liferay on my own machine because I have multiples versions and multiple installs from different clients.


You *could* change the XML config files posted earlier but I wouldn't want to go that far unless there was a specific reason.
thumbnail
nek konstantopoulos, modificado hace 15 años.

RE: Liferay: Databes Setup for two instances

New Member Mensajes: 6 Fecha de incorporación: 3/10/07 Mensajes recientes
Hi james

Thank you for your reply

Maybe we were not so clear what we want to do....

Its two different states...

The 1st state is to setup multiple virtuals hosts(not instances) with different database schemas

The 2nd state is to setup multiple instances with different database servers

Kindly Regards
Nek Konstantopoulos