3 4
In this section, you'll learn how to configure, monitor, and tune the distributor for transactional replication. As mentioned in the previous chapter, the distributor is a server containing the SQL Server database, called the distribution database, that is used as a repository of replication data. This data is held in a SQL Server database to provide several benefits, including the following:
Depending on the frequency of modifications to your database, the amount of activity in the distributor can be quite high. Because the distributor uses a SQL Server database, all modifications to the distributor must be logged in the transaction log. You should configure the distribution database and the log to be large enough to perform the work required and fast enough to perform it efficiently. While the default distribution configuration can work for smaller replication systems, it is inadequate for many systems because the SQL Server replication wizards do not place the SQL Server transaction log and data files optimally. They are usually placed on the default SQL Server volume and both transaction log and database files are placed on the same volume.
By configuring the distribution database appropriately, you can avoid costly performance problems. Here are a few guidelines for configuring the distribution database:
To properly configure the distribution database as outlined in the preceding list, you need to specify where this database resides. To do this by using Enterprise Manager, first invoke the Configure Publishing And Distribution Wizard. Use this wizard to set up publishing and distribution, specifying in the Customize The Configuration screen that you want to customize the distribution settings (by clicking Yes). This option allows you to set the distribution database location manually. (It also allows you to pick a name for the database, enable publishing, and create publications as well as subscribers.)
Unfortunately, when you use the wizard, you can't set the size of the distribution database. You can increase the size of the distribution database by selecting that database's properties in Enterprise Manager and changing the size of the database or transaction log files. If you prefer specifying the location and the size of the database at one time, you can use the sp_adddistributiondb stored procedure.
The system stored procedure sp_adddistributiondb allows you to script the creation of the distribution database. This is useful when you want to specify the size and location of the database and its transaction log. And once you have written a script that creates the distribution database, you can use it on different systems, or you can use it to re-create the distribution database in the event of a system reconfiguration.
NOTE
Before you can create the distribution database, you must enable the distributor. You accomplish this by using the system stored procedure sp_adddistributor, followed by the distributor's system name.
The syntax for the sp_adddistributiondb stored procedure is shown in SQL Server Books Online. An example of using that stored procedure is shown here:
sp_adddistributor Dash
The following SQL statement initializes the system named Dash as a distributor.
sp_adddistributiondb @database=dist, @data_folder='C:\mssql2000\data', @data_file='dist.mdf', @data_file_size=10, @log_folder='C:\mssql2000\data', @log_file='dist.ldf', @log_file_size=2, @min_distretention=0, @max_distretention=72, @history_retention=96, @security_mode=0, @login='sa', @password='', @createmode=0
You monitor the distributor by using Windows 2000 Performance Monitor (perfmon). Within perfmon are a number of objects that are added when SQL Server replication is used. These objects are as follows:
By using Performance Monitor to monitor these values, you can sometimes determine whether the distributor is experiencing a performance problem. This perfmon data provides a lot of valuable information, but it does not always identify problems. For monitoring the distributor, we are most concerned with the SQLServer:Replication Dist. object. This object provides the following counters:
While these counters give you some general indication of how the distribution process is running, they are of limited usefulness when you are determining whether you need to tune the distributor because the most important aspect of tuning the distributor is tuning the SQL Server database. Thus, you should look mainly for the following problems:
As mentioned earlier, the distributor is the server containing the distribution database, and this database must be tuned in the same manner as any other SQL Server database. You can enhance the performance of the distributor by properly sizing it, although, as you learned in Chapter 6, sizing is not always an easy task. The distributor should have enough capacity to handle extra work. The distributor is the link between the publishers and the subscribers and should be configured so that it is not a bottleneck. Some tips for configuring and tuning the distributor are provided here: