Programming4us
         
 
 
SQL Server

Microsoft SQL Server 2008 Analysis Services : Productionization - Copying databases between servers

6/21/2012 4:33:54 PM

Analysis Services data directory maintenance

By default, all of the files used by Analysis Services to store MOLAP data are stored in the Analysis Services data directory. The location of this directory is set during installation, and can be changed by changing the value of the DataDir server property.

As with any other type of file handled by Windows, the files in the Analysis Services data directory are prone to fragmentation. During processing a lot of files are created, written, and deleted, and if the disk is very fragmented these files may be split across different portions of the disk, slowing down access to them.

A regular defragmentation of the drive on which the data directory exists will improve the overall speed of the disk subsystem, which will of course have benefits for Analysis Services query and processing performance. As a result we suggest regular disk defragmentation of the Analysis Services data directory's drive as part of the server's maintenance plan, making sure of course that it only takes place at a time when we are not processing or when users are not querying the cube.

Backup

It may be stating the obvious, but after processing has finished we should always back up our Analysis Services database. This can be done very easily from Integration Services using an Execute Analysis Services DDL task; once again, we can generate the XMLA command needed to back up a database by right-clicking on it in SQL Management Studio, selecting Back Up, and then pressing the Script button on the Back Up Database dialog.

Copying databases between servers

There are several scenarios where we may need to copy an Analysis Services database from one server with one on a different server. Here are a couple of examples:

  • We have several frontend servers directly accessible by users in the DMZ area of the network, and one backend server inside the internal network. When the cube is processed on the internal server, it needs to be duplicated to the frontend servers so that it can be queried by our users.

  • We have two powerful Analysis Services servers and several cubes. Half of the cubes are processed on one server and half are processed on the other. When both servers have finished processing, the databases are synchronized between the two servers, so they both have the same data and can share the query load.

Using Analysis Services 2008 we have three options to synchronize data between servers:

  • Use the Synchronize XMLA command: This is the preferred method in most situations. When executed, the Synchronize command tells one Analysis Services instance to synchronize a database with a database on another instance. During the synchronization process Analysis Services checks for any differences between the version of the database on the destination database and the version on the source server. Updated objects are copied over the network from the source server to the destination server until the destination is identical to the source.

    The XMLA needed for a Synchronize command can be generated in SQL Management Studio by right-clicking on Databases node of an instance in the Object Explorer pane, running the Synchronize Database wizard and at the end choosing to generate script rather than running the synchronization immediately. This XMLA command can be run from an Execute Analysis Services DDL Task in Integration Services.

    The synchronization operation might be slow in situations where there is a lot of data in a cube or where there are a lot of differences between the source and the destination. However, the major advantage of using this approach is that users can continue to query the destination server while synchronization takes place, although when synchronization has completed there will be a (usually short) period where new users cannot connect and new queries cannot be run, while the old version of the database is replaced by the new version.

    Note that synchronization cannot be used at the same time as lazy aggregation building is taking place because there is a risk of database corruption.

  • Use backup/restore: Even if this approach seems crude when compared with the more elegant Synchronize XMLA command, it has some advantages. For a start, we're going to be backing up our database anyway after it has been processed so using the backup to copy the database to another server will require little extra development. Secondly, we can take the same backup file and copy it to multiple destination servers, where they can be restored in parallel.

    A problem with this approach is that if we try to restore over our existing database on the destination server then we cannot query that database while the restore is taking place. One way of working around this would be to restore to a different database to the one that users are currently querying, and then to redirect all new queries to this second database after the restore has completed. This would be feasible if the only client tool used was Reporting Services, where connection strings can be parameterized, but not if a client tool like Excel was used. Another issue is that we have to copy the entire database over the network even if there is only a small amount of new data, and if the backup file is very large then this might take a relatively long time and require extra disk space.

  • Use Attach/Detach: This method simply involves detaching the database from the source server, copying the database files over to the destination server, detaching the old version of the database on the destination server and then reattaching the new version of the database. Since attaching and detaching a database is a very fast operation this method involves the minimum of downtime; it also has the advantage that if a database is attached to one instance with its ReadModeMode property set to ReadOnly, then the same database files can be attached to multiple other instances in the same way.

    The main problem with this approach is that when we detach a database it cannot of course be queried at all, and any open connections to it are closed. This may lead to errors in some client tools and, at best, all users will have to reconnect to the server once the attach operation has completed.

