Author Archives: tore
DR for a Replication Server
Restoring a Primary Database
________________________________________________________________________
Phase I: Clean up the old system
1) Log on to your primary Replication Server and suspend the DSI connection to the
primary database.
suspend connection to srv1.pdb
2) Re-create the primary database.
- · If your primary database is irretrievably damaged, drop it. If the database is
- · Drop any damaged database devices using sp_dropdevice.
- · Create new database devices using disk init (if necessary).
- · Create the new database using create database with the for load option.
- · Load the database from the database dump.
- · Restore any transaction log dumps.
- · Activate the database using the online database command.
- · Recover any data modification lost from the primary database.
- · Re-synchronize the replicate database:
- · Re-materialize the replicate database.
- · Run rs_subcmp.
- · Replay the transaction log from a log backup.
- · Examine the error log of your primary Adaptive Server, looking for a message
- · Run sp_help_rep_agent on the RepAgent for the temporary recovery database:
- · Examine the error log of your primary Adaptive Server, looking for a message
- · Run sp_help_rep_agent on the RepAgent for the temporary recovery database:
- · Re-materializing the replicate database.
- · Running rs_subcmp.
- · In UNIX, you can use the touch command to create a file.
- · In Windows NT, you can create a file using a utility program such as Notepad.
- · Compare the primary and replicate databases, and replace any lost data.
- · Use the ignore loss command to restart replication.
- · If your RSSD database is irretrievably damaged, drop it. If the database is marked
- · Drop any damaged database devices using sp_dropdevice.
- · Create new database devices using disk init (if necessary).
- · Create the new RSSD database using create database with the for load option.
- · Load the database from the database dump.
- · Load the database from any transaction log dumps. Be sure to apply the
- · Activate the database using the online database command.
- · Compare the primary and replicate databases, and replace any lost data.
- · Use the ignore loss command to restart replication.
- · Clear the RSSD’s LTM truncation point:
- · Move the transaction log forward. Execute the following batch multiple times (40
- · Reset the RSSD’s LTM truncation point:
- · Increment the generation id number in the RSSD:
- · To start your Replication Server in normal mode, you should have a run server file
- · To start a RepAgent in normal mode, run the following command:
Miscellaneous suggestions
10) Document your system, so that you know the names and locations of all important objects. 11) Create rs_subcmp parameter files for every subscription you are replicating, so that you don’t need to create them during a crisis. 12) On a regular basis, run rs_subcmp against your primary and replicate tables to ensure that they truly are synchronized.How much Procedure cache
To caculate how much procedure cache you need, there’s a set of calculations which can be performed;
The upper size = (Max number of concurrent users) * (Size of the largest plan) * 1.25
The lower size =(Total number of procedures) * (average size of query plan) * 1.25
To work out the largest query plan size execute the following query in the main user database;
select max(count(*)/8 +1)
from sysprocedures
group by id
And to find the average size use this;
select avg(count(*)/8+1)
from sysprocdures
group by id
To calculate the total number of stored procdures execute the following query;
select count(*)
from sysobjects
where type=”p”
Max number of concurrent users is found from the result of sp_configure “max number of users”
Say for example the results came out to be 21MB and 3MB a reasonable figure could be 6MB but obviously if you have 21MB for the procedure cache then that is ideal, this canbe achieved by increasing total memory so that 20 % of total cache is 6MB or by altering the percentage of procedure cache out of total cache.
Common Repserver commands
a quick guide to some of the more common commands you’ll need;
Create connection
create connection to phoebe.sundry set error class rs_sqlserver_error_class set function string class rs_function_string_class set username sundry_maint set password sundry_maint_ps with log transfer on The log transfer on means that it will be able to replicate data as well as receive it. Also rememebr that you have to add the database to the replication server by using rs_init in the install directory. This installs the stored procs and tables into the db as needed by the repserver.Create replication definition
create replication definition rep1 with primary at phoebe.sundry with all tables named ‘alpha1’ (a int, b char(10)) primary key (a)Create subscription
create sybscription sub1 for rep1 with replicate at phoebe.sundry2check subscription
check subscription sub1 For rep1 With replicate at phoebe.sundry2 You can also use the command rs_helpsub from the RSSD of the repserver.resume connection
This restarts the dsi threads etc resume connection to phoebe.sundry2drop subscription
drop subscription sub1 for rep1 with replicate at phoebe.sundry2 This sometimes doesn’t work if this is the case then go into the RSSD database for the replication server and delete the relevant line from the rs_subscriptions table, you have to do this if you want to drop the connection.Admin who
This will tell you what is up or down etcAdmin who_is_down
Tells you specifically what isn’t working If it’s a connection then try to suspend the connection and resume it, if it’s a repagent then use sp_stop_rep_agent <dbname> from the dataserver and then sp_start_rep_agent <dbname> to get i8t working again, if that fails check the error log.Rs_subcmp
This is a program which can be found in the bin directory of the Replication server installation, it is used to resyncronise the replicate database with the primary database, after a system failure, the sysadmin manual has an exstensive description of its use. The best way to run this is to create a config file for it to run against. The config file will look something like; PDS = TOKYO_DS RDS = SYDNEY_DS PDB = pubs2 RDB = pubs2 PTABLE = titleauthor RTABLE = titleauthor PSELECT = select au_id, title_id, au_ord, royaltyper from titleauthor order by au_id,\ title_id RSELECT = select au_id, title_id, au_ord, royaltyper from titleauthor order by au_id,\ title_id PUSER = repuser RUSER = repuser PPWD = piglet RPWD = piglet KEY = au_id KEY = title_id RECONCILE = Y VISUAL = Y NUM_TRIES = 3 WAIT = 10 If this file was called reconcile1.cfg then the command would be rs_subcmp –f reconcile1.cfg If you want to reconcile the primary database from the replicate database then you would swap around the PDB and RDB and also the PDS and RDS. You could either have a separate file for this or use command line options, -d for the replicate database and –D for the primary database and then –s for the replicate dataserver and –S for the primary dataserver.Sysadmin log_first_tran
This command will find the transaction which failed to be replicated, it’s run from the replication server controlling the database with the problem. It writes the output to the exceptions log. This consists of 3 tables in the RSSD for the Repserver, rs_excepthdr, rs_exceptcmd and rs_exceptslast. These tables should be purged periodically after having fixed the problem. You use rs_helpexception to see a list of the exceptions stored in the RSSD. And to delete it you would use rs_delexception.Duplicate row removal from a table
The way to do this is to create a copy of the table using
In this example I will assume I have a table called apple in database plum, and the column you want to make unique is called fruit
select * into tempdb..apple
from plum..apple
next create an identity column on this new table:
alter table tempdb..apple
add pip numeric(5,0) identity
The following query will now eliminate the duplicate entries of fruit;
delete from tempdb..apple
where pip in (select a.pip from tempdb..apple a, tempdb..apple b
where a.fruit = b.fruit
and a.pip > b.pip)
You will now have the table unique on the column fruit and you can put the data back into the original table (minus the identity column created with the following:
First delete or truncate the original plum..apple
then
Select fruit,… , <columns in plum..apple>
Into plum..apple
From tempdb..apple
Setting up a Historical server recording
Setting up a historical server recording
As a rough guide just to see how it all works after you have the monitor server and historical server running execute the following on the historical server (log in using isql);Example
Suppose you want to record, once every second, the reads, writes, and total I/O per device on an Adaptive Server that is monitored by the SMS1100 Monitor Server. You can use the following steps to record the data, create a table to accept the data, and then use the bcp utility to import the data into the table. In this example, the view data file that is created by Historical Server for the view is d1_1_device_io.- Use isql to log in to Historical Server.
- Record the data by using the following commands:
hs_create_recording_session capella_mon, 30
go
hs_create_view device_io,
"device name", "value for sample",
"device reads", "value for sample",
"device writes", "value for sample",
"device i/o", "value for sample"
go
hs_initiate_recording
go
- Use isql to log in to Adaptive Server. Because the recording session contains only one view (“device_io”), create just one table in the pubs2 database to store data for that view by using the following transact sql commands:
use history
go
create table device_io
(
sample_time datetime not null,
device_name varchar (255) null,
device_reads_val int null,
device_writes_val int null,
device_io_val int null,
)
go
- After the recording session is complete, you can use bcp to import data from the view’s data file into the database table. Use the following commands:
bcp history..device_io in d1_1_device_io -c -e d1_1_device_io.err -U username -P password -S server –t\,
Appendix
Table of data items and definitions
Table A-1 describes the data items available for inclusion in recording session views. The table lists data items in alphabetical order and provides the following information about each one:- A definition
- An Adaptive Server release dependency designation
- A result or key designation
| Table A-1: Data items and definitions Data item | Description |
| Application Execution Class Version: 11.5 and later | Configured execution class, if any, for a given application name. Because of override features, the configured execution class does not necessarily reflect the priority and engine group at runtime. The following notations are used in the monitor:
|
| Application Name Version: 11.0 and later | Name of application for which other statistics are being accumulated. Views that contain Application Name report only on processes that are active as of the end of the sample period. Application name is mutually exclusive with Process ID in a view. Type: Key |
| Blocking Process ID Version: 11.0 and later | ID of the process that holds a lock that another process is waiting for, if any. A returned value of zero means that the other process is not blocked. Type: Result |
| Cache Efficiency Version: 11.0 and later | The number of cache hits per second per megabyte of a particular data cache. Type: Result |
| Cache Hit Pct Version: 11.0 and later | The fraction of the page reads for objects bound to a particular data cache that are satisfied from the cache computed from the following formula: cache_hits / (cache_hits + cache_misses) * 100 Type: Result |
| Cache Hits Version: 11.0 and later | The number of times a page read was satisfied from a particular data cache. Type: Result |
| Cache ID Version: 11.0 and later | The ID of a data cache in Adaptive Server version 11.0 or later. Particular database tables and indexes may be bound to a specific data cache, or all objects in a database may be bound to the same data cache. No object may be bound to more than one data cache. Type: Key |
| Cache Misses Version: 11.0 and later | Number of times a page read was satisfied from disk rather than from a particular data cache. This data item includes failed attempts to locate pages in the data caches during page allocation. Therefore, the number of physical page reads reported may be overstated. If this occurs, the percentage of data cache misses reported by Cache Hit Pct is understated. Type: Result |
| Cache Name Version: 11.0 and later | The name of a data cache. Particular database tables and indexes may be bound to a specific data cache, or all objects in a database may be bound to the same data cache. No object may be bound to more than one cache. Type: Key |
| Cache Prefetch Efficiency Version: 11.0 and later | A percentage comparing the count of pages being reused in large I/O buffers (the denominator) to the number of those pages that were ever referenced by Adaptive Server. When a buffer is reused, all of the pages in it are counted as reused. Buffers are reused when there are no free buffers in the pool to accept a new physical read from a database device. The number of reused pages referenced by Adaptive Server divided by the result of the number of pages per buffer multiplied by the number of reused buffers indicates the effectiveness of large I/O fetches. Regardless of how many buffer pools are configured in a named data cache, Adaptive Server only uses two of them. It uses the 2K buffer pool and the pool configured with the largest-sized buffers. Prefetch effectiveness does not apply to the 2K buffer pool, since 2K grabs are not considered large I/O. Therefore, prefetch effectiveness applies to the largest buffer pool in the cache. For example, if a data cache has pools of buffers sized 2K, 8K, and 16K, the 8K pool is not used, and this metric reflects the effectiveness of large I/O in the 16K buffer pool. If the ratio is large, then prefetching is effective; otherwise, prefetching is not providing much benefit. This may suggest that a buffer pool should be eliminated (or it may imply that a clustered index on some table is fragmented, and that the index should be dropped and re-created). Type: Result |
| Cache Refer and Reuse Version: 11.0 and later | The number of pages in buffers that were both referenced and reused. This count is employed when determining the efficiency of prefetching buffers (see Cache Prefetch Efficiency). This data item, unlike Cache Prefetch Efficiency, includes activity in the default 2K buffer pool. See Cache Prefetch Efficiency for a definition of buffer reuse. Type: Result |
| Cache Reuse Version: 11.0 and later | The number of pages in buffers that were reused. A large value indicates a high rate of turnover (of buffers in this memory pool), and suggests that the pool may be too small. A zero value suggests that this memory pool may be too large. This data item, unlike Cache Prefetch Efficiency, includes activity in the default 2K buffer pool. See Cache Prefetch Efficiency for a definition of buffer reuse. Type: Result |
| Cache Reuse Dirty Version: 11.0 and later | The number of times that a buffer that was reused had changes that needed to be written. A non-zero value indicates that the wash size is too small. See Cache Prefetch Efficiency for a definition of buffer reuse. Type: Result |
| Cache Size Version: 11.0 and later | The size of a data cache, in megabytes. Type: Result |
| Cache Spinlock Contention Version: 11.0 and later | The fraction of the requests for a data cache’s spinlock that were forced to wait. spinlock_waits / spinlock_requests Type: Result |
| Code Memory Size Version: 11.0 and later | Amount of memory in bytes allocated to Adaptive Server. Type: Result |
| Connect Time Version: 11.0 and later | Number of seconds elapsed since the process was started or since the session was started, whichever is smaller. Type: Result |
| CPU Busy Percent Version: 11.0 and later | Percentage of total server CPU ticks that the Adaptive Server CPU was busy. Type: Result |
| CPU Percent Version: 11.0 and later | If used in a view with Process ID, this is the percentage of time a single process was in the Running state over the time all processes were in the Running state. If used in a view with Application Name, this is the percentage of time the set of processes running a given application were in the Running state over the time all processes were in the Running state. Type: Result |
| CPU Time Version: 11.0 and later | If used in a view with no keys, this data item is the total CPU busy time, in seconds, on the server. If used with keys, this data item is the busy time, in seconds, that was used by each process, application, or engine. Process ID and Application Name are mutually exclusive. Type: Result |
| CPU Yields Version: 11.0 or later | Number of times that the Adaptive Server yielded to the operating system. Type: Result |
| Current Application Name Version: 11.0 and later | The name of the application that is currently executing on a particular process. Type: Result |
| Current Engine Version: 11.0 and later | Number of the Adaptive Server engine on which the process was running most recently. Type: Result |
| Current Execution Class Version: 11.5 and later | The name of the execution class under which a process is currently running. Type: Result |
| Current Process State Version: 11.0 and later | Current state of a process. See Process State for definitions of the possible states. Type: Result |
| Current Stmt Batch ID Version: 11.5 and later | The ID of a particular query batch being executed on a particular process. Type: Result |
| Current Stmt Batch Text Version: 11.5 and later | The text of a particular query batch being executed for a particular process. This text may be only an initial substring of the complete text in a query batch. The amount of text stored in this field is determined by the Adaptive Server max SQL text monitored configuration parameter. Type: Result |
| Current Stmt Batch Text Byte Offset Version: 11.5 and later | The byte offset to the beginning of a statement within the query batch or stored procedure being executed for a particular process. If both: Current Stmt Procedure Database ID is equal to 0 and Current Stmt Procedure ID is equal to 0 then the statement is the currently executing SQL statement in the query batch. Otherwise, the statement is the currently executing SQL statement in the stored procedure uniquely identified by these two IDs. Type: Result |
| Current Stmt Batch Text Enabled Version: 11.5 and later | Reports whether Adaptive Server (version 11.5 and later) is saving the SQL text of the currently executing query batches and, if so, how much. Value of 0 = saving SQL text disabled Value of 1 or more = maximum number of bytes of batch text per server process that can be saved. Type: Result |
| Current Stmt Context ID Version: 11.5 and later | The ID that uniquely identifies a stored procedure invocation within a particular query batch being executed for a particular process. Type: Result |
| Current Stmt CPU Time Version: 11.5 and later | The amount of time (in seconds) that the currently executing SQL statement has spent in the running state. Type: Result |
| Current Stmt Elapsed Time Version: 11.5 and later | The amount of time (in seconds) that the currently executing SQL statement has been running. Type: Result |
| Current Stmt Line Number Version: 11.5 and later | The number of the line (within a query batch or stored procedure) that contains the beginning of the currently executing SQL statement for a particular process. The currently executing SQL statement is in the query batch if both Current Stmt Procedure Database ID is equal to 0 and Current Stmt Procedure ID is equal to 0. Otherwise, the currently executing SQL statement is in the stored procedure uniquely identified by these two IDs. Type: Result |
| Current Stmt Locks Granted After Wait Version: 11.5 and later | Number of lock requests by the currently executing SQL statement that were granted after waiting. Type: Result |
| Current Stmt Locks Granted Immediately Version: 11.5 and later | Number of lock requests by the currently executing SQL statement that were granted immediately or were not needed (because sufficient locking was already held by the requestor). Type: Result |
| Current Stmt Locks Not Granted Version: 11.5 and later | Number of lock requests by the currently executing SQL statement that were denied. Type: Result |
| Current Stmt Logical Reads Version: 11.5 and later | Number of data page reads satisfied from cache or from device reads by the currently executing SQL statement. Type: Result |
| Current Stmt Number Version: 11.5 and later | The number of the statement (appearing in a query batch or stored procedure) that is the currently executing SQL statement for a particular process. The currently executing SQL statement is in the query batch if both Current Stmt Procedure Database ID is equal to 0 and Current Stmt Procedure ID is equal 0. Otherwise, the currently executing SQL statement is in the stored procedure uniquely identified by these two IDs. A value of 0 indicates partial result data for the currently executing SQL statement. In other words, this SQL statement began executing before monitoring began. Performance metrics are available but numbers reflect only the time period since the start of monitoring. Type: Result |
| Current Stmt Page I/O Version: 11.5 and later | Number of combined logical page reads and page writes by the currently executing SQL statement. Type: Result |
| Current Stmt Physical Reads Version: 11.5 and later | Number of data page reads by the currently executing SQL statement that could not be satisfied from the data cache. Type: Result |
| Current Stmt Procedure Database ID Version: 11.5 and later | The database ID of the stored procedure (including triggers, a special kind of stored procedure) that contains the currently executing SQL statement for a particular process. If the currently executing SQL statement is not contained in a stored procedure, this ID is 0. Type: Result |
| Current Stmt Procedure Database Name Version: 11.5 and later | The database name of the stored procedure (including triggers, a special kind of stored procedure) that contains the currently executing SQL statement for a particular process. If the currently executing SQL statement is not contained in a stored procedure, this name is “**NoDatabase**”. Type: Result |
| Current Stmt Procedure ID Version: 11.5 and later | The ID of the stored procedure (including triggers, a special kind of stored procedure) that contains the currently executing SQL statement for a particular process. If the currently executing SQL statement is not contained in a stored procedure, this ID is 0. Type: Result |
| Current Stmt Procedure Name Version: 11.5 and later | The name of the stored procedure (including triggers, a special kind of stored procedure) that contains the currently executing SQL statement for a particular process. If the currently executing SQL statement is not contained in a stored procedure, this name is “**NoObject**”. Type: Result |
| Current Stmt Procedure Owner Name Version: 11.5 and later | The owner name of the stored procedure (including triggers, a special kind of stored procedure) that contains the currently executing SQL statement for a particular process. If the currently executing SQL statement is not contained in a stored procedure, this name is “**NoOwner**”. Type: Result |
| Current Stmt Procedure Text Version: 11.5 and later | The text of a particular stored procedure (including triggers, a special kind of stored procedure) being executed for a particular process. If both Current Stmt Procedure Database ID is equal to 0 and Current Stmt Procedure ID is equal to 0 then a stored procedure is not currently executing and this text is a null-terminated empty string (“”). If the text is not available (because this stored procedure was compiled and its text was discarded, or because the text is stored in an encrypted format), then this text is a null-terminated empty string (“”). Type: Result |
| Current Stmt Query Plan Text Version: 11.5 and later | The text of the query plan for a particular query being executed for a particular process. If the text is not available (because the Adaptive Server has removed this plan from its catalog of query plans), then this text is a null-terminated empty string (“”). Type: Result |
| Current Stmt Start Time Version: 11.5 and later | The date and time, in the time zone of Adaptive Server, when the currently executing SQL statement began running. If this SQL statement began running before monitoring began, then this result is the date and time that activity was first encountered for this statement. Type: Result |
| Current Stmt Text Byte Offset Version: 11.5 and later | The byte offset to the beginning of a statement within the query batch or stored procedure being executed for a particular process. If both Current Stmt Procedure Database ID is equal to 0 and Current Stmt Procedure ID is equal to 0, then the statement is the currently executing SQL statement in the query batch. Otherwise, the statement is the currently executing SQL statement in the stored procedure uniquely identified by those two IDs. Type: Result |
| Database ID Version: 11.0 and later | Unique identification of a database. Type: Key |
| Database Name Version: 11.0 and later | Name of the database. Type: Result |
| Deadlock Count Release: 11.0 and later | Number of deadlocks. Type: Result |
| Demand Lock Version: 11.0 and later | A character string (Y or N) that indicates whether or not a lock that has been upgraded to demand lock status. Type: Result |
| Device Hit Percent Version: 11.0 and later | The fraction of device requests is computed by multiplying the quotient of device hits divided by device misses plus device misses by 100. Type: Result |
| Device Hits Version: 11.0 and later | Number of times access to a device was granted. Type: Result |
| Device I/O Version: 11.0 and later | Combination of device reads and device writes. Type: Result |
| Device Misses Version: 11.0 and later | Number of times access to a device had to wait. Type: Result |
| Device Name Version: 11.0 and later | Name of a database device defined in Adaptive Server. Type: Key |
| Device Reads Version: 11.0 and later | Number of reads made from a device. Type: Result |
| Device Writes Version: 11.0 and later | Number of writes made to a device. Type: Result |
| Elapsed Time Version: 11.0 and later | The time increment, in seconds, either from one data refresh to the next (sample) or from the creation of the view to the present (session). Type: Result |
| Engine Number Version: 11.0 and later | Number of the Adaptive Server engine. Type: Key |
| Host Name Version: 11.0 and later | The name of the host computer that established a particular connection. Type: Result |
| Index Logical Reads Release: 11.0 and later | Number of index page reads satisfied from cache and from database devices. Type: Result |
| Index Physical Reads Version: 11.0 and later | Number of index page reads that could not be satisfied from the data cache. Type: Result |
| Kernel Process ID Version: 11.0 and later | An Adaptive Server process identifier that remains unique over long periods of time. Type: Key |
| Kernel Structures Memory Size Version: 11.0 and later | Amount of memory in bytes allocated to the kernel structures. Type: Result |
| Large I/O Denied Version: 11.0 and later | The number of times the buffer manager did not satisfy requests (of the optimizer) to load data into a buffer in this data cache by fetching more than one contiguous page from disk at a time. Type: Result |
| Large I/O Performed Version: 11.0 and later | The number of times the buffer manager satisfied requests (of the optimizer) to load data into a buffer in this data cache by fetching more than one contiguous page from disk at a time. Type: Result |
| Large I/O Requested Version: 11.0 and later | The number of times the optimizer made requests (of the buffer manager) to load data into a buffer in this data cache by fetching more than one contiguous page from disk at a time. Type: Result |
| Lock Count Version: 11.0 and later | Number of locks. Type: Result |
| Lock Hit Percent Version: 11.0 and later | Percentage of successful requests for locks. Type: Result |
| Lock Result Version: 11.0 and later | Result of a logical lock request. Lock result values are:
|
| Lock Results Summarized Version: 11.0 and later | Lock results summarized at a granted or not granted level.
|
| Lock Status Version: 11.0 and later | Current status of a lock which includes lock status values:
|
| Lock Status Count Version: 11.0 and later | Number of locks in each lock status. This is a snapshot value. Type: Result |
| Lock Type Version: 11.0 and later | Adaptive Server protects tables or data pages currently used by active transactions by locking them. Adaptive Server employs the following lock types:
|
| Locks Being Blocked Count Version: 11.0 and later | Number of locks being blocked by this process that holds this “held_and_blocking” lock. Type: Result |
| Locks Granted Immediately Version: 11.5 and later | Number of locks that were granted immediately, without having to wait for another lock to be released. Type: Result |
| Locks Granted After Wait Version: 11.5 and later | Number of locks that were granted after waiting for another lock to be released. Type: Result |
| Locks Not Granted Version: 11.5 and later | Number of locks that were requested but not granted. Type: Result |
| Log Contention Percent Version: 11.0 and later | The percentage of times, of the total times when a user log cache was flushed into the transaction log, that it had to wait for the log semphore. A high percentage may indicate that the user log cache size should be increased. Type: Result |
| Logical Page Reads Version: 11.0 and later | Number of data page reads per unit of time, whether satisfied from cache or from a database device. Type: Result |
| Login Name Version: 11.0 and later | Login name associated with Adaptive Server processes. Type: Result |
| Most Active Device I/O Version: 11.0 and later | Number of combined reads and writes against the device with the most activity during a given time interval. Type: Result |
| Most Active Device Name Version: 11.0 and later | Name of the device with the largest number of combined reads and writes during a given time interval. Type: Result |
| Net Bytes Received Version: 11.0 and later | Number of network bytes received. Type: Result |
| Net Bytes Sent Version: 11.0 and later | Number of network bytes sent. Type: Result |
| Net Default Packet Size Version: 11.0 and later | Default network packet size. Type: Result |
| Net I/O Bytes Version: 11.0 and later | Total number of network bytes sent and received. Type: Result |
| Net Max Packet Size Version: 11.0 and later | Configured maximum size for a network packet. Type: Result |
| Net Packet Size Received Version: 11.0 and later | Average size of network packets received. Type: Result |
| Net Packet Size Sent Version: 11.0 and later | Average size of network packets sent. Type: Result |
| Net Packets Received Version: 11.0 and later | Number of network packets received. Type: Result |
| Net Packets Sent Version: 11.0 and later | Number of network packets sent. Type: Result |
| Number of Engines Version: 11.0 and later | Number of engines configured for Adaptive Server. Type: Result |
| Number of Processes Version: 11.0 and later | Number of processes currently running on Adaptive Server, or, if used with the key Application Name, the number of processes currently running a given application. Type: Result |
| Object ID Version: 11.0 and later | ID of a database object. The object returned is a database table, a stored procedure, or a temporary table. Object IDs might be negative numbers. The object IDs that Adaptive Server assigns to temporary tables can be positive or negative. Type: Key |
| Object Name Version: 11.0 and later | Database object name. The string **TempObject** is reported for temporary tables. Type: Result |
| Object Type Version: 11.0 and later | Type of database object:
|
| Owner Name Version: 11.0 and later | Name of an objects’s owner. Type: Result |
| Page Cache Size Version: 11.0 and later | Amount of memory in bytes allocated for the page cache. Type: Result |
| Page Hit Percent Version: 11.0 and later | Percentage of times that a data page read could be satisfied from cache without requiring a physical page read. Type: Result |
| Page I/O Version: 11.0 and later | Combined total of logical page reads and page writes. Type: Result |
| Page Number Version: 11.0 and later | Data page number for a particular lock or lock request. Type: Key |
| Page Writes Version: 11.0 and later | Number of pages written to a database device. Type: Result |
| Physical Page Reads Version: 11.0 and later | Number of data page reads that could not be satisfied from the data cache. Type: Result |
| Procedure Buffer Size Version: 11.0 and later | Amount of memory in bytes allocated for the procedure buffer. Type: Result |
| Procedure CPU Time Version: 11.0 and later | Number of seconds of CPU time spent executing a stored procedure. Type: Result |
| Procedure Database ID Version: 11.0 and later | Database ID of the active stored procedure. Type: Key |
| Procedure Database Name Version: 11.0 and later | Database name of the active stored procedure. Type: Key |
| Procedure Elapsed Time Version: 11.0 and later | Number of seconds elapsed during a stored procedure execution. All statistic types valid with this data item report time in units of seconds. For example, “Procedure Elapsed Time”, “Average for Session” reports the average number of elapsed seconds per procedure execution. Type: Result |
| Procedure Execution Class Version: 11.5 and later | Configured execution class, if any, for a given stored procedure. Type: Result |
| Procedure Execution Count Version: 11.0 and later | Number of times a stored procedure, or a line in a stored procedure, was executed. Type: Result |
| Procedure Header Size Version: 11.0 and later | Amount of memory in bytes allocated for the procedure header. Type: Result |
| Procedure Hit Percent Version: 11.0 and later | Percentage of times that a procedure execution found the procedure’s query plan in procedure cache and available for use. Type: Result |
| Procedure ID Version: 11.0 and later | Active stored procedure. Active indicates the top-level stored procedure was called. Type: Key |
| Procedure Line Number Version: 11.0 and later | Stored procedure line number. Type: Key |
| Procedure Line Text Version: 11.0 and later | Entire text of the stored procedure. Type: Result |
| Procedure Logical Reads Version: 11.0 and later | Number of requests to execute a stored procedure, whether satisfied from procedure cache or with a read from sysprocedures. Type: Result |
| Procedure Name Version: 11.0 and later | Name of the active stored procedure. Type: Result. |
| Procedure Owner Name Version: 11.0 and later | Name of the owner of the active stored procedure. Type: Result |
| Procedure Physical Reads Version: 11.0 and later | Number of requests to execute a stored procedure, for which a read from sysprocedures was necessary. Type: Result |
| Procedure Statement Number Version: 11.0 and later | Statement number within a stored procedure. A single stored procedure line can contain one or more statements. Type: Key |
| Process ID Version: 11.0 and later | Adaptive Server process identification number. Views that contain Process ID only report on processes that are active as of the end of the sample period. Process ID is mutually exclusive with Application Name in a view. Type: Key |
| Process State Version: 11.0 and later | Process state:
|
| Process State Count Version: 11.0 and later | Number of processes in a particular state. Type: Result |
| Rows Deleted Version: 11.0 and later | Number of rows deleted from a database table. Type: Result |
| Rows Deleted Deferred Version: 11.0 and later | Number of rows deleted from a database table in deferred mode. Type: Result |
| Rows Deleted Direct Version: 11.0 and later | Number of rows deleted from a database table in direct mode. Type: Result |
| Rows Inserted Version: 11.0 and later | Insertions into a database table. Type: Result |
| Rows Inserted Clustered Version: 11.0 and later | Insertions into database tables with clustered indexes. Type: Result |
| Rows Inserted Heap Version: 11.0 and later | Insertions into database tables without clustered indexes. Type: Result |
| Rows Updated Version: 11.0 and later | Updates to a database table. Type: Result |
| Rows Updated Deferred Version: 11.0 and later | Updates that require two steps to complete. First, records for deleting the existing entry and inserting the new entry are written to the log, but only the deletes are actually performed on the data pages. In the second step, the log is rescanned and the insert operations performed on the data pages. Type: Result |
| Rows Updated Direct Version: 11.0 and later | The sum of expensive, in-place, and not-in-place updates (everything except updates deferred). Type: Result |
| Rows Updated Expensive Version: 11.0 and later | A type of direct update that deletes a row from its original location and inserts it in a new location. |
| Rows Updated In Place Version: 11.0 and later | A type of direct update that does not require rows to move on a data page. Type: Result |
| Rows Updated Not In Place Version: 11.0 and later | A type of direct update that does not require the updated row to move, but because the length of the updated row changes, other rows on the data page are moved. Also known as cheap updates. Type: Result |
| Select Statements Version: 11.0 and later | Number of SELECT or OPEN CURSOR statements. Type: Result |
| Server Structures Size Version: 11.0 and later | Amount of memory in bytes allocated for the Adaptive Server structures. Type: Result |
| SQL Server Name Version: 11.0 and later | Name of the Adaptive Server that is being monitored as specified by the -S parameter in the start-up command for the Monitor Server being used. Type: Result |
| SQL Server Version Version: 11.0 and later | Version of the Adaptive Server that is being monitored. For more information, see the global @@version variable in the Transact-SQL User’s Guide. Type: Result |
| Thread Exceeded Max Version: 11.5 and later | The number of times a query plan was adjusted at runtime because of attempting to exceed the configured limit of threads in the server-wide worker thread pool in Adaptive Server version 11.5 and later. Type: Result |
| Thread Exceeded Max Percent Version: 11.5 and later | The percentage of time a query plan was adjusted at runtime because of attempting to exceed the configured limit of threads in the server-wide worker thread pool in Adaptive Server version 11.5 and later. Type: Result |
| Thread Max Used Version: 11.5 and later | The maximum number of threads from the server-wide worker thread pool that were concurrently in use on the server. Type: Result |
| Time Waited on Lock Version: 11.0 and later | Amount of time (in seconds) that a lock request has been waiting. Type: Result |
| Timestamp Version: 11.0 and later | In recording session views and in playback views when summarization_level is raw, the date and time on the Adaptive Server when the recording session data was gathered. In playback views, when summarization_level is actual, entire, or a user-defined interval, the time is converted to the time zone of Historical Server. For more information, see the getdate() function in the Transact-SQL User’s Guide. Type: Result |
| Timestamp Datim Version: 11.0 and later | In recording session views and in playback views when summarization_level is raw, the date and time on the Adaptive Server when the recording session data was gathered, returned in a CS_DATETIME structure. For more information, see the getdate() function in the Transact-SQL User’s Guide. In playback views, when summarization_level is actual, entire, or a user-defined interval, the time is converted to the time zone on Historical Server. Type: Result |
| Transactions Version: 11.0 and later | Total number of committed Transact-SQL statement blocks delimited by a begin transaction and commit transaction statement. Type: Result |
Installing Sybase Auditing
Sybase Auditing
- Create the auditing devices and auditing database with the Transact-SQL disk init and create database commands. For example:
Remote table creation
This process sets up a proxy table so that you can select and insert into a remote table on another server from your local server. It’s more elegant than doing regular bcp’s
The following example defines the remote Adaptive Server table authors, starting with the server definition:
1. Define a server named SYBASE. Its server class is ASEnterprise, and its name in the interfaces file is SYBASE:
exec sp_addserver SYBASE, ASEnterprise, SYBASE
2. Define a remote login alias. This step is optional. User “sa” is known to remote server SYBASE as user “sa,” password “timothy”:
exec sp_addexternlogin SYBASE, sa, sa, timothy
3. Define the remote authors table:
create existing table authors
(
au_id id not null,
au_lname varchar(40) not null,
au_fname varchar(20) not null,
phone char(12) not null,
address varchar(40) null,
city varchar(20) null,
state char(2) null,
country varchar(12) null,
postalcode char(10) null
)
EXTERNAL TABLE at “SYBASE.pubs2.dbo.authors”
4. Update statistics in tables to ensure reasonable choices by the query optimizer:
update statistics authors
5. Execute a query to test the configuration:
select * from authors where au_lname = ‘Carson’
Correcting identity row gaps
You can fix the rows containing the large numbers to correct gaps in the identity column. Perform the following steps:
set identity_insert table_name on
bcp out the data from the table.
set identity_insert table_name off
Drop and recreate the table with possibly a smaller numeric field for the identity column e.g numeric (5,0) instead of numeric (18,0)
bcp the table back in
Installing dbccdb
From scratch
1. run sp_plan_dbccdb from the master database to get an estimate of the sizes needed 2. create a dedicated data and log device for the dbccdb database and create the database onto these, or just create it on existing devices 3. run isql –U –P –S –i$SYBASE/$SYBASE_ASE/scripts/installdbccdb to install all the necessary tables and stored procs in the the dbccdb database 4. Add segments into the dbccdb database; use dbccdb go sp_addsegment scanseg, dbccdb, dbccdb_data1 go sp_addsegment textseg, dbccdb, dbccdb_data1 Where dbccdb_data1 is the data device dbccdb was created on 5. Add a 16K pool if it doesn’t already exist;sp_poolconfig "default data cache", "150M", "16K"go 5. Create workspaces;
use dbccdbgo sp_dbcc_createws dbccdb, scanseg, scan_pubs2, “scan”, “10M” go sp_dbcc_createws dbccdb, textseg, text_pubs2, “text”, “10M” go The values in MB are found from the highest values of the output from sp_plan_dbccdb earlier 6. Configure databases into dbccdb; derive the required values from the sp_plan_dbccdb earlier
use dbccdbgo sp_dbcc_updateconfig pubs2,”max worker processes”, “4” go sp_dbcc_updateconfig pubs2, “dbcc named cache”, “default data cache”, “10K” go sp_dbcc_updateconfig pubs2, “scan workspace”, scan_pubs2 go sp_dbcc_updateconfig pubs2, “text workspace”, text_pubs2 go sp_dbcc_updateconfig pubs2, “OAM count threshold”, “5” go sp_dbcc_updateconfig pubs2, “IO error abort”, “3” go sp_dbcc_updateconfig pubs2,”linkage error abort”, “8” go You will need to increase the number of worker processes parameter to 100 and bounce the Sybase server, after it comes up set max parallel degree to 10 and max scan parallel degree to 3