How to rebuild the reporting database on Kubernetes deployment


Description

On Kubernetes deployments, the rebuild of the reporting database is not supported out of the box and requires manual steps. The following article describes how to reprocess interactions that have already been aggregated into the reporting database in containerized deployment.

The procedure for non-container deployment is defined in the article Rebuild the reporting database.

Solution

To rebuild the reporting database do the following:
  1. Add secondary reporting connection strings:
    1. Modify cm.yaml and prc.yaml files by adding a new environment variable:
      - name: Sitecore_ConnectionStrings_Reporting.Secondary
      value: Data Source=$(Database_Server);Initial Catalog=Sitecore.Reporting.Secondary;User ID=$(Database_Username);Password=$(Database_Password)
    2. Run the apply -f .\ command on the folder with your YAML files. This updates the configuration of your deployment.
    3. Patch the web.config file on both Content Management and Processing instances:
      • Copy the web.config file locally using
        kubectl cp <Your-Pod-Name>:web.config.
        or
        kubectl cp <Your-Pod-Name>:web.config <Path-on-your-file-system>
      • Patch the mode value from "Strict" to "Greedy" in the web.config SitecoreConnectionStringsBuilder string:
        <add name="SitecoreConnectionStringsBuilder" mode="Strict" prefix="SITECORE_CONNECTIONSTRINGS_" stripPrefix="true" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment, Version=1.0.0.0, Culture=neutral" />
      • Copy the patched web.config back to your pod using kubectl cp "<path to copy from\.>" <required pod name> "<relative path where to put file>". For example:
        kubectl cp "C:\ResourcesProcessing\container-k8\sc10.0\k8s-sitecore-xp1\test_prc\web.config" prc-549bd89774-zjsdr:"."
      • Do this on both Content Management and Processing instances.
  2. Deploy the secondary reporting database:
    1. Get the DACPAC file of your reporting database (you can get it from the Sitecore Developer Portal).
    2. Connect to your SQL server.
    3. Deploy the reporting DACPAC file and set the name for your database as "Sitecore.Reporting.Secondary".
  3. Issue a rebuild command from a Content Management instance:
    1. Log in to Content Management backend and go to <sitename>/sitecore/admin/RebuildReportingDB.aspx
    2. Set the cut-off date and click Start.
  4. Reconfigure reporting database connection strings.  After the rebuild is finished you need to make sure that the reporting connection string points to the secondary reporting database.
    1. Modify cm.yaml and prc.yaml files again:
      • Edit the reporting variable:
        - name: Sitecore_ConnectionStrings_Reporting
        value: Data Source=$(Database_Server);Initial Catalog=Sitecore.Reporting.Secondary;User ID=$(Database_Username);Password=$(Database_Password)
      • Remove the Sitecore_ConnectionStrings_Reporting.Secondary value
    2. Run the apply -f .\ command on the folder with your YAML files.