Friday, July 13, 2012

SQL Server Report Service Migration from Server A to Server B


Pre-Requisites on SERVER B

1.       Install Reporting Services on SERVER B.
2.       Set following properties to False in “C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\rsreportserver.config” file:

·        IsSchedulingService>False
·         IsNotificationService>False
·         IsEventService>False
Restart the Reporting Service.

Migration of DBs

1.       Take the Full backups of the following DBs from SERVER A and restore it on SERVER B:
·         ReportServer
·         ReportServerTempDB
2.       Configure Reporting Services on SERVER B by going to START -> Programs -> Microsoft SQL Server 2005 -> Configuration Tools -> Reporting Services Configuration. Configure all the steps manually.
3.       Configuring Encryption Key: Open the above config tool on SERVER A and take the Encryption key backup. Restore the same encryption key on SERVER B using the above configuration tool.
4.       Set the following property values to true in “reportserver.config” file:

·        IsSchedulingService>False
·         IsNotificationService>False
·         IsEventService>False
Restart the Reporting Service.
Once these values are set, it will populate the SQL Server agent with subscription jobs.  All these jobs need to be disabled immediately. Else the subscription mails will start immediately unless the email execution account is not specified or the above config values are set back to false.


Issues and Errors

1.       You get the following error when you try to run the report URL:
·         "The feature: "Scale-out deployment" is not supported in this edition of Reporting Services."
Solution:
Delete SERVER A encryption key from the restored system. Run the following commands on SERVER B:
o   rskeymgmt -l -i InstName
o   rskeymgmt -i InstName -r SourceEncryptionKeyID

SQL Server Reporting Services Flow

1.       SQL Server Agent Jobs of subscriptions populates the Event table with subscription details.
2.       The following XML Config values determine if the subscriptions in the event table should be executed:

·        IsSchedulingService>False
·         IsNotificationService>False
·         IsEventService>False
Restart the Reporting Service.
3.       Once the Email Execution Account is setup, the subscriptions will be sent out if the above config values are set to true.

Revert Back to Server A as Reporting Server

                Stop Service on Server B

1.       Stop the Service “SQL Server Reporting Services(InstanceName)” on Server B
2.       Empty the Email execution account from Report Config.
3.       Empty the Events Table in ReportServer DB.
4.       Disable all the SQL Server Agent subscription jobs
5.       Set the Scheduling, Events and Notification service property values to ‘false’ in “Reportserver.config” file. Restart the Reporting Service.

Start Service on Server A

1.       Start the Service “SQL Server Reporting Services(InstanceName)” on Server B
2.       Enter the email execution account from Report Config.
3.       Empty the Events Table in ReportServer DB.
4.       Enable all the SQL Server Agent subscription jobs
5.       Set the Scheduling, Events and Notification service property values to ‘true in “Reportserver.config” file. Restart the Reporting Service.


Important Queries on Report Server DB:

1.       To determine which SQL Server Job is associated with which subscription:

SELECT      Schedule.ScheduleID AS SQLAgent_Job_Name,
            Subscriptions.Description AS sub_desc,
            Subscriptions.DeliveryExtension AS sub_delExt,
            [Catalog].Name AS ReportName,
            [Catalog].Path AS ReportPath, Subscriptions.SubscriptionID
FROM        ReportSchedule
      INNER JOIN
            Schedule ON
            ReportSchedule.ScheduleID = Schedule.ScheduleID
      INNER JOIN
            Subscriptions ON
            ReportSchedule.SubscriptionID = Subscriptions.SubscriptionID
      INNER JOIN
            [Catalog] ON
            ReportSchedule.ReportID = [Catalog].ItemID AND
            Subscriptions.Report_OID = [Catalog].ItemID
      INNER JOIN [Event] E ON
            E.[EventData] = Subscriptions.SubscriptionID

2.       Disable all the Subscription Jobs:

