Foren

Problem adding extra database to existing sharded Liferay 6.0 EE SP2

Magnus Smith, geändert vor 12 Jahren.

Problem adding extra database to existing sharded Liferay 6.0 EE SP2

New Member Beiträge: 3 Beitrittsdatum: 18.03.11 Neueste Beiträge
Liferay Portal Enterprise Edition 6.0 EE SP2 running with database sharding.

In our current test configuration I have 3 data sources

    jdbc.default.driverClassName=com.mysql.jdbc.Driver
    jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
    jdbc.default.username=root
    jdbc.default.password=root
    
    jdbc.one.driverClassName=com.mysql.jdbc.Driver
    jdbc.one.url=jdbc:mysql://localhost/lportal1?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
    jdbc.one.username=root
    jdbc.one.password=root
    
    jdbc.two.driverClassName=com.mysql.jdbc.Driver
    jdbc.two.url=jdbc:mysql://localhost/lportal2?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
    jdbc.two.username=root
    jdbc.two.password=root

    shard.selector=com.liferay.portal.dao.shard.ManualShardSelector
    shard.available.names=default,one,two
    shard.default.name=default


This is running nicely but now we want to add an extra data source. I've added the following datasource in portal-ext.properties

jdbc.three.driverClassName=com.mysql.jdbc.Driver
    jdbc.three.url=jdbc:mysql://localhost/lportal3?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
    jdbc.three.username=root
    jdbc.three.password=root


and updated the available names.

  shard.available.names=default,one,two,three


I've overridden
shard-data-source-spring.xml
with the extra datasource by adding


<bean id="shardDataSource3" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
		<property name="targetDataSource">
			<bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean">
				<property name="propertyPrefix" value="jdbc.three." />
			</bean>
		</property>
	</bean>


and adding the entry to datasources property
	
<entry>
	<key>
		<value>three</value>
	</key>
	<ref bean="shardDataSource3" />
</entry>


Now when I restart the portal server I get the following log message
INFO  [ShardDataSourceTargetSource:73] Sharding configured with 4 data sources

but the database tables do not get created.

If I delete all the databases and start from fresh then they get created correctly.

The behaviour is the same in both Mysql and Oracle

Is there a workaround to allow me to add a new database to an existing sharded liferay?
Kris Sokolovski, geändert vor 11 Jahren.

RE: Problem adding extra database to existing sharded Liferay 6.0 EE SP2

New Member Beiträge: 8 Beitrittsdatum: 14.11.11 Neueste Beiträge
Hi Magnus,

I think, You've done everything correctly. But as I can see, You miss one more thing!

The database won't create automaticaly. You should create a new schema 'lportal3' and run SQL scripts to create minimal-database. We are using MySQL DB, so I would use 'create-minimal-mysql.sql' which can be found in Liferay Downloads 'liferay-portal-sql-6.1.20-ee-ga2' - just pay attention what version do You use.

Also, please check 'create-minimal-mysql.sql' content and replace all 'lportal' to 'lportal3'.

Hope that helps!

Regards,
Kris
thumbnail
Marco Rosetti, geändert vor 9 Jahren.

RE: Problem adding extra database to existing sharded Liferay 6.0 EE SP2

Junior Member Beiträge: 68 Beitrittsdatum: 06.03.13 Neueste Beiträge
Kris Sokolovski:
Hi Magnus,

I think, You've done everything correctly. But as I can see, You miss one more thing!

The database won't create automaticaly. You should create a new schema 'lportal3' and run SQL scripts to create minimal-database. We are using MySQL DB, so I would use 'create-minimal-mysql.sql' which can be found in Liferay Downloads 'liferay-portal-sql-6.1.20-ee-ga2' - just pay attention what version do You use.

Also, please check 'create-minimal-mysql.sql' content and replace all 'lportal' to 'lportal3'.

Hope that helps!

Regards,
Kris


This works fine for liferay-bundled plugins (for example calendar). Is there a way to handle also other plugins?

Thanks