To keep Lync Server operating
smoothly and with optimal performance, Lync Server administrators
should conduct regular maintenance on each SQL Server database. Such
maintenance tasks include rebuilding indexes, checking database
integrity, updating index statistics,
and performing internal consistency checks and backups. Administrators
can perform database maintenance tasks either by executing Transact-SQL
commands or by running the Database Maintenance Wizard.
This section provides information and recommendations
for maintaining the databases that host Lync Server data and
configurations. Later in this section, administrators learn how to
automate and schedule the major maintenance tasks by creating database
maintenance plans through SQL Server Database Maintenance Wizard.
Checking and Repairing Database Integrity
DBCC CHECKDB is the most
frequently used validation command for checking the logical and physical
integrity of the whole database. Essentially, DBCC CHECKDB is a
superset command that actually runs CHECKALLOC, CHECKTABLE, and
CHECKCATALOG.
The following are some recommendations for using DBCC CHECKDB:
Administrators should run DBCC CHECKDB rather
than the individual operations because it identifies most of the errors
and is generally safe to run in a production environment.
After running DBCC CHECKDB, administrators should run it again with the REPAIR argument to repair reported errors.
DBCC
CHECKDB can be time-consuming and it performs schema locks that prevent
metadata changes; therefore, it is highly recommended that
administrators run it during nonproduction hours.
The command should run on a table-by-table basis if it is used to perform consistency checks on large databases.
Monitoring and Reducing Fragmentation
Although indexes can speed up the execution of
queries, some overhead is associated with them. Indexes consume extra
disk space and involve additional time to update themselves any time
data is updated, deleted, or inserted in a table.
When indexes are first built, little or no
fragmentation should be present. Over time, as data is inserted,
updated, and deleted, fragmentation levels on the underlying indexes may
begin increase.
When a data page of data is completely full and
further data must be added to it, a page split occurs. To make room for
the new data, SQL Server creates another data page somewhere else in the
database (not necessarily in a contiguous location) and moves some of
the data from the full page to the newly created one.
The effect of this is that the blocks of data are
logically linear but physically nonlinear. Therefore, when searching for
data, SQL Server has to jump from one page to somewhere else in the
database looking for the next page it needs instead of going straight
from one page to the next. This results in performance degradation and
inefficient space utilization.
Monitoring Fragmentation
The
fragmentation level of an index is the percentage of blocks that are
logically linear and physically nonlinear. In SQL Server 2008 R2, SQL
Server 2008, or SQL Server 2005, administrators can use the
sys.dm_db_index_physical_stats dynamic management function and keep an
eye on the avg_fragmentation_in_percent column to monitor and measure
the fragmentation level. The value for avg_fragmentation_in_percent
should be as close to zero as possible for maximum performance. However,
values from 0% to 10% may be acceptable.
Reducing Fragmentation
In the previous version of Communications Server, it
was recommended to track and reduce the fragmentation level by running
the database statistics timer job, which updates the query optimization
statistics and rebuilds all indexes in the content databases every time
it runs. Another option was reorganizing or rebuilding the indexes on a
regular basis using the SQL Server 2008 or SQL Server 2005 Maintenance
Wizard.
In Lync Server, administrators no longer need to
worry about fragmentation because Lync Server can do that on their
behalf through the health analyzer. The health analyzer performs health
checks based on timer jobs and self-heals the database index
fragmentation automatically.
Shrinking Data Files
In SQL Server 2005 and SQL Server 2008/R2,
administrators can reclaim free space from the end of data files to
remove unused pages and recover disk space.
Caution
However, shrinking data files is not recommended
unless the content database has lost at least half of its content. This
typically happens after activities that create whitespace in the content
database, such as moving a site collection from a content database to
another one or deleting a massive amount of data. Shrinking Lync Server
databases other than content databases is not recommended because they
do not generally experience as many necessary deletions to contain
considerable free space.
Shrinking a Database by Using SQL Server 2008 R2 Management Studio
The following steps show how to shrink a database by using SQL Server 2008 R2 Management Studio:
1. | Click Start, All Programs, Microsoft SQL Server 2008 R2, and SQL Server Management Studio.
|
2. | Connect to the desired SQL Server database engine instance and expand that instance.
|
3. | Expand Databases, right-click the database to be shrunk, click Tasks, click Shrink, and click Files.
|
4. | Select the file type and filename from the dialog box shown in Figure 1.
- a. Optionally, select Release unused space.
Selecting this option causes unused space in the file to be released to
the operating system and shrinks the file to the last allocated extent.
This reduces the file size without moving data.
- b. Optionally, select Reorganize files before releasing unused space. If this option is selected, the Shrink file option must be set to value.
Selecting this option causes unused space in the file to be released to
the operating system and relocates rows to unallocated pages.
- c. Optionally, select Empty file by migrating the data to other files in the same filegroup.
Selecting this option moves all data from the specified file to other
files in the file group. The empty file can then be deleted. This option
is the same as executing DBCC SHRINKFILE with the EMPTYFILE option.
|
5. | Click OK.
|
Creating SQL Server Maintenance Plans
Maintaining Lync Server back end databases can
significantly improve the health and performance of Lync Server servers.
Unfortunately, administrators often do not perform regular database
maintenance because maintaining Lync Server environments involves
several maintenance tasks.
Fortunately, Microsoft has provided maintenance plans
as a way to automate these tasks. A maintenance plan performs a
comprehensive set of SQL Server jobs that run at scheduled intervals.
Specifically, the maintenance plan conducts scheduled SQL Server maintenance tasks to ensure that databases are performing optimally, regularly backed up, and checked for anomalies.
Tip
Administrators can use the Maintenance Plan Wizard
(included with SQL Server) to create and schedule these daily tasks. In
addition, the wizard can configure database and transaction log backups.
Administrators should set maintenance operations or
maintenance plans to run during off-hours to minimize the performance
impact on users.
Configuring a SQL Server 2008 R2 Database Maintenance Plan
The following steps show how to configure a SQL Server 2008 R2 database maintenance plan:
1. | Click Start, All Programs, Microsoft SQL Server 2008 R2, and SQL Server Management Studio.
|
2. | Connect to the desired SQL Server database engine instance.
|
3. | Expand Management, right-click Maintenance Plans, and then click Maintenance Plan Wizard.
|
4. | On the Welcome to the Database Maintenance Plan Wizard screen, click Next to continue.
|
5. | On the Select a Target Server Plan Properties screen shown in Figure 2, enter a name and description for the maintenance plan.
|
6. | Decide whether to configure one or more maintenance plans.
To configure a single maintenance plan, select Single schedule for the entire plan or no schedule. This option is selected in this example.
To configure multiple maintenance plans with specific tasks, select Separate schedules for each task. This option is selected in this example.
|
7. | Click Change to set a schedule for one or more of the plans. The Job Schedule Properties dialog box displays, as shown in Figure 3.
|
8. | Complete the schedule, click OK, and then click Next to continue.
|
9. | On the Select Maintenance Tasks screen, select the maintenance tasks to include in the plan, and then click Next to continue.
|
10. | In
the Select Maintenance Task Order page, change or review the order in
which the tasks will be executed. Select a task, and then click Move up or Move down.
|
11. | When tasks are in the desired order, click Next. The wizard guides you through setting the details for each task. For example, Figure 4 shows the configuration of the Database Check Integrity Task.
|
12. | On the Select Report Options page, select Write a report to a text file.
|
13. | Select a location for the files as shown in Figure 5, and then click Next until the wizard is completed.
|
Note
Administrators should include
the Database Check Integrity maintenance task for all Lync Server
databases and the Maintenance Cleanup Task maintenance task in their
plans. It is also recommended not to select the option to shrink the
database, primarily because automatically shrinking databases on a
periodic basis leads to excessive fragmentation and produces I/O
activity, which can negatively influence the performance of Lync Server.