Upgrading from Liferay 6.1 to 6.2 Part 3
Created: 11 March 2016 Modified:In version 6.2 Liferay has made quite a jump to version 4 of Solr from 1.4 in use with Liferay 6.1. The Solr 4 setup for Liferay 6.2 is very similar to the setup for the previous version. First we will need to configure the Solr Portlet which gets deployed to Liferay. Second we will then need to configure and deploy the Solr server. This work is being performed on a XFCE Fedora Core 23 workstation. Software being used is Liferay 6.2 EE, Solr 4.9.1 and Apache Tomcat 7.0.68.
The first step is to go to the Liferay Marketplace and download the Solr 4 Search Engine portlet. You will then want to extract, from the “Solr 4 Search Engine EE.lpkg” Liferay package, the solr4-web-6.2.10.6.war file. You will want to open the WAR file and edit the WEB-INF/classes/META-INF/solr-spring.xml file. Locate the BasicAuthSolrServer bean and edit the URL property. An excerpt is shown below.
src/main/resources/portal.properties
You may notice the “code” subdirectoy which refers to the Solr core which we will create in a bit. The Solr 1.4 installation I inherited did not have a application specific core. Next we should extract the WEB-INF/conf/schema.xml file from solr4-web-6.2.10.6.war. This file will be used later to help configure the Solr server.
To configure the Solr 4 Server we will need to download the Apache Solr 4 Server and Apache Tomcat 7. Find a good place to work and extract out both files to a directory. The working directory where you extracted these files will look something like the following.
src/main/resources/portal.properties
In apache-tomcat-7.0.68/webapps you will want to remove all the sub directories and their contents. From solr-4.9.1/dist you will want to copy solr-4.9.1.war into the apache-tomcat-7.0.68/webapps directory. Copy all the files from solr-4.9.1/example/lib/ext/, solr-4.9.1/dist/solrj-lib/, and solr-4.9.1/example/resources directories into apache-tomcat-7.0.68/lib. Thinking I new better, I initially copied the files into the apache-tomcat-7.0.68/lib/ext directory. This did not work and I later moved them to apache-tomcat-7.0.68/lib.
Copy /home/chris/Downloads/solr-setup-directory/solr-4.9.1/example/solr directory into apache-tomcat-7.0.68. Copy the solr-4.9.1/contrib/ and solr-4.9.1/dist/ directories into the apache-tomcat-7.0.68/solr/ directory. Rename the apache-tomcat-7.0.68/solr/collection1 directory to “code” or whatever name you prefer. This will be the name of your Solr core. The apache-tomcat-7.0.68/solr/myapp/conf/solrconfig.xml will now need to be edited.
The dataDir, lib dir and autoSoftCommit settings will need to be modified. You can use a relative path to define the first two. I used the absolute directory path. Below I show excerpts of solrconfig.xml.
apache-tomcat-7.0.68/solr/myapp/conf/solrconfig.xml
With the solrconfig.xml behind us we now want to create a Tomcat Context Fragment. See Apache Tomcat documentation for an explanation of Context Fragments. First create the apache-tomcat-7.0.68/conf/Catalina/localhost/ directory path. This is where the Context Fragment will be placed. A Context Fragment, is an xml file, that must have the same name as the WAR file we placed in the webapps directory, excepting the file extension. For example if you WAR file is solr-4.9.1.war then your Context Fragment should be solr-4.9.1.xml. An example of the content is below.
apache-tomcat-7.0.68/solr/myapp/conf/solrconfig.xml
Last we will want to edit apache-tomcat-7.0.68/conf/server.xml and change the server port to 8983. An excerpt is shown below.
apache-tomcat-7.0.68/solr/myapp/conf/solrconfig.xml
Startup your server and you should be able to connect to http://localhost:8983/solr/admin.
tags: liferay - 6.2 - EE - solr 4 - linux