Point all Nodes to the Same Liferay DXP Database

Each node should have a data source that points to one Liferay DXP database (or a database cluster) that all the nodes share. This means, of course, Liferay DXP cannot (and should not) use the embedded HSQL database that is shipped with the bundles (but you already knew that, right?). And, of course, the database server should be on a separate system from the Liferay DXP server.

Read-Writer Database Configuration

To improve database performance, you can use a read-writer database configuration. Instead of using the same data source for read and read-write operations, this strategy uses a separate data source for each operation type. DXP’s Aspect Oriented Programming (AOP) transaction infrastructure directs read transactions to the read data source and read-write transactions to the write data source.

Connections to separate read and read-write data sources are configured using JDBC or JNDI Portal Properties (e.g., in a portal-ext.properties file), as explained in the following sections. The data sources should use separate instances of the DXP database, where the read-write database instance is replicated to the read database instance.

JDBC

Edit your portal-ext.properties file following these steps to connect directly to your separate read and write data sources using JDBC:

  1. Set the default connection pool provider. For provider information, see the JDBC properties reference. The default setting specifies HikariCP as the pool provider:

    jdbc.default.liferay.pool.provider=hikaricp
    
  2. Configure JDBC connections to your separate read and write data sources. Here’s an example:

    jdbc.read.driverClassName=[place your driver name here]
    jdbc.read.url=[place the URL to your "read" database here]
    jdbc.read.username=[place your user name here]
    jdbc.read.password=[place your password here]
    
    jdbc.write.driverClassName=[place your driver name here]
    jdbc.write.url=[place the URL to your "read-write" database here]
    jdbc.write.username=[place your user name here]
    jdbc.write.password=[place your password here]
    

    For example JDBC connection values, please see Database Templates.

  3. Configure DXP to use the write data source (the data source whose prefix is jdbc.write.) to create the Counter data source. A separate data source is always dedicated to the counter.

    counter.jdbc.prefix=jdbc.write.
    
  4. Optionally validate the data connections to make sure bad connections are handled gracefully.

    Some connection pools used with JDBC4 (check your driver’s JDBC version) validate connections automatically. Other connection pools may require additional, vendor-specific connection validation properties—specify them in a Portal Properties file. Refer to your connection pool provider documentation for connection validation details.

  5. Enable the read-writer database configuration by copying the default spring.configs and spring.infrastructure.configs Portal Properties to your portal-ext.properties file and adding the following Spring configuration file paths to them.

    Add to spring.configs:

    META-INF/dynamic-data-source-spring.xml
    

    Add to spring.infrastructure.configs:

    META-INF/dynamic-data-source-infrastructure-spring.xml
    

    For more information, see the Spring configuration Portal Properties.

JNDI

Edit your portal-ext.properties file following these steps to connect to your read and write data sources on your app server using JNDI:

  1. Set your read and write JNDI data source user names and passwords.

    jdbc.read.jndi.name=[place your "read" data source JNDI name here]
    
    jdbc.read.username=*[place your user name here]
    jdbc.read.password=[place your password here]
    
    jdbc.write.jndi.name=[place your "read-write" data source JNDI name here]
    
    jdbc.write.username=[place your user name here]
    jdbc.write.password=[place your password here]
    
  2. Configure DXP to use the write data source (the data source whose prefix is jdbc.write.) to create the Counter data source. A separate data source is always dedicated to the counter.

    counter.jdbc.prefix=jdbc.write.
    
  3. Optionally validate the data connections to make sure bad connections are handled gracefully.

    Some connection pools used with JDBC4 (check your driver’s JDBC version) validate connections automatically. Other connection pools may require additional, vendor-specific connection validation properties—specify them in a Portal Properties file. Refer to your connection pool provider documentation for connection validation details.

  4. Enable the read-writer database configuration by copying the default spring.configs and spring.infrastructure.configs Portal Properties to your portal-ext.properties file and add the following Spring configuration file paths to them.

    Add to spring.configs:

    META-INF/dynamic-data-source-spring.xml
    

    Add to spring.infrastructure.configs:

    META-INF/dynamic-data-source-infrastructure-spring.xml
    

    For more information, see the Spring configuration Portal Properties.

DXP uses a read data source, a write data source, and a counter data source the next time it starts.

« Liferay DXP ClusteringConfigure Documents and Media the Same for all Nodes »
Was this article helpful?
0 out of 1 found this helpful