AppFabric Monitoring on Oracle 10g XE

advertisement
Windows Server AppFabric
Monitoring on Oracle
Database
Contents
Windows Server AppFabric ships with an out of the box solution for storing Monitoring records in a SQL
Server 2008 database. In order to use the monitoring feature set with Oracle you need to do two main
things: have a basic understanding of how Windows Server AppFabric monitoring records are collected
and then migrate the schema objects from SQL Server to Oracle. This solution s article we provide
guidance on both, showing you how to get setup with the SQL Express equivalent of Oracle along the
way. ............................................................................................................................................................... 2
Monitoring Event Collection Basics .............................................................................................................. 2
Schema Objects Involved .......................................................................................................................... 3
Oracle Schema Objects Provided .............................................................................................................. 4
Oracle Setup Procedure ................................................................................................................................ 5
Install Pre-Requisites................................................................................................................................. 5
Install Oracle 10g XE (Express Edition) ...................................................................................................... 5
Install & Configure ODP.NET ..................................................................................................................... 9
Setting up the Monitoring Schema in Oracle.............................................................................................. 13
Configure ODP.NET ................................................................................................................................. 13
Create the Monitoring Connection String .............................................................................................. 15
Create the Monitoring Schema Objects.................................................................................................. 15
Configure AppFabric to use the Oracle Monitoring Store ...................................................................... 16
Viewing the monitoring data in Oracle ....................................................................................................... 17
Connecting to Oracle within SQL Developer........................................................................................... 17
Exploring the Schema in SQL Developer ................................................................................................. 19
Viewing the monitoring data with IIS Manager .......................................................................................... 20
Troubleshooting Setup................................................................................................................................ 22
Implementation Notes ................................................................................................................................ 22
Scheduling Calls to ImportEvents ........................................................................................................... 22
Project Files ............................................................................................................................................. 22
Management PowerShell Scripts & User Interfaces ............................................................................... 23
About the Required Hotfix ...................................................................................................................... 24
1
AppFabric Monitoring on Oracle
Database Systems
Windows Server AppFabric ships with an out of the box solution for storing Monitoring records in a SQL
Server 2008 database. In order to use the monitoring feature set with Oracle you need to do two main
things: have a basic understanding of how Windows Server AppFabric monitoring records are collected
and then migrate the schema objects from SQL Server to Oracle. This solution s article we provide
guidance on both, showing you how to get setup with the SQL Express equivalent of Oracle along the
way.
Monitoring Event Collection Basics
Before attempting to leverage another database to store AppFabric monitoring records, it’s important to
understand the event life-cycle leading up to the event being written in the database. With the out of
the box configuration using SQL Server 2008 the life cycle is as shown in Figure 1.
Figure 1 - The event collection lifecycle.
2
The diagram itself describes most of the details. There are, however, a few things you should be aware
when planning a migration to Oracle.
First, the Event Collector can be configured to use any ADO.NET Provider registered in the
machine.config of the system to write to the target database. Out of the box, this means using
System.Data.SqlClient. The mechanism the Event Collector uses for writing the records to the staging
table can be either batch or bulk insert. The most performant method is to use a bulk insert, though this
requires the implementation of a IBulkCopy for the target database. For our purposes in targeting an
Oracle Database, we will instead make use of the Oracle Data Provider (ODP.NET), whose provider is
Oracle.DataAccess.Client. We have provided an implementation of IBulkCopy that uses the
OracleBulkCopy functionality of ODP.NET to bulk insert records into the staging table in Oracle.
Second, the records collected by the Event Collector are not made available immediately to users of the
monitoring store (such as the AppFabric Dashboard or the Tracked Events Views in IIS Manager). This is
because all records are first staged to the ASStagingTable and, because the processing is a little resource
intensive, these records are shredded (by the ASImportEvents stored procedure) every 10 seconds from
the single row inserted per event to the appropriate tables for WF or WCF Events, for example. The
mechanism that triggers the execution of the stored procedure varies depending on which version of
SQL Server is used. For SQL Express, a Service Broker Dialog Timer is used to periodically kick off the
processing, for non-express versions a SQL Agent Job is used. Obviously, neither of these is an option in
Oracle, and we will show how to implement an equivalent.
One last point, the records are never accessed or manipulated directly by the AppFabric tooling. The
Dashboard and Tracked Events views all access the data through similarly named views that perform
some translation on the data stored in the table.
Schema Objects Involved
With that overview in mind, we can turn our attention to the migration. Specifically, what needs to get
migrated and how. The schema objects can be grouped into three different categories based on the
functionality they support: staging of collected event data, the “shredding” of staged records into their
final form and other functionality (which provides support for Enterprise features like table partitioning,
auto purging of aged records and archival mostly used by PowerShell scripts).
With that separation of concerns in mind, here’s a listing of what a migration entails, grouping the
schema objects according to their function.
3
Key:
Oracle Schema Objects Provided
In the files that accompany this article, we have provided the scripts to create all of the schema objects
in Oracle to satisfy the Load Staging and “Shredding” feature sets. Collectively these should provide the
functionality needed to monitor the system using the AppFabric extensions in IIS Manager.
4
Oracle Setup Procedure
In order to use the schema objects provided, you will need to install Oracle. Oracle offers a free version
of its database. The latest incarnation is branded Oracle 10g Express Edition or just Oracle 10g XE. The
steps that follow will walk you through installing and configuring Oracle 10g XE.
Install Pre-Requisites




