3

Can I use same Solr service to install or use for different vanilla Sitecore 9.0.2 instances?

What is the best practice?

4

Short answer is yes.

Long answer:

You can achieve this setup pretty easily.

You have two or more instances of Sitecore. Make sure that these are compatible with installed version of Solr. Check it here.

For new installations:

Make sure you specify prefix parameter for solr cores install ps1 script:

#define parameters 
$prefix = "sc9u2" 
$PSScriptRoot = "C:\resourcefiles\"
$XConnectCollectionService = "$prefix.xconnect" 
$sitecoreSiteName = "$prefix.sc" 
$SolrUrl = "https://localhost:8984/solr" 
$SolrRoot = "C:\Solr\solr-6.6.2\" 
$SolrService = "Solr" 
$SqlServer = ".\" 
$SqlAdminUser = "sa" 
$SqlAdminPassword= "saP4$$" 

#install solr cores for xdb 
$solrParams = 
@{     
    Path = "$PSScriptRoot\xconnect-solr.json"     
    SolrUrl = $SolrUrl     
    SolrRoot = $SolrRoot     
    SolrService = $SolrService     
    CorePrefix = $prefix 
} 

Install-SitecoreConfiguration @solrParams -Verbose 

#install solr cores for sitecore $solrParams = 
$solrParams = @{     
    Path = "$PSScriptRoot\sitecore-solr.json"     
    SolrUrl = $SolrUrl     
    SolrRoot = $SolrRoot     
    SolrService = $SolrService     
    CorePrefix = $prefix 
} 

Install-SitecoreConfiguration @solrParams 

This is only part of the script to demonstrate how to set CorePrefix parameter to Solr cores.

Full script can be found here -> https://github.com/chorpo/Sitecore9Installation/blob/master/01%20Install.ps1

For already installed instances: For each Solr core definition you will keep core name (name parameter) and id the same (id attribute).

Normally config would look like this:

<index id="sitecore_master_index" .....>
   <param desc="name">$(id)</param>
   <param desc="core">$(id)</param>

You will just specify "core" parameter as follows:

<param desc="core">instance1_$(id)</param> or <param desc="core">instance2_$(id)</param> as you need based on instance name.

So config in your case would look like this at the end:

<index id="sitecore_master_index" .....>
   <param desc="name">$(id)</param>
   <param desc="core">instancename_$(id)</param>

For each solution you will have then config files for Solr with same file name, Solr ids and all the remaining settings. Only difference will be this "core" parameter.

Here is the patch config to apply your instance settings per Solr core:

<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">
   <sitecore search:require="solr">
      <contentSearch>
         <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
            <indexes hint="list:AddIndex">
               <index id="sitecore_master_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
                  <param desc="core" patch:instead="param[@desc='core']">instancename_$(id)</param>
               </index>
               <index id="sitecore_core_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
                  <param desc="core" patch:instead="param[@desc='core']">instancename_$(id)</param>
               </index>
               <index id="sitecore_web_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
                  <param desc="core" patch:instead="param[@desc='core']">instancename_$(id)</param>
               </index>
               <index id="sitecore_marketingdefinitions_master" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
                  <param desc="core" patch:instead="param[@desc='core']">instancename_$(id)</param>
               </index>
               <index id="sitecore_marketingdefinitions_web" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
                  <param desc="core" patch:instead="param[@desc='core']">instancename_$(id)</param>
               </index>
               <index id="sitecore_marketing_asset_index_master" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
                  <param desc="core" patch:instead="param[@desc='core']">instancename_$(id)</param>
               </index>
               <index id="sitecore_marketing_asset_index_web" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
                  <param desc="core" patch:instead="param[@desc='core']">instancename_$(id)</param>
               </index>
               <index id="sitecore_testing_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
                  <param desc="core" patch:instead="param[@desc='core']">instancename_$(id)</param>
               </index>
               <index id="sitecore_suggested_test_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
                  <param desc="core" patch:instead="param[@desc='core']">instancename_$(id)</param>
               </index>
               <index id="sitecore_fxm_master_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
                  <param desc="core" patch:instead="param[@desc='core']">instancename_$(id)</param>
               </index>
               <index id="sitecore_fxm_web_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
                  <param desc="core" patch:instead="param[@desc='core']">instancename_$(id)</param>
               </index>
            </indexes>
         </configuration>
      </contentSearch>
   </sitecore>
</configuration>

Do not forget about adding SXA indexes or custom indexes also if you will have them in the future and also for CD servers, you need to remove master or other unnecessary indexes from the list.

In code you will reuse everything as you have as you are referencing solr index id so you will still reference "sitecore_master_index" or "sitecore_web_index" but based on the deployed configuration in each instance, you will effectively reference different Solr cores based on instance.

