Skip to main content

Sitecore Publishing target and Solr Configuration

Creating a new publishing target is very helpful if your Sitecore environment is setup in multiple content delivery servers. We can publish data from Master database to one or more publishing target databases. Main thing to notice here is Master database contains all versions of any content or assets while publishing target database contains single latest version for each language.

     This post aims to provide systematic instructions to set up publishing target. It comprises of a target database (where the content will be published) and publishing target definition item in master database that points to that target database. 
    
     Post creation of publishing target need to take care of Solr configuration. This post cove master slave Solr configuration and onPublishEndAsync strategy. We are using 1 Solr Master instance and 6 Slave instance (2-EU, 2-Ap, 2- NA).
   

1   Software used for this post

a.      OS – Window 7/ Windows Server 2008 R2 Enterprise
b.      CMS – Sitecore 8.0 (Update 1)
c.      Solr ( Master and Slave ) 
d.      SQL Server

                   


Create target database (where the content will be published) and do entry in  /App_Config/Include/ConnectionString.config file.

<add name="web_us" connectionString="Trusted_Connection=Yes;Data Source=T-SC_SQL\SITECORE;Database=PublishSCDBUSSitecore_Web" />


Open /App_Config/Include/Sitecore.config file and search for <databases> node.
Copy and paste existing <database> node  “web” and change the database id with the connection string name (web_us).

<!-- web _us-->
    <database id="web_us" singleInstance="true" type="Sitecore.Data.Database, Sitecore.Kernel">
      <param desc="name">$(id)</param>
      <icon>Images/database_web.png</icon>
      <securityEnabled>true</securityEnabled>
      <dataProviders hint="list:AddDataProvider">
        <dataProvider ref="dataProviders/main" param1="$(id)">
          <disableGroup>publishing</disableGroup>
          <prefetch hint="raw:AddPrefetch">
            <sc.include file="/App_Config/Prefetch/Common.config"/>
            <sc.include file="/App_Config/Prefetch/Webdb.config"/>
          </prefetch>
        </dataProvider>
      </dataProviders>
      <proxiesEnabled>false</proxiesEnabled>
      <proxyDataProvider ref="proxyDataProviders/main" param1="$(id)"/>
      <archives hint="raw:AddArchive">
        <archive name="archive"/>
        <archive name="recyclebin"/>
      </archives>
           <Engines.HistoryEngine.Storage>
          <obj type="Sitecore.Data.$(database).$(database)HistoryStorage, Sitecore.Kernel">
            <param connectionStringName="$(id)" />
            <EntryLifeTime>30.00:00:00</EntryLifeTime>
          </obj>
        </Engines.HistoryEngine.Storage>
        <Engines.HistoryEngine.SaveDotNetCallStack>false</Engines.HistoryEngine.SaveDotNetCallStack>
      <cacheSizes hint="setting">
        <data>500MB</data>
        <items>300MB</items>
        <paths>500KB</paths>
        <itempaths>10MB</itempaths>
        <standardValues>5MB</standardValues>
      </cacheSizes>
    </database>


Follow below steps to add publishing target in Sitecore master DB.
A)      Navigate to /sitecore/system/Publishing targets. Right click and add insert new publishing target.




B)      Give any significant name to publishing target definition item.  Enter database id (web_us) in the Target database Field. 




C)      Open Sitecore publishing dialog and you can see newly created publishing target.
                               
              


3.1    Create publishing strategy : we need to push the content from newly created DB to respective solr core.
·        Open file  App_Config/Include/Sitecore.ContentSearch.DefaultConfigurations.config
·        Copy already existing respective strategy and paste it.  
·        Change the name of strategy and provide the correct DB name as specified in connection string.
<onPublishEndAsyncWebUS type="Sitecore.ContentSearch.Maintenance.Strategies.OnPublishEndAsynchronousStrategy, Sitecore.ContentSearch">
            <param desc="database">web_us</param>
            <!-- Whether or not a full index rebuild should be triggered when the number of items in the EventQueue exceeds the number specified
               in ContentSearch.FullRebuildItemCountThreshold. -->
            <CheckForThreshold>true</CheckForThreshold>
 </onPublishEndAsyncWebUS>

