Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Magnus Smith
Problem adding extra database to existing sharded Liferay 6.0 EE SP2
November 7, 2011 8:31 AM
Answer

Magnus Smith

Rank: New Member

Posts: 3

Join Date: March 18, 2011

Recent Posts

Liferay Portal Enterprise Edition 6.0 EE SP2 running with database sharding.

In our current test configuration I have 3 data sources

 1    jdbc.default.driverClassName=com.mysql.jdbc.Driver
 2    jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
 3    jdbc.default.username=root
 4    jdbc.default.password=root
 5   
 6    jdbc.one.driverClassName=com.mysql.jdbc.Driver
 7    jdbc.one.url=jdbc:mysql://localhost/lportal1?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
 8    jdbc.one.username=root
 9    jdbc.one.password=root
10   
11    jdbc.two.driverClassName=com.mysql.jdbc.Driver
12    jdbc.two.url=jdbc:mysql://localhost/lportal2?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
13    jdbc.two.username=root
14    jdbc.two.password=root
15
16    shard.selector=com.liferay.portal.dao.shard.ManualShardSelector
17    shard.available.names=default,one,two
18    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
1
2jdbc.three.driverClassName=com.mysql.jdbc.Driver
3    jdbc.three.url=jdbc:mysql://localhost/lportal3?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
4    jdbc.three.username=root
5    jdbc.three.password=root


and updated the available names.

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


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

1
2<bean id="shardDataSource3" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
3        <property name="targetDataSource">
4            <bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean">
5                <property name="propertyPrefix" value="jdbc.three." />
6            </bean>
7        </property>
8    </bean>


and adding the entry to datasources property
1   
2<entry>
3    <key>
4        <value>three</value>
5    </key>
6    <ref bean="shardDataSource3" />
7</entry>


Now when I restart the portal server I get the following log message
1INFO  [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
RE: Problem adding extra database to existing sharded Liferay 6.0 EE SP2
January 9, 2013 12:00 AM
Answer

Kris Sokolovski

Rank: New Member

Posts: 8

Join Date: November 13, 2011

Recent Posts

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
Marco Rosetti
RE: Problem adding extra database to existing sharded Liferay 6.0 EE SP2
September 4, 2014 3:16 AM
Answer

Marco Rosetti

Rank: Junior Member

Posts: 68

Join Date: March 6, 2013

Recent Posts

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