To identify Sitecore Solr cores quickly, you can go to ShowConfig admin page and search for <indexes hint="list:AddIndex".

You will see all 11 out of the box indexes and their respective configuration. You can quickly identify files in which are patched:

Example of search results for list:AddIndex in admin's show config page.

  • as mentioned by Richard , for Sitecore v9 "the solr cores are already prefixed with the instance name. So no extra work is required". For previous versions , you along with other developers have given answers ! Wonderful responses by Sitecore Community ! Cheers ! – Pratik Wasnik Aug 29 '18 at 12:14
2

If you are doing on development machine yes you can do it. For production I don't recommend to use same Solr for different solutions.

Just keep in mind if you have different Sitecore releases, your release should be compatible with your Solr server.

Please have a look on Solr compatibility table : https://kb.sitecore.net/articles/227897

  • "For production I don't recommend to use same Solr for different solutions." Can you elaborate why? – James Skemp Aug 29 '18 at 12:29
  • Are some partners who offer hosting for their clients and I saw cases they host multiple clients solutions on a single solr server. – Vlad Iobagiu Aug 29 '18 at 13:19
  • Ah. So different solutions ~= different clients. Thanks. – James Skemp Aug 29 '18 at 15:31
1

The answer is yes, you can use the same solr service for different sitecore instances.You need to make sure that both Sitecore versions are compatible with the solr version.

The only thing that you will need to change is the index names for the second instance.

For example, In both instances, the Sitecore master index will have the same name.

sitecore_master_index

You will need to rename it to something like sitecore_master_index_instance2. This has to be done for all sitecore indexes namely:

  • master
  • web
  • core

This can be done on the following configs:

  • Sitecore.ContentSearch.Solr.Index.Core.config
  • Sitecore.ContentSearch.Solr.Index.Master.config
  • Sitecore.ContentSearch.Solr.Index.Web.config
  • I have small doubt , by default Sitecore instance name is prefixed before the index/core name like "sc902_core_index", so is renaming of the index/core required ? – Pratik Wasnik Aug 29 '18 at 10:23
  • 2
    Depends on the version of Sitecore, since SIF and v9, the solr cores are already prefixed with the instance name. So no extra work is required. Prior to that, then you would need to manually do that. Also there are far more cores than just the 3 for a Sitecore 9 instance. – Richard Seal Aug 29 '18 at 12:01
  • Thanks for clarification Richard , yes my previous instance also is of Sitecore 902 version, hence was confused ! – Pratik Wasnik Aug 29 '18 at 12:10
0

Yes, you can with some considerations:

  1. Ensure that core names are unique for each Sitecore instance, so that data doesn't get overwritten.
  2. Ensure that Solr server version is compatible with Sitecore.
  3. Performance might be impacted if some instances of Sitecore take heavy load and index size grows significantly. However, it should be okay for development scenarios.
0

As other people have mentioned here it is possible to do this by renaming all the indexes in your 2nd instance. However since you won't be doing this in Production etc then this is a bit of an odd approach and could lead to confusion.

I'm not sure of your reasoning for this but I'm guessing it's because you don't want to have to spend time having to setup Solr again, you are not sure about how to run more than one instance of Solr on a single server or you are concerned about the performance of running multiple instances of Solr on one box.

I would say in my experience there is no issue with installing multiple instances of Solr on one server and that it is very easy to do and maintain. I'd recommend that you use a Powershell script like one from Jeremy Davis which will install Solr on a specific port for you (e.g not: 8983) and uses NSSM to install the Solr service under a specific name. This will easily allow you to identify and mange multiple Solr instances. You can do this on a local dev machine or on a dev or even UAT Server:

https://gist.github.com/jermdavis/8d8a79f680505f1074153f02f70b9105

With regard to performance the -Xmx value can be set to set the amount of memory that the JVM uses so this can be managed also if required: https://lucene.apache.org/solr/guide/6_6/jvm-settings.html

If this is not the reason please update your question to include your reasoning or comment below.

This is a better approach in my mind as:

  • You can upgrade each instance without a dependency on another Sitecore instance
  • It separates concerns so there is not potential issues arising from another site indexing lots of content etc
  • It reduces confusion regarding config and avoids the config somehow ending up deployed to other environments
  • Performance will likely be better
  • I do this all the time on my development machine. I might be working on 3 or 4 different projects at a time. No need to install Solr 4 times. Just use the same instance. – Richard Seal Aug 29 '18 at 11:59
  • 1
    I think thats fine on a dev machine. There wasn't really enough detail in the question to know what the context was here though. – Adam Seabridge Aug 29 '18 at 12:08
  • Yup - more detail definitely needed – Richard Seal Aug 29 '18 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.