3.2   Create another solr index related to current target database  and set the newly created strategy.
·        Create new file inside path: App_Config/Include and copy the data from another solr web index.    
New File Name :  Sitecore.ContentSearch.Solr.Index.NA.Web.config
·        Enter the meaningful index name ex : na_web_us_index
·        Enter newly created strategy Ex: onPublishEndAsyncWebUS
·        Enter newly created database for each crawler. Ex : Web_US
                                 
<indexes hint="list:AddIndex">
          <index id="na_web_us_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
            <param desc="name">$(id)</param>
            <param desc="core">$(id)</param>
            <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
            <configuration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration" />
            <strategies hint="list:AddStrategy">
              <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/ onPublishEndAsyncWebUS" />
            </strategies>
            <locations hint="list:AddCrawler">
              <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                <Database>web_us</Database>
                <Root>/sitecore/content/NA</Root>
              </crawler>
              <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                <Database> web_us</Database>
                <Root>/sitecore/content/Shared Data</Root>
              </crawler>
              <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                <Database>web_us</Database>
                <Root>/sitecore/media library/NA</Root>
              </crawler>
            </locations>
            <enableItemLanguageFallback>false</enableItemLanguageFallback>
            <enableFieldLanguageFallback>false</enableFieldLanguageFallback>
          </index>

3.3 Create another solr core inside CMS solr setup (Master) with current target database. 
Note: Master solr URL is : http://10.1.16.13:8983/solr
EX: Core Name -  na_web_us_index

3.4 Create another solr core inside CD solr setup (Slave) with current target database. 
Note: Create core for each slave with current database ID and modify master Url in solrconfig.xml file accordingly.

EX: Core Name - na_web_us_index

<requestHandler name="/replication" class="solr.ReplicationHandler" >
    <lst name="slave">
      <!--fully qualified url for the replication handler of master. It is possible
               to pass on this as
               a request param for the fetchindex command-->
      <str name="masterUrl">http://10.1.16.13:8983/solr/na_web_us_index/replication</str>
      <!--Interval in which the slave should poll master .Format is HH:mm:ss . If
               this is absent slave does not
               poll automatically.
               But a fetchindex can be triggered from the admin or the http API -->
      <str name="pollInterval">00:00:20</str>
    </lst>
  </requestHandler>




Happy configuration :) Feel free if you face any issue with same.


Comments

Post a Comment

Popular posts from this blog

Setup Sitecore Habitat v9.0 project in simple way

In this article , I would describe how to setup the Sitecore habitat V9.0 project with Sitecore Experience Platform 9.0 rev in very simple way. I used below system configuration to setup this project: 1. Windows 10 (32/64-bit) 2. IIS 10.0 3. .NET Framework 4.6.2 4. Microsoft Visual Studio 2017 5. Microsoft SQL Server 2017 6. Solr 6.6.2 7. Microsoft PowerShell® version 5.0 8. Web Platform Installer 5.0. 9. Web Deploy 3.6 for Hosting Servers 10. Node-v8.9.4-x64 Follow below steps to setup the project. A).   Habitat require Sitecore instance. Setup the clean Sitecore 9.0 instance. Ex : http://demo.local.com , Directory location : C:\inetpub\wwwroot\demo.local.com   For more info visit -   https://dev.sitecore.net/ B). Download the Habitat V9.0 project from Github site :  https://github.com/Sitecore/Habitat/     Note  :  When you download the packages, it is possible that the .ZIP packages are marked as blocke...

Web Deploy setup and configuration with Sitecore

Web Deploy empowers Visual Studio and WebMatrix to help developers streamline the deployment of Web applications to Microsoft IIS Web servers or to Microsoft Azure Websites. In addition, integration with Web Platform Installer allows developers to simply and easily install community webapplications.   This post describe the installation of Web Deploy and Configuration with Sitecore instance.  This post will be very useful if you want to sync your Sitecore media items with all of the CD's environment (Distributed environment) . In one of my previous project, I was keeping all the media items in file system and synchronizing all the files from CM to Cd's server. This solution is tested with 1 CMS and 6 CD's server (2-EU, 2- NA, 2- AP) with more than 5 Lakh files.  1.       Software Pre-requisites           a.       OS – Window 7/ Windows Server 2008 R2 Enterprise       ...