Select 'EXEC msdb.dbo.sp_update_job @job_name = '''
            + msdb.dbo.sysjobs.name
            + ''',@enabled = 0'
FROM        msdb.dbo.sysjobs
            INNER JOIN
                  msdb.dbo.sysjobschedules
                  ON msdb.dbo.sysjobs.job_id = msdb.dbo.sysjobschedules.job_id
            INNER JOIN
                  msdb.dbo.sysschedules
                  ON msdb.dbo.sysjobschedules.schedule_id = msdb.dbo.sysschedules.schedule_id
            INNER JOIN
                  ReportServer.dbo.ReportSchedule a
                  ON CONVERT(VARCHAR(100),a.ScheduleID) = msdb.dbo.sysjobs.name
            INNER JOIN
                  ReportServer.dbo.ReportSchedule c
                  ON msdb.dbo.sysjobs.name = CONVERT(VARCHAR(100),C.ScheduleID)
            INNER JOIN
                  ReportServer.dbo.Subscriptions d
                  ON c.SubscriptionID = d.SubscriptionID
            INNER JOIN ReportServer.dbo.Catalog e
                  ON d.report_oid = e.itemid

3.       Get which Stored Procedures are used in Reports:

;WITH xmlnamespaces (
    default
    'http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition',
    'http://schemas.microsoft.com/SQLServer/reporting/reportdesigner' AS rd
)
SELECT
    NAME AS reportname,
    q.value('@Name[1]', 'VARCHAR(50)') AS datasetname,
    x.value('DataSourceName[1]', 'VARCHAR(50)') AS datasourcename,
    x.value('CommandText[1]', 'VARCHAR(50)') AS spname
FROM
(
    SELECT NAME,
    CAST(CAST(content AS varbinary(MAX)) AS xml) AS reportxml
    FROM reportserver.dbo.catalog
) a
      CROSS apply
            reportxml.nodes('/Report/DataSets/DataSet') d(q)
      CROSS apply
            q.nodes('Query') r(x)
WHERE x.value('CommandText[1]', 'VARCHAR(50)') LIKE '%SPName%'

Migrating SharePoint Service DBs from One DB Server to Another


1.       Switch off the following SharePoint services on the Web Server :

·         Windows SharePoint Services Administration service
·         Windows SharePoint Services Search service
·         Windows SharePoint Services Timer service
·         Windows SharePoint Services Tracing service
·         Windows SharePoint Services VSS Writer service
This needs to be done so that no data is modified to the SharePoint site while the farm is being backed up and restored on the new server.

2.       Stop the Central Administration Web site on the Web Server.

3.       Create an Alias on the Web server from Source Server A to Target Server B. Alias can be created as follows:
Goto Start -> All Programs -> Microsoft SQL Server 2005 -> Configuration Tools -> SQL Server Configuration Manager. Click on SQL Native Client Configuration and create a new alias there with following details:
·         Alias Name = ‘Source Server A’
·         Protocol = TCP/IP
·         Server = ‘Source Server B’(Default Instance) or ‘Source Server B\Instance Name’(For Named Instance)

Alternately, the alias can also be created using the cliconfg.exe utility present in the systems folder as follows:

·         On the General tab, verify that TCP/IP is enabled.
·         On the Alias tab, click Add. The Add Network Library Configuration dialog box appears.
·         In the Server alias box, enter the name of the current instance of SQL Server.
·         In the Network libraries area, click TCP/IP.
·         In the Connection parameters area, in the Server name box, enter the new server name and instance to associate with the alias, and then click OK.

4.       Backup the SharePoint DBs on the Source Server A. I had the following DBs on my system to migrate it:
·         SharePoint_AdminContent_11a1a11a-111a-1111-aaaa-a1aa111a1111
·         SharePoint_Config
·         WSS_Content (Contents DB)
·         WSS_Search
Take full backups as well as the transactional log backups.
5.       Restore all the Full and Transactional log backups on the target server B.
6.       Copy all the required logins from Source Server A to Target Server B. Script to perform this can be found in the following link:
7.       Restart the Services and Website on the Web Server that was stopped in step 1 and 2.