OS is either Windows 7 (32 or 64 bit) or Windows 2008 (32 or 64 bit) or Windows Server 2008
R2
Install SQL Server 2008 Express (for reference or use for persistence store)
Install Visual Studio 2010 RTM or at least .NET 4.0
Install Windows Server AppFabric RTM.
o At the end of the install, Register & Initialize the Monitoring & Persistence databases for
SQL Server to have them as a reference.
Install Oracle 10g XE (Express Edition)
1. Download Oracle 10g XE.
2. Run the installer as an Administrator.
3. Click Next on the Welcome screen
4. Accept the license agreement.
5
5. Choose the install location (defaults are typically OK). Click Next.
6. Enter a password for the auto-generated SYSTEM account. Write this down somewhere!
6
7. Review settings and click Install.
8. Leave the "Launch the Database homepage" checkbox checked and click Finish.
7
9. In the browser window that opens, log in with the SYSTEM account using the password you
entered during setup.
8
10. Leave this window open. If you close it, you can always return to it via the link installed under
the Start Menu->Oracle Database 10g Express Edition->Go To Database Home Page.
Install & Configure ODP.NET
As mentioned previously, we will use ODP.NET as the ADO.NET Provider for communicating with the
Oracle Database, as this is now the preferred provider to use given that the Microsoft
System.Data.OracleClient provider has been deprecated.
1. Download the latest release of ODP.NET (you should see a Table of Contents on the right that
contains links to the downloads).
a. Currently the 32-bit and 64-bit downloads are different. The 32 bit version offers a beta
release that can fully support .NET 4. This package also offers Visual Studio integration, get
the ODP.NET 11.2.0.11 Beta installer here.
b. To install on Windows 7 x64, Windows Server 2008 x64 or R2 use the ODAC 11.1.0.7.0 for
Window Server 2008 x64 installer. In this document, we show installing this version.
9
2. Extract the downloaded ZIP.
3. Run Setup.exe in the extracted files as an Administrator.
4. Choose a Custom install and click Next.
5. Leave English as the Selected language. Click Next.
10
6.
Choose the base installation path and click Next.
7. In the Available Product Components, select only the Oracle Data Provider for .NET and click Next.
11
13. Click Finish to perform the installation.
15. Click Close when finished. You now have ODP.NET installed.
12
Setting up the Monitoring Schema in Oracle
Configure ODP.NET
The current version of ODP.NET does not register the DbProviderFactories for .NET 4, it only includes
assemblies for .NET 2.0. To correct this, and make it available to AppFabric, you will need to edit
machine.config.
1. Navigate to the x64 machine.config for .NET 2.0 in
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG.
3. Open it with notepad.
4. Scroll down to the DbProviderFactories, which should look similar to the following.
13
5. Copy the entry for Oracle Data Provider for .NET (which targets .NET 2.0 x64), which currently has
this value:
<add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client"
description="Oracle Data Provider for .NET" type="Oracle.DataAccess.Client.OracleClientFactory,
Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
7. Open machine.config for .NET 4 from
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config (if using Notepad, be sure to run
Notepad as Administrator).
8. Scroll down to the DbProviderFactories element and paste the copied value.
10. Save the changes.
14
Create the Monitoring Connection String
1. You can use Oracle's EZ CONNECT syntax for adding a connection string to the Oracle database.
2. Run notepad as an Administrator and open the root web.config available at
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config
3. Scroll down to the bottom to view the connectionStrings section. It may contain SQL connection
string created by AppFabric.
4. You will need to add a connection string (using EZ CONNECT syntax) to your Oracle install that
uses the invariant name of the DbProviderFactory you added to machine.config for the value of
the providerName (it should be Oracle.DataAccess.Client):
<add connectionString="Data Source=conviction/xe; User Id=SYSTEM; Password=*********"
providerName="Oracle.DataAccess.Client" name="AF_Monitoring_Oracle" />
Create the Monitoring Schema Objects
1. Log in to Oracle.
2. Click SQL Scripts.
3. Click Upload.
4. Browse to the provided SQL file, AppFabricMonitoringOracle.sql.
5. Name the Script AF Monitoring Schema.
6. Click Upload.
7. Click the newly created AF Monitoring Schema.
9. Click Run.
15
Configure AppFabric to use the Oracle Monitoring Store
1. First you need to register the BulkCopy implementation. In the provided files, this is the
OracleMonitoring.dll assembly.
2. Copy this assembly into the AppFabric installation folder (%windir%\System32\AppFabric).
3. Open the root web.config and configure AppFabric to use the Bulk Copy provider by adding a
bulkCopyProvider entry to the bulkCopyProviders element near the bottom of the web.config (if
you will not be using SQL Server, you should comment out the entry for that provider):
4. Save the web.config.
5. Open IIS Manager, at the level in the hierarchy (server, site or application) that applies to you
choose Manage WCF and WF->Configure…
6. Choose the Monitoring tab.
7. In the connection string drop down list, select the connection string you created for monitoring in
Oracle.
8. Click OK.
16
9. Click YES to the recycle prompt.
Viewing the monitoring data in Oracle
Just as you might open SQL Server Management Studio to view the monitoring data stored by AppFabric
in SQL Server, you can use Oracle SQL Developer to view the data captured. Oracle SQL Developer is a
free tool you can download directly from Oracle at http://www.oracle.com/technetwork/developertools/sql-developer/downloads/index.html. Installation consists of ensuring you have that correct
version of the Java SDK (JDK) and then simply unzipping the package to run the sqldeveloper.exe
executable.
Connecting to Oracle within SQL Developer
Once you have SQL Developer open, you will need to make a connection to your local instance. From
the Connections pane (use View->Connections if it’s not visible), right click the Connections node and
select New Connection as shown:
In the New / Select Database Connection window that appears, you need to fill in the fields as follows to
connect to the local instance you installed by following the instructions in this document:
Field Name
Value
Connection Name
A user friendly name for your connection. For example:
local (SYS)
Username
SYS
Password
The password provided at installation time
17
Save Password
Optionally checked.
Role
Should be set to default. If you are using the SYSTEM
user account (instead of SYS), you will need to set this
to SYSDBA.
Connection Type
Leave as Basic
Hostname
localhost
Port
The value set for the Oracle Database Listener. Default
is 1521
SID
xe
Then click Test and verify you get a “Status: Success” message in the bottom left corner, as shown:
Finally, click Connect to add the connection to the list of connections.
18
Exploring the Schema in SQL Developer
Once you have your connection established, you can expand the various categories to explore the
tables, views, procedures, functions, triggers and sequences defined. For the purposes of examining any
captured monitoring data, expand the Views node. The following screenshot shows the views node with
a filter applied to only display the AppFabric views (you right click on the Views folder and select Apply
Filter to define a filter, we used NAME LIKE AS%):
These are the views that drive the data seen in the Dashboard and Tracked Events views within IIS
Manager.
Clicking on ASWFINSTANCES will open a tab to the schema of the view as shown:
19
To view the data click the Data tab just underneath the ASWFINSTANCES label, you will get a view
similar to the following listing tracked workflow instances:
You can explore the other views in a similar fashion to examine detailed WCF and WF events, tracked
variables and annotations.
Viewing the monitoring data with IIS Manager
Once you have configured AppFabric to write records to Oracle, aside from verifying the data with SQL
Developer, you do not have to configure IIS Manager to view the data in the Dashboard or Tracked
Events views. You simply use it as you had when backed with a SQL Server database.
For example, here is a screenshot of the Tracked WF Instances view for a workflow service:
20
NOTE: Currently, in order for IIS Manager to correctly process the Oracle records returned by ODP.NET
when querying the Oracle views, a hotfix is required that updates one of the assemblies used by the IIS
Manager extension. Please contact the author of the blog posting for instructions on how to obtain it.
21
Troubleshooting Setup
If you are having difficulty viewing monitoring events logged to Oracle from IIS Manager, you can
generally identify the source of the problem from the event viewer. Here’s how:
1. Most connection issues are logged in the Event Viewer, to view them go Start->Administrative
Tools->Event Viewer.
2. Expand the Custom Views folder.
3. Select the Administrative Events.
4. Look for recent events with a Source of Application Server - System Services Event Collector
Implementation Notes
Scheduling Calls to ImportEvents
Recall from the introduction in Monitoring Event Collection Basics that AppFabric schedules a call to the
ASImportEvents stored procedure such that it will run every 10 seconds. The recommended approach to
schedule recurring tasks in Oracle is to use the DBMS_Scheduler package’s create_job method, which is
what we do in the schema scripts provided:
PL/SQL
BEGIN
DBMS_SCHEDULER.create_job (
job_name
=> 'AF_Monitoring_ImportEvents',
job_type
=> 'PLSQL_BLOCK',
job_action
=> 'BEGIN ASImportEvents(…); END;',
start_date
=> SYSTIMESTAMP,
repeat_interval => 'freq=secondly; interval=10',
end_date
=> NULL,
enabled
=> TRUE,
comments
=> 'Periodically shreds records from ASStaging tables into target
tables.');
END;
Project Files
The associated files includes a Visual Studio 2010 solution that contains all of the sql and .NET source
used in support of the monitoring schema. The following screenshot shows the major component of the
solution:
22
Here are the highlights:


Oracle Bulk Copy Provider: The Bulk Copy provider is defined in the OracleMonitoring project.
SQL Scripts: The OracleMonitoring project also includes a Text Transform Template called
AppFabricMonitoringOracle.tt. It collects all the SQL scripts defined at the solution level under
the Solution Items\Oracle Monitoring Schema folder for the monitoring schema and
concatenates them into one SQL script (the one used during installation). If you need to make
changes to any of the schema objects, change the SQL file representing that object, and then
rebuild the OracleMonitoring project to get a new AppFabricMonitoringOracle.sql script.
Management PowerShell Scripts & User Interfaces
The SQL Server based installation also provides PowerShell scripts that provide functionality for
archiving and purging of monitoring records in the SQL Server database, as well as for creating and
deleting the monitoring database itself. In addition the Configure AppFabric Wizard includes a UI that
leverages some of these scripts as a part of creating and configuring monitoring. All of these are SQL
23
Server specific and would need to be migrated if a complete 1:1 migration were desired. This kit does
not include these items.
About the Required Hotfix
The QFE required in order to use the Dashboard and Tracked Events views fixes various type-casting and
SQL syntax issues that closely couple the data access logic to Microsoft SQL Server and are not
compatible with Oracle.
24
Download