How to Configure Apache Solr to run with Multiple Cores
This tutorial assumes that you are running Apache Solr on Jetty Web Server, and have both set up in the same manner as described in the following tutorials:
How to Install Jetty Web Server in Ubuntu
How to Install Apache Solr in Ubuntu
Edit solr.xml
cd /opt/jetty/solr sudo gedit solr.xml
If you haven't done any modifications to your current solr.xml file, then use the following as a template:
<?xml version="1.0" encoding="UTF-8" ?>
<!--
All (relative) paths are relative to the installation path
persistent: Save changes made via the API to this file
sharedLib: path to a lib directory that will be shared across all cores
-->
<solr persistent="false">
<!--
adminPath: RequestHandler path to manage cores.
If 'null' (or absent), cores will not be manageable via request handler
-->
<cores adminPath="/admin/cores">
<core name="core0" instanceDir="./cores/core0" />
<core name="core1" instanceDir="./cores/core1" />
</cores>
</solr>
Edit solrconfig.xml
cd /opt/jetty/solr/conf
sudo gedit solrconfig.xml
Change the following:
<dataDir>${solr.data.dir:./solr/data}</dataDir>To:
<dataDir>${solr.data.dir:./data}</dataDir>Create cores directory
cd /opt/jetty/solr
sudo mkdir cores
Create first core directory
cd /opt/jetty/solr/cores
sudo mkdir core0
cd core0
sudo mkdir data
sudo chown -R jetty:jetty data
Copy over configuration files
cd /opt/jetty/solr
sudo cp -R conf cores/core0/conf
Create second core directory
cd /opt/jetty/solr/cores
sudo cp -R core0 core1
Restart Jetty
sudo /etc/init.d/jetty restart
If all is well, you should be able to access the admin page for each core at the following URLs:
core0 (admin)
core1 (admin)
The query URL works similarly:
core0 (query URL)
core1 (query URL)