Our recommendation is to use the Synchronize command if it runs fast enough and doesn't result in queries being blocked for too long. If we can't use Synchronize because it takes too long, or we don't mind that connections will be dropped, then attach/detach is the best option.

Other -----------------
- Microsoft SQL Server 2008 Analysis Services : Managing processing - Partition processing & Managing processing with Integration Services
- Protecting SQL Server Data : CELL-LEVEL ENCRYPTION - Views and Stored Procedures (part 2) - Creating the Stored Procedures
- Protecting SQL Server Data : CELL-LEVEL ENCRYPTION - Views and Stored Procedures (part 1) - Creating the View
- Protecting SQL Server Data : Implementing Cell-Level Encryption
- Protecting SQL Server Data : Preparing for Cell-Level Encryption
- Microsoft SQL Server 2008 R2 : Monitoring Replication (part 2) - New and Improved Peer-to-Peer Replication
- Microsoft SQL Server 2008 R2 : Monitoring Replication (part 1) - Replication Monitoring SQL Statements
- Microsoft SQL Server 2008 R2 : Scripting Replication
- Processing and Storing Data in SQL Server 2005 : Data Migration from One Data Store to Another Data Store
- Processing and Storing Data in SQL Server 2005 : Implementing the Record Failure Code
- Processing and Storing Data in SQL Server 2005 : Data Tracking Validation
- Processing and Storing Data in SQL Server 2005 : Updating the FileWorker Class
- Microsoft SQL Server 2008 R2 : Setting Up Replication (part 4) - Creating Subscriptions
- Microsoft SQL Server 2008 R2 : Setting Up Replication (part 3) - Horizontal and Vertical Filtering
- Microsoft SQL Server 2008 R2 : Setting Up Replication (part 2) - Creating a Publication
- Microsoft SQL Server 2008 R2 : Setting Up Replication (part 1) - Creating a Distributor and Enabling Publishing
- SQL Server 2008 R2 : Basing the Replication Design on User Requirements
- SQL Server 2008 R2 : Planning for SQL Server Data Replication & SQL Server Replication Types
- SQL Server 2008 R2 : Replication Agents
- SQL Server 2008 : Replication - Subscriptions
 
 
Top 10
- Active Directory Domain Services 2008: Enable the Detailed Directory Service Replication Auditing Subcategory
- Windows Azure : Programming Access Control Service (part 9) - Configuring a Web Service Client to Acquire and Send SAML Tokens
- Message Routing in Exchange 2010 (part 2) - Reviewing and Configuring Message Routing Between Active Directory Sites
- Developing Applications for Windows Phone 7 : Data Binding (part 2)
- SQL Server 2008 : Viewing and Modifying Data (part 1) - Creating Views
- SharePoint 2010 : Publishing Service Applications to Remote Farms
- Programming with SQL Azure : Connecting to SQL Azure (part 1) - ADO.NET
- Writing Your First Phone Application - Adding Code (part 2)
- Setting Up Your Windows Home Server 2011 Network : Troubleshooting Network Problems (part 1)
- Sharepoint 2010 : Optimizing Outside of SQL Server
Most view
- Windows Phone7: Adding a Picture or Ringtone to a Contact
- Windows Server 2008 : Configuring Windows Media Services (part 5)
- Monitoring Exchange Server 2010 (part 1) - System Center Operations Manager 2007 R2
- SQL Server 2008: Troubleshooting SSB Applications with ssbdiagnose.exe
- Windows 7 : Disabling the Hidden Administrative Shares
- Programming Excel with VBA and .NET : Tasks in Visual Basic - Find Truth & Compare Bits
- iPad SDK : New Graphics Functionality - Introducing Dudel (part 2)
- SharePoint 2010 : Implementing and Configuring a Records Center (part 1) - Creating and Managing a Content Type & Creating the Records Center
- Processing and Storing Data in SQL Server 2005 : Data Tracking Validation
- Installing SQL Server 2008 Using a Configuration File