Deploying a Data-Tier Application
Now that we have created the dacpac
file for our UsedCars application, let’s connect to another instance of
SQL Server and deploy it. To start, connect to another SQL Server
instance using SSMS. Navigate to the Management and then Data-Tier
Applications nodes in Object Explorer. Right-click the Data-Tier
Applications node, and select “Deploy Data-tier application” to launch
a wizard that asks you which dacpac
file to deploy. This wizard is shown in Figure 3.
Figure 3. The Select Package page of the Deploy Data-tier Application wizard
After the wizard inspects the package, it asks
you for the name of the new database and location to store the database
files (see Figure 4).
Figure 4. The Update Configuration page of the Deploy Data-tier Application wizard
Next, the wizard will provide you with a
summary page and deploy your application. When the wizard completes,
you will have a new node under “Data-tier applications” called
UsedCars. Notice that you also have the UsedCars database created in
this instance. At this point, our UsedCar application is deployed to
the new server.
Registering an Existing Database as a Data-Tier Application
In the original SQL Server instance, we ran the Extract Data-tier Application wizard to create the dacpac
file. If all you want to do is take an existing database and make a
data-tier application on the same server, you can run the Register as
Data-tier Application wizard. To help showcase the monitoring piece of
data-tier applications, let’s register the UsedCar database on the
original SQL Server instance we used to create the dacpac
file. To do this, connect to the original instance of SQL Server, and
navigate to the UsedCar database in Object Explorer. Next, right-click
the database, and select Tasks and then “Register as Data-tier
Application”. This will launch a wizard. The first page of this wizard
will ask you to set the properties of the application. Much like we did
in the wizard shown in Figure 1,
we can enter a name, version number, and description. Once this wizard
completes, our UsedCar application will appear in the Data-tier
Application node of the Management node in Object Explorer for this
instance of SQL Server as well.
Monitoring a Data-Tier Application Using the SQL Server Utility
Today, more applications in our datacenters
need to be managed than in previous years. Not all of these are Tier 1,
mission-critical applications. On the contrary, many are departmental
Tier 2 and Tier 3 applications that support a subset of an
organization. Data-tier applications allow the database administrator
to focus on management at scale as opposed to micromanaging each
individual application. In the example in this section, we have two
instances of SQL Server: the default instance and an instance with a
name of INST2
. Since these applications are deployed, we can easily manage them through the SQL Server Utility.
In SQL Server 2008, the Performance Data
Collector feature was introduced. This feature allowed DBAs to
periodically poll a SQL instance for disk usage, query statistics, and
server health information. Data from these queries would automatically
be pushed into a database called the management data warehouse.
This powerful tool gave DBAs a quick view of the health of a particular
SQL Server instance. In SQL Server 2008 R2, this feature was expanded
to include a concept called the utility control point (UCP). The UCP is
a SQL Server instance designated as the central place to store and
report on performance information. To create a UCP in SSMS, select the
Utility Explorer menu item from the View menu in the SSMS toolbar. This
will display a Getting Started document window containing a hyperlink
to Create a Utility Control Point. Clicking this link will launch the
Create Utility Control Point wizard. The first input screen is shown in
Figure 5; it asks for a SQL Server instance to be used to create the UCP.
Figure 5. Specifying the SQL Server instance for the Create Utility Control Point wizard
The next page, shown in Figure 6,
asks you for the Windows account that will be used to run the utility
collect sets. Note that SQL Server Agent needs to be started on the
instance you select to be the UCP. If you forget to start SQL Agent,
the validation page will tell you and won’t allow you to proceed until
you start the service. Once the wizard has passed the validation
checks, the next page will create the UCP, as shown in Figure 6.
Figure 6. The Specify Account page of the Create Utility Control Point wizard
When the wizard has finished, it will bring you
to the Utility Explorer Content document window. This window gives you
a view of the overall health of all the managed instances and data-tier
application components that the UCP is monitoring. Let’s go ahead and
add a second instance of SQL Server to be monitored. Remember that the
SQL Server Agent service must be started on any SQL Server instance
that we want to monitor. To enroll a SQL Server instance, in the
Utility Explorer Utility node, right-click the Managed Instances
container node, and select Enroll Instance from the context menu. This
will launch a wizard for which the first input is the name of the SQL
Server instance to enroll. This page is shown in Figure 7.
Figure 7. Specifying the instance of SQL Server in the Enroll Instance wizard
Next, we specify the
Windows credentials for the account that will be obtaining the data on
that instance of SQL Server; this page is similar to Figure 6. The wizard will then perform checks, and if these are passed, it will enroll the instance.
The UCP will be updated periodically from all
the managed instances. At first, the new managed instance will be
shown, but since no data has been collected, the display will show a
gray circle as opposed to a green or red circle. This initial state for
the second instance, ROB-DENALI-1\INST2
, is shown in Figure 8.
Figure 8. Managed instances
After a few minutes, both managed instances
will report data to populate the Utility Explorer Content page. The
real power of the UCP comes not only in its ability to get a snapshot
of a server instance with respect to disk volume size and CPU trends
over the past few days but in its ability to define a policy based on
these statistics. For example, we can create a policy that says to mark
a SQL Server instance as being overutilized if it’s CPU usage is over
70 percent when sampled four times an hour. These policies are flexible
and can be managed by clicking the Utility Administration node in the
Utility Explorer. If a policy has been violated, the green circle shown
in Figure 8 would be red.
Up until now, we have been
discussing using UCPs to manage instances of SQL Server. UCPs can also
manage data-tier applications. Once you’ve enrolled a SQL Server
instance into a UCP, any data-tier applications that were defined
within that instance will show up in the Data-Tier Applications node in
the Utility Explorer. Since we have registered the UsedCars application
on both of our SQL Server instances, we can see the performance of this
application by clicking the Data-Tier Application node. This node is
shown in 9.
Figure 9. Data-tier Applications
We can now define policies like CPU and disk space limits to the application, just as we could for the instance.
Once we have all our managed instances
enrolled, we can get a good, quick view of the health of our
environment by clicking the Utility root node in the Utility Explorer.
The resulting report is shown in Figure 10.
Figure 10. A utility node report
Since we only have two instances and not a lot
of time has elapsed for data to be collected, this report looks fairly
blank, but you can see the kind of content that you will be able to
obtain from a real production environment.