Installing SOLR on a Two Node Cluster

Liferay Support does not recommend or endorse specific third-party products over others. Liferay is not responsible for any instructions herein or referenced regarding these products. Any implementation of these principles is the responsibility of the subscriber.

This is an introductory guide to setting up Solr in a two node cluster and then switching Liferay's indexing method to Solr.

Solr is an open source enterprise search server based on the Lucene Java search library, with XML/HTTP and JSON APIs, hit highlighting, faceted search, caching, replication, and a web administration interface. Solr allows the administrator to search structured data without needing to write any custom code. 


  • Overall, SOLR has the best performance for clustering the indexes
  • Using SOLR offloads the burden of indexing from the Liferay nodes
  • Centralized index repository
  • Solr has more configuration options that make customization easier


  • If the Solr box goes down, all nodes will have no index (However, there is a distributed/replication setup that gives Solr high availability.) Learn more here: Lucidworks Documentation.
  • Lengthy configuration/setup


Users will set up three portal instances:

  • The Solr Server—This is the node that will do the indexing for the Liferay nodes.
  • Node 1—This node is running Liferay and is clustered with node 2.
  • Node 2—This node is running Liferay and is clustered with node 1.

Setting up the Solr Node

  1. Download Tomcat 6 zip and unzip it.
  2. Set the JAVA_HOME Environment variable to the location where the JDK is installed. 
  3. Download Solr zip and unzip it to a convenient location.
  4. Create the $SOLR_HOME directory; for instance C:\Program Files\Solr. Navigate to "apache-solr-1.4.0\example" and copy the contents of the "solr" folder into $SOLR_HOME. 
  5. Copy the WAR file from the Solr folder located in $APACHE-SOLR/dist/apache-solr-${solr.version}.war into $TOMCAT_HOME/webapps; where ${solr.version} represents Solr version number, i.e., 1.4.0.

    Rename the .war file to something easier, such as "solr.war" since the name will matter later. 

  6. Add following line to $TOMCAT_AS_DIR/bin/catalina.bat.

    set JAVA_OPTS=%JAVA_OPTS% -Dsolr.solr.home="C:\Program Files\Solr"

    Note: this only works because we are only running one instance of Solr. For multiple instances on the same Tomcat server, users will need to create a Tomcat Context XML file.

  7. Run Tomcat. If there are no errors, browse to http://localhost:8080/solr/admin and verify the Solr Admin page displays correctly. 

    Note: the "solr" part of the URL will be whatever you named the .war filesolr01.PNG

Setting up Node 1

  1. Install a database and configure MySQL to allow remote connections.
  2. Download the Liferay bundle. 
  3. Delete the lucene folder located in $LIFERAY_HOME/data/ so that the portal is pointing to Solr 
  4. Setup a file with the appropriate JDBC configurations.
    1. For informational purposes, you may add this property: web.server.display.node=true which will show which node you are currently logged into.
  5. Download the appropriate Solr plugin from Marketplace. Be sure to download the correct version for the appropriate portal version. For example, users on Portal 6.1 GA2+ should download Liferay Solr Search Engine. Users on newer portal versions should download either SOLR 3 or SOLR 4.
  6. Open the .war archive and edit the file, solr-spring.xml, located in $SOLR_WAR\WEB-INF\classes\META-INF\
    1. Look for the bean class which sets the location(s) of the Solr server. It should look something like this:  
      <bean class="com.liferay.portal.spring.context.PortletBeanFactoryPostProcessor" />
      <bean id="solrServer" class="">
      <constructor-arg type="java.lang.String" value="http://localhost:8080/solr/" />
    2. Change the value to point to where the $SOLR_HOME is setup. It should look something like this: http://$IP_OF_SOLR_SERVER:8080/solr/  
  7. Copy the Schema located in $SOLR_WAR\WEB-INF\conf\ and place it in the $SOLR_HOME/conf (might have to create the conf directory) on the Solr box. Now you can go ahead and start Solr.
  8. Copy the edited Solr plugin .war file and place it in the Deploy folder.
  9. Start the Node 1 Tomcat Server.

Setting up Node 2

  1. Download and install Liferay to the Tomcat server (a bundle may be used)
  2. Setup a file with the appropriate JDBC configurations to connect to the database in Node 1. For more information on this, see Installing Liferay Portal in a Clustered Environment.
  3. Start Node 2.
  4. Deploy the modified Solr .war file that was already deployed on Node 1. 

Testing SOLR

Start Liferay on both Nodes. Make sure they both start up correctly before trying to verify if Solr is configured correctly. 

Create a User

An easy way to test Solr is to create a user in Node 1 and see if the Node2 reflects the changes. Remember to check both ways.

If new user in Node 2 is found, then you have successfully configured Solr.

Create a wiki

Another way to test Solr is to create a wiki in Liferay and see if you can search for it through the Solr admin console.

  1. For example, create a wiki named "chocolate", in the body put "chocolate", and finally add a tag named "chocolate". 
  2. Navigate to the Solr admin webpage
  3. Search for "chocolate"solr02.PNG
  4.  If Solr was configured correctly, you should see the search result with the wiki we created: solr03.PNG

Expected Behavior

Each Liferay node sends requests to the search engine to update the search index when needed. These updates are then queued and handled automatically by the search engine independently. 

Here is an example of Solr making changes to the index:


Additional Information

For more information about setting up cluster environments for Liferay Portal, please see Installing Liferay Portal in a Clustered Environment


  1. Why do I need to install Solr on a separate application server? Can't I install it in conjunction with Liferay?

    In theory yes, but that defeats the purpose of using Solr because the goal is to offload search indexing to another box in order to free up processing for your Liferay installation(s). 

  2. Why do I get "SolrException: Bad Request" errors?

    Most likely, the Schema.xml from the Liferay Solr plugin .war was not added to the $SOLR_HOME/conf 

  3. Why do I get "SolrException: Not Found" errors?

    Most likely the URL of the Solr home was incorrectly in the Solr-Spring.xml. 

  4. How do I migrate from Lucene?

    Simply follow the above steps and reindex (there aren't any special "migration" steps). In regards to the reindex:

  5. How long will the reindexing take?

    It depends on many factors: the size of the data to be re-indexed, the Solr server's JVM settings and application configurations as well as the deployment type of your Solr instance: single-node or SolrCloud. The usual time it takes to reindex a full portal using the default Lucene engine can provide a rough estimation.
    You can find more information about Solr's performance here:

  6. Is there a way to reindex without taking the production down?

    Yes. Switching to Solr on a running Liferay server is a seamless process and does not require to take the production server down as long as both Liferay's Solr plugin and the Solr server are properly configured.

  7. What will happen to my portal while the reindexing has taken place?

    There is no difference between the default Lucene engine and Solr server in terms of Liferay portal's availability during reindexing: until the process is finished, searches may yield zero results or incorrect counts. Therefore, it is better to schedule the full-server reindex at a time when the load on the server is lowest.

  8. Can this work on other environments?

    To see the same process using JBoss on Linux, click here.

0 人中有 0 人觉得有帮助