掲示板

Problem adding extra database to existing sharded Liferay 6.0 EE SP2

12年前 に Magnus Smith によって更新されました。

Problem adding extra database to existing sharded Liferay 6.0 EE SP2

New Member 投稿: 3 参加年月日: 11/03/18 最新の投稿
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?
11年前 に Kris Sokolovski によって更新されました。

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

New Member 投稿: 8 参加年月日: 11/11/14 最新の投稿
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
9年前 に Marco Rosetti によって更新されました。

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

Junior Member 投稿: 68 参加年月日: 13/03/06 最新の投稿
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