Switching to Solr
There was a little pain involved in switching from Lucene to Solr for an active project, but luckily, my co-worker, Patrick Perrone had already been down the path of getting Solr running on his Windows machine and provided an excellent step-by-step guide on how to make it work. If you haven't already, see his 3-part series on Making Sitecore 8 and Solr Work Together.Thanks to Patrick, getting Solr running was a breeze. This worked great for my active project, but now I'm starting up new projects where Solr will be the indexing mechanism from day 1. How will I separate client Solr cores from one another?
Installing Multiple Instances of Solr on your (Windows) Machine
Patrick's install guide works great when you're only going to be running a single instance of Solr, but in order to get a second instance of Solr running on my machine, I had to make some minor modifications.
Note: These steps assume you already have a solr instance up and running with the proper Sitecore-generated schemas. If you haven't followed all the steps to get Solr running with Sitecore, please do those first to save a bit of configuration time on your cores later.
Note: These steps assume you already have a solr instance up and running with the proper Sitecore-generated schemas. If you haven't followed all the steps to get Solr running with Sitecore, please do those first to save a bit of configuration time on your cores later.
- Stop your Tomcat service.
- I installed my Solr directory at C:\Solr and all my standard Sitecore and custom cores were then in directories under there. In order to clean things up, I created a new folder named ClientName1 that would now contain the cores for that client. Go ahead and create a folder named ClientName2 while you're here for the project you are starting up.
- Once created, pull all the content from the root of C:\Solr into this new ClientName1 folder.
- Since the original cores were already configured to work with Sitecore, it's a simple matter of copy/pasting all the cores into a second client folder. Copy all the files from the root of ClientName1 and paste them into ClientName2. At this time, you should remove any custom cores that were defined specifically for client 1. You can leave all the Sitecore cores as we're going to rebuild them as a final step anyways to get client 2 data into them. Your Solr root should now just have client folders in it, nice and clean-like.
- Go into your 'Monitor Tomcat' tool and remove the Java Options you set as part of the initial configuration of Solr. In my case, I removed Dsolr.solr.home=C:\Solr This option tells Tomcat where the home Solr directory is, but it assumes there is only one instance running. Our next steps will define the multiple home directories.
- Move the solr.war file out of the root of your ...\Tomcat 8.0\webapps\ directory. In my case, I moved the solr.war file up one directory from C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps to C:\Program Files\Apache Software Foundation\Tomcat 8.0\ Having the war file in the webapps directory is another indicator to Tomcat that it's only running a single instance and it will ignore the configuration files we are going to set in the next step.
- Go to your \Tomcat 8.0\conf\Catalina\localhost directory and create new XML config files for each client. I named mine solr-<clientNameX>.xml Note that this filename will be how you access your Solr cores in the browser. In this case, I'll access my two clients by http://tomcat:8081/solr-clientName1 and http://tomcat:8081/solr-clientName2. You can name them whatever you like, but the contents should look like this:
<Context docBase="C:\Program Files\Apache Software Foundation\Tomcat 8.0\solr.war" debug="0" crossContext="true" > <Environment name="solr/home" type="java.lang.String" value="C:\solr\ClientName1" override="true" /> </Context>
Here, you are referencing the path to the solr.war file that we moved and are setting the Solr home directory to where all your cores are for this client. - Copy the XML file you just created and paste it to create the XML file for ClientName2. Edit the file and change the path to from the C:\solr\ClientName1 directory to the ClientName2 directory.
- Start your Tomcat service back up.
- Navigate to http://tomcat:8081/solr-clientname1 and http://tomcat:8081/solr-clientname2 and verify that both instances are running. (using the port number used when configuring Solr and the file names for the XML configs you defined)
- Edit your ContentSearch.Solr.ServiceBaseAddress setting in the Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config file to point to the correct new instance of Solr.
- Once running, go back to your Sitecore instances and rebuild your indexes!