A few days ago, I set up my very first SQL Always On cluster. It would be a very straightforward task, just two databases in a 2 basic availability groups and making sure one fails over with the other. Besides that, the customer also asked if we could let the report server fail over at the same time. Sure, no problem… except that this is an enterprise-only feature. Let’s see how we can achieve this on a standard edition.
In this post, I am going to assume you already have:
As you can see, we start with two nodes (Node1 and Node2). We have a basic availability group AG_SQL_TSQL on database TSQLV4 and a listener LSNR_TSQL. In my example, I’m using Windows Server 2016 and SQL Server 2017. This will work for all versions above SQL Server 2012.
First, we will have to install the report servers on both nodes. When we got the report server installed on both nodes, we have to get the report server database synchronized. At last, we will put all of this in a simple script, so we don’t have to do all of this manually.
In my installation I have left everything default, just to keep things simple. If you want to use different URL’s for the services, make sure you configure the second node exactly the same.
We will need the encryption key from the first node. Go to encryption keys and backup the key. You can already copy this key to your second node. I suggest you put the folder with the key near the data file of your report server database.
When you installed and enabled your report service, you should now be able to see your reports when you go to http://<NameNode1>:80/Reports.
Now we will configure reporting services the same on Node2 as we did on Node1. We don’t need to back up the encryption key from Node2. When you have done everything correctly, you will be able to go to http://<NameNode2>:80/Reports.
We are now running a separate reporting service on both our nodes. Since we have a basic availability group with a listener, we are able to connect to the reporting service from the primary node through the listener of the availability group.
All you have to do is connect to the URL http://<ListenerName>:80/Reports. In my case, this becomes http://lsnr_tsql:80/Reports.
When we connect to the URL while Node2 is primary, we will see the folder that we created on Node2.
This is nice but not really, what we needed. We want to see the same reports on both nodes.
An easy way to do this is a backup/restore from the primary database. The data in both nodes will be the same and the listener will switch between nodes on a failover.
Now we stop SSRS on the Node2 and restore the database with a full backup from Node1.
Make sure you select the options to overwrite the existing database.
Now we have the same data on both nodes and the connection will switch between nodes when they failover. Seems like we are done, or not? When we enable SSRS again and try to connect to http://LSNR_TSQL/Reports, we receive this error message.
To resolve this issue we have to delete the key entry in the database from Node2 and restore the key we saved from Node1.
Edit the table dbo.Keys and delete the records with the keys on Node2.
When we deleted the key from the database, we can now restore the key. Open SSRS Manager on Node2 and go to Encryption Keys. Click on restore and select the key file from Node1.
When you go to http://LSNR_TSQL/Reports now, you will see the same reports on both nodes. However, there is a drawback to this. Since we only synchronize from Node1 to Node2, reports can only be created on Node1.
I don’t think any of you want to sync their reporting services once or twice a day by hand. Don’t worry, we can write a script to manage all this for us. Since I am more experienced in PowerShell for the time being, I wrote a small PowerShell scripts to do this heavy task for me. Even if you have no knowledge of PowerShell, it will be very easy to follow.
To make the script I will be making use of DbaTools. If you havn’t heard from DbaTools as a Dba, just stop reading and check their website http://dbatools.io. It is a very powerful PowerShell module, which allows you to do most Dba-tasks in a single line of code.
Let’s explain the script. We want it to do 5 things:
If you don’t use the backup script from Ola Hallengern (https://ola.hallengren.com) then you just need to remove the switch “MaintenanceSolutionBackup” from the Restore-DbaDatabase function and set the path to the full backup from Node1 yourself.
You are able to schedule this script using Windows Task Scheduler or anything similar.
The argument in my case will be:
-ExecutionPolicy Bypass C:\SQLData\Scripts\Sync_ReportServer.ps1
Below I will give you the script I used to synchronize the report server. You need to fill in the parameters on the last line and schedule it. If you have done everything correctly, it should now synchronize the report server for you.
Function Sync-ReportServer {
[CmdletBinding()]
param (
[string]$password,
[string]$computerName,
[string]$backupPath,
[string]$keyPath
)
process {
# Stop reporting service
Stop-DbaSqlService -ComputerName $computerName -Type SSRS
# Restore reporting database
$backup = Get-ChildItem -Path $backupPath | Sort-Object LastAccessTime -Descending | Select-Object -First 1
Restore-DbaDatabase -SqlServer $computerName -DatabaseName ReportServer -Path "$($backupPath)\$($backup)" -WithReplace -IgnoreLogBackup -MaintenanceSolutionBackup
# Delete key
Invoke-Sqlcmd2 "Delete from dbo.Keys where MachineName IS NOT NULL;" -ServerInstance $computerName -Database "ReportServer"
# Start service
Start-DbaSqlService -ComputerName $computerName -Type SSRS
# Restore key
rskeymgmt.exe -a -f $keyPath -p $password -i $computerName
}
}
Sync-ReportServer -computerName '' -backupPath '' -keyPath '' -password ''
The script should take most of the burden off your shoulders. However, I wouldn’t recommend to use this solution when you edit or create reports constantly.
Thank you for reading, hopefully until next time!
© 2023 Kohera
Crafted by
© 2022 Kohera
Crafted by
Cookie | Duration | Description |
---|---|---|
ARRAffinity | session | ARRAffinity cookie is set by Azure app service, and allows the service to choose the right instance established by a user to deliver subsequent requests made by that user. |
ARRAffinitySameSite | session | This cookie is set by Windows Azure cloud, and is used for load balancing to make sure the visitor page requests are routed to the same server in any browsing session. |
cookielawinfo-checkbox-advertisement | 1 year | Set by the GDPR Cookie Consent plugin, this cookie records the user consent for the cookies in the "Advertisement" category. |
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
CookieLawInfoConsent | 1 year | CookieYes sets this cookie to record the default button state of the corresponding category and the status of CCPA. It works only in coordination with the primary cookie. |
elementor | never | The website's WordPress theme uses this cookie. It allows the website owner to implement or change the website's content in real-time. |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |
Cookie | Duration | Description |
---|---|---|
__cf_bm | 30 minutes | Cloudflare set the cookie to support Cloudflare Bot Management. |
pll_language | 1 year | Polylang sets this cookie to remember the language the user selects when returning to the website and get the language information when unavailable in another way. |
Cookie | Duration | Description |
---|---|---|
_ga | 1 year 1 month 4 days | Google Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors. |
_ga_* | 1 year 1 month 4 days | Google Analytics sets this cookie to store and count page views. |
_gat_gtag_UA_* | 1 minute | Google Analytics sets this cookie to store a unique user ID. |
_gid | 1 day | Google Analytics sets this cookie to store information on how visitors use a website while also creating an analytics report of the website's performance. Some of the collected data includes the number of visitors, their source, and the pages they visit anonymously. |
ai_session | 30 minutes | This is a unique anonymous session identifier cookie set by Microsoft Application Insights software to gather statistical usage and telemetry data for apps built on the Azure cloud platform. |
CONSENT | 2 years | YouTube sets this cookie via embedded YouTube videos and registers anonymous statistical data. |
vuid | 1 year 1 month 4 days | Vimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. |
Cookie | Duration | Description |
---|---|---|
ai_user | 1 year | Microsoft Azure sets this cookie as a unique user identifier cookie, enabling counting of the number of users accessing the application over time. |
VISITOR_INFO1_LIVE | 5 months 27 days | YouTube sets this cookie to measure bandwidth, determining whether the user gets the new or old player interface. |
YSC | session | Youtube sets this cookie to track the views of embedded videos on Youtube pages. |
yt-remote-connected-devices | never | YouTube sets this cookie to store the user's video preferences using embedded YouTube videos. |
yt-remote-device-id | never | YouTube sets this cookie to store the user's video preferences using embedded YouTube videos. |
yt.innertube::nextId | never | YouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen. |
yt.innertube::requests | never | YouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen. |
Cookie | Duration | Description |
---|---|---|
WFESessionId | session | No description available. |