Tuesday 20 December 2011

My simple note

If Server experience is slowness

@os level

1. vmstate  --- check for cpu , cache , memory , resourses

2.  check error log

3. sp_monitor --> % of time Adaptive Server uses the CPU during an elapsed time interval cpu usage should not > engine

4. sysprocesses ---> awaiting_cmd


How to do cross platform Dump Load 

@source

1. put db in single user mode

2.dump tran with truncate only

3sp_flushstats

4.Dump db

@Target

1.Load 

2.online db

3.sp_post_xpload ---> this rebuild the currupted index

 

 

Thread down due to Duplicate rows in replicate database table


@ RS :
sysadmin log_first_tran, data_server, database
 
@ DS :
use rs_RSSD
go
rs_helpexception - displayed xact no 107
rs_helpexception 107, v
set

where you will see the transaction causing the problem.

Apply this transaction manually.
set autocorrection on
 for publishers_rep
 with replicate at SYDNEY_DS.pubs2
 

How to clear the log from the RSSD db

 

1. dbcc settrunc(ltm,ignore).
2. sp_stop_rep_agent <dbname> or sp_config_rep_agent 'disable'.

To enable when you are ready. P.S. The order is very important.

If you have used sp_stop_rep_agent

1. dump tran with truncate_only.
2. use db
dbcc settrunc(ltm,valid)
3. On the RSSD.
rs_zeroltm DBSERVER,DBNAME
This step will tell the RepServer to look at the secondary marker from the start of the transaction log.
4. sp_start_rep_agent <dbname>

If you have used sp_config_rep_agent 'disable'

1. dump tran with truncate_only.
2. sp_config_rep_agent 'enable'..... This will also set the valid trunc marker.
3. On the RSSD.
rs_zeroltm DBSERVER,DBNAME
This step will tell the RepServer to look at the secondary marker from the start of the transaction log.
4. sp_start_rep_agent <dbname>

 

 

How to find the whether specified index used by the query :  check showplan output

1> use pubs2

1> set showplan on

1> select stores.stor_name, sales.ord_num

2> from stores, sales, salesdetail

3> where salesdetail.stor_id = sales.stor_id

4> and stores.stor_id = sales.stor_id

5> plan " ( m_join ( i_scan salesdetailind salesdetail)

6> ( m_join ( i_scan salesind sales ) ( sort ( t_scan stores ) ) ) )"

QUERY PLAN FOR STATEMENT 1 (at line 1).

Optimized using the Abstract Plan in the PLAN clause.

6 operator(s) under root

The type of query is SELECT.

ROOT:EMIT Operator

    |MERGE JOIN Operator (Join Type: Inner Join)

    | Using Worktable3 for internal storage.

    |  Key Count: 1

    |  Key Ordering: ASC

    |

    |   |SCAN Operator

    |   |  FROM TABLE

    |   |  salesdetail

    |   |  Index : salesdetailind

    |   |  Forward Scan.

    |   |  Positioning at index start.

    |   |  Index contains all needed columns. Base table will not be read.

    |   |  Using I/O Size 2 Kbytes for index leaf pages.

    |   |  With LRU Buffer Replacement Strategy for index leaf pages.

    |

    |   |MERGE JOIN Operator (Join Type: Inner Join)

    |   | Using Worktable2 for internal storage.

    |   |  Key Count: 1

    |   |  Key Ordering: ASC

    |   |

    |   |   |SCAN Operator

    |   |   |  FROM TABLE

    |   |   |  sales

    |   |   |  Table Scan.

    |   |   |  Forward Scan.

    |   |   |  Positioning at start of table.

    |   |   |  Using I/O Size 2 Kbytes for data pages.

    |   |   |  With LRU Buffer Replacement Strategy for data pages.

    |   |

    |   |   |SORT Operator

    |   |   | Using Worktable1 for internal storage.

    |   |   |

    |   |   |   |SCAN Operator

    |   |   |   |  FROM TABLE

    |   |   |   |  stores

    |   |   |   |  Table Scan.

    |   |   |   |  Forward Scan.

    |   |   |   |  Positioning at start of table.

    |   |   |   |  Using I/O Size 2 Kbytes for data pages.

    |   |   |   |  With LRU Buffer Replacement Strategy for data pages.

After the statement level output, the query plan is displayed. The showplan output of the query plan

consists of two components:

·         The names of the operators (some provide additional information) to show which operations

 are being executed in the query plan.

·         Vertical bars (the “|” symbol) with indentation to show the shape of the query plan operator tree.

Task context switches by engine

“Task Context Switches by Engine” reports the number of times each Adaptive Server engine switched context from one user task to another. “% of total” reports the percentage of engine task switches for each Adaptive Server engine as a percentage of the total number of task switches for all Adaptive Server engines combined.

1) Meaning of Spinlock :-  "spinning" (repeatedly trying to acquire the lock)

2) T-SQL Query to get all the tables and lock scheme info.

The following Query gives list of all the User Tables and locking scheme of the Table.

select "Table"=left(name,32), "lock_scheme"= case 
                            when (sysstat2 & 57344) < 8193 then 'APL' 
                            when (sysstat2 & 57344) = 16384 then 'DPL' 
                            when (sysstat2 & 57344) = 32768 then 'DRL' 
                            end
 from sysobjects
  where type='U'
        order by sysstat2

4) How to clear data from cache memory

How to clear data from cache memory

data cache

as of 15.0.3 - dbcc cachedataremove(dbid | dbname, objid | objname, partitionid | partitionname, indid | indexname)
you need sa_role for that as well

pre-15.0.2 ESD6 - try sp_unbindcache_all 'default data cache'
for example to clear "default data cache".  For named data caches, you should do this, followed by a sp_bindcache again for each object bound to a named cache

statement cache

set statement_cache off    -- session level
<your sql statements here>
or
sp_configure 'statement cache size',0  -- server level


procedure cache

In 12.5.4 ESD5 and 15.0.2 :   dbcc proc_cache (free_unused)

pre 12.5.4 ESD5:    dbcc proc_cacherm(type, dbname, objname)

where: type is V,P,T,R,D,C,F, or S (must be uppercase) corresponds to View, Proc, Trigger, Rule, Default, Cursor, SQLJ Function, SQL function

5)

Getting the process ID for the oldest open transaction.

Use the following query to find the spid of the oldest open transaction in a transaction log that has reached its last-chance threshold:
use master
go
select dbid, spid from syslogshold
where dbid = db_id("name_of_database")

For example, to find the oldest running transaction on the pubs2 database:

select dbid, spid from syslogshold
where dbid = db_id ("pubs2")

dbid   spid
------ ------
    7      1
6) How do you troubleshoot if your tempdb gets filled

i) Try to find out the Active process that is filling up the temp db space.

ii)  If the transaction log of tempdb is full then you call login through sa and type following command.

> dump tran tempdb with trancate_only
> go

iii) If the database is full then you can increase the size of the database on a free device.

> alter database tempdb on device_name = size
> go
 
iv) use following command It will abort all open transactions.
    But be sure the task by confirming with the concern users.

>select lct_admin(0,2)
>go

Restarting the server is not recommanded.lct_admin (0,2) would abort all open transactions, or you
can go for altering the tempdb space. Multiple tempdb's is a feature which can be implemented to 
minimize such issues of tempdb getting full.
 

How to force a Table Scan in Sybase?

Are indexes always useful and mandatory on a table or Is Table scan on a table
always a bad news for us? To understand what is good for us we need to know the
exact purpose of indexes and what is meant by a Table scan? When a user executes
a query and the Sybase server has to iterate over each row of each page in a Sybase
table then the scan that Sybase server is currently performing is called a Table scan.
In case we have created indexes and used proper SARGs then the Sybase server will
pickup an appropriate index and fetch our results more quickly than any Table scan.
However, this is just one part of the story and is applicable only when tables are of
very large size. So, always create indexes on a table which is of very large size
otherwise there are lots of overheads to maintain and keep the indexes up to date in
Sybase. In case of smaller tables it is better to be without Indexes than using an
Index. So, what to do in case we have some data in the table and have some indexes
created on the table and still want to force Sybase to perform a table scan?
This is usually required when the data in a table is serialized or sequential and
we are sure that first few records is all that we need to iterate on.
So, now knowing that we need a Table scan in Sybase we need to make sure that
Sybase server does not use any index while executing the query.
This is called forcing a table scan. To force a table scan in Sybase we can
use a simple statement like this -

select * from my_table (index 0) where col1 = @col1

As we can see here that we have suggested (index 0) to be used in the
above mentioned query? Wondering why and what does (index 0) specify? Well, 0
here refers to the 0th entry in sysindexes table which is actually representing
a table scan. Hence by suggesting the index we can force a table scan in Sybase.

Monday 12 December 2011

Cleaning Shared Memory Segment and semaphore, for the ASE startup

When we shutdown the Sybase dataserver abruptly, by using the kill -9 or kill -12(or due to any reason automatically).

During the restart, sometime it gives the problem unable to create shared memory region, as below:


os_create_region: shmget (0x%x): %s

os_create_region: Shared memory segment %d is in the way

os_create_region: uninitialized shared memory descriptor

os_create_region: shmat (%d): %

Killing Process may left behind the System V semaphore or shared memory left behind instead of being cleaned up automatically. To eliminate unneeded semaphores or shared memory segments, we need to release semaphore or shared memory segment manually.

For the Semaphores:

Run the command ipcs -sa, it will give all semaphores active in the UNIX box, look for the value "0" in the column NSEMS. 0 values indicate that unused semaphore, find all semaphore for the Sybase user and remove them using command ipcrm -s

testinghostname:(/sybase)=>ipcs -sa
IPC status from as of Thu Sep 17 08:50:11 EST 2007
T ID KEY MODE OWNER GROUP CREATOR CGROUP NSEMS OTIME CTIME
Semaphores:
s 201326671 0xc103d804 --ra-ra-ra- patrol dba patrol dba 2 8:45:15 0:00:08
s 201326668 0xc103d80e --ra-ra-ra- sybase dba sybase dba 0 8:50:08 0:00:00


testinghostname:(/sybase)=>ipcrm -s 201326668

For the Shared Memory:

To cleanup the Shared memory segment, which are assigned at OS level but not in use, run ipcs -ma command.

testinghostname:(/sybase)=>ipcs -ma
IPC status from as of Thu Sep 17 08:50:24 EST 2007
T ID KEY MODE OWNER GROUP CREATOR CGROUP NATTCH SEGSZ CPID LPID ATIME DTIME CTIME
Shared Memory:
m 654311446 0x4103d80e --rw-rw-rw- patrol dba patrol dba 0 2304 1766 1766 8:50:18 8:50:18 0:00:08
m 671088657 0x4103d80d --rw-rw-rw- sybase dba sybase dba 0 1792 1766 1762 8:45:15 8:45:15 0:00:08
m 671088650 0x4103d80b --rw-rw-rw- root root root root 0 768 1766 1766 8:50:18 8:50:18 0:00:08
m 671088648 0x4103d80a --rw-rw-rw- sybase dba sybase dba 1 1280 1766 1766 8:50:18 8:50:18 0:00:08
m 654311548 0x4103d809 --rw-rw-rw- sybase dba sybase dba 0 256 1766 1766 8:50:08 8:50:08 0:00:08


Now look in the NATTCH field for 0, if it 0 zero for Sybase user , it is unneeded, but still assigned at OS level. Remove it ipcrm -m by providing the id.

testinghostname:(/sybase)=>ipcrm -m 671088657 -m 654311548

Now Start the dataserver.. :)

Same case with backup server.

Wednesday 7 December 2011

How to get source code of sp_helpdb?


code of sp_helpdb is in $SYBASE/$SYBASE_ASE/scripts/installmaster

or you could get it from :

exec sybsystemprocs..sp_helptext sp_helpdb
or more recent versions of ASE:

exec sybsystemprocs..sp_showtext sp_helpdb

Tuesday 6 December 2011

Configuring Named Cache and a 4K Buffer Pool for Syslogs

The Problem:

The SQL Server Performance and Tuning Guide states:

"In environments with high transaction rates or transactions that create large log records, the 2K transaction log pages fill quickly, and a large proportion of log writes are due to full log pages, rather than group commits. Creating a 4K buffer pool for the transaction log can greatly reduce the log writes in these environments."
Stated another way, there will be fewer physical writes when 4K pages fill and are flushed to disk than there are when 2K pages fill and are flushed to disk.

The problem is that setting up a 4K buffer pool is complex and challenging.

The Resolution:

1. Create a named cache with sp_cacheconfig.

Example:

sp_cacheconfig testcache, "8M",logonly

2. Restart SQL server to bring the cache online.

3. Create a 4K cache pool using the named cache with sp_poolconfigure testcache.

Example:

sp_poolconfigure testcache,"7.5M","4K"

4. Change database to single user mode to allow the use of binding cache.

5. Bind the named cache to syslogs for the database with sp_bindcache.

Example:

sp_bindcache testcache, "pubs2", "syslogs"

6. Use the database.

Example:

use pubs2

7. Change log I/O size to 4K in the database with sp_logiosize.

Example:

sp_logiosize "4"

Extended Example:

To demonstrate, follow the steps above using the example commands shown, then use sp_sysmon to monitor the behaviour of the server. This was tested by dropping all records in selected pubs2's user tables (e.g. delete authors etc...) and inserting all records back using a modified version of instpbs2 scripts. The sp_sysmon output is shown below.

DBCC execution completed. If DBCC printed error messages, contact a user with
System Administrator (SA) role.
===============================================================================
Sybase SQL Server System Performance Report
===============================================================================

Run Date Sep 08, 1997
Statistics Cleared at 14:58:45
Statistics Sampled at 15:00:45
Sample Interval 2 min.

===============================================================================

Kernel Utilization
------------------

Engine Busy Utilization:
Engine 0 10.4 %


CPU Yields by Engine per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
Engine 0 85.9 31.1 10255 100.0 %


Network Checks
0.0 0.0 0 n/a


Disk I/O Checks
Total Disk I/O Checks 5142.2 1860.7 614036 n/a
Checks Returning I/O 4.4 1.6 526 0.1 %
Avg Disk I/Os Returned n/a n/a 1.04183 n/a

===============================================================================

Task Management per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------

Connections Opened 0.0 0.0 2 n/a


Task Context Switches by Engine
Engine 0 13.0 4.7 1558 100.0 %


Task Context Switches Due To:
Voluntary Yields 2.9 1.1 350 22.5 %
Cache Search Misses 0.8 0.3 99 6.4 %
System Disk Writes 0.0 0.0 5 0.3 %
I/O Pacing 0.3 0.1 35 2.2 %
Logical Lock Contention 0.0 0.0 0 0.0 %
Address Lock Contention 0.0 0.0 0 0.0 %
Log Semaphore Contention 0.0 0.0 0 0.0 %
Group Commit Sleeps 0.0 0.0 0 0.0 %
Last Log Page Writes 2.8 1.0 334 21.4 %
Modify Conflicts 0.0 0.0 0 0.0 %
I/O Device Contention 0.0 0.0 0 0.0 %
Network Packet Received 2.8 1.0 333 21.4 %
Network Packet Sent 2.7 1.0 319 20.5 %
SYSINDEXES Lookup 0.0 0.0 0 0.0 %
Other Causes 0.7 0.3 83 5.3 %

===============================================================================

Transaction Profile
-------------------

Transaction Summary per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
Committed Xacts 2.8 n/a 330 n/a


Transaction Detail per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
Inserts
Heap Table 1.8 0.7 220 65.7 %
Clustered Table 1.0 0.3 115 34.3 %
------------------------- ------------ ------------ ----------
Total Rows Inserted 2.8 1.0 335 48.8 %

Updates
Deferred 0.1 0.0 16 100.0 %
Direct In-place 0.0 0.0 0 0.0 %
Direct Cheap 0.0 0.0 0 0.0 %
Direct Expensive 0.0 0.0 0 0.0 %
------------------------- ------------ ------------ ----------
Total Rows Updated 0.1 0.0 16 2.3 %

Deletes
Deferred 0.1 0.0 16 4.8 %
Direct 2.7 1.0 319 95.2 %
------------------------- ------------ ------------ ----------
Total Rows Deleted 2.8 1.0 335 48.8 %

===============================================================================

Transaction Management
----------------------

ULC Flushes to Xact Log per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
by Full ULC 0.2 0.1 21 5.7 %
by End Transaction 2.8 1.0 329 88.7 %
by Change of Database 0.0 0.0 0 0.0 %
by System Log Record 0.1 0.0 15 4.0 %
by Other 0.1 0.0 6 1.6 %
------------------------- ------------ ------------ ----------
Total ULC Flushes 3.1 1.1 371


ULC Log Records 19.4 7.0 2321 n/a
Max ULC Size n/a n/a 2044 n/a


ULC Semaphore Requests
Granted 39.8 14.4 4749 100.0 %
Waited 0.0 0.0 0 0.0 %
------------------------- ------------ ------------ ----------
Total ULC Semaphore Req 39.8 14.4 4749


Log Semaphore Requests
Granted 4.2 1.5 500 100.0 %
Waited 0.0 0.0 0 0.0 %
------------------------- ------------ ------------ ----------
Total Log Semaphore Req 4.2 1.5 500


Transaction Log Writes 3.2 1.2 381 n/a
Transaction Log Alloc 0.8 0.3 92 n/a
Avg # Writes per Log Page n/a n/a 4.14130 n/a

===============================================================================

Index Management
----------------

Nonclustered Maintenance per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
Ins/Upd Requiring Maint 2.4 0.9 285 n/a
# of NC Ndx Maint 3.6 1.3 426 n/a
Avg NC Ndx Maint / Op n/a n/a 1.49474 n/a

Deletes Requiring Maint 2.4 0.9 285 n/a
# of NC Ndx Maint 3.6 1.3 426 n/a
Avg NC Ndx Maint / Op n/a n/a 1.49474 n/a

RID Upd from Clust Split 0.0 0.0 2 n/a
# of NC Ndx Maint 0.1 0.0 9 n/a
Avg NC Ndx Maint / Op n/a n/a 4.50000 n/a


Page Splits 0.0 0.0 3 n/a
Retries 0.0 0.0 0 0.0 %
Deadlocks 0.0 0.0 0 0.0 %
Empty Page Flushes 0.0 0.0 0 0.0 %
Add Index Level 0.0 0.0 1 33.3 %


Page Shrinks 0.0 0.0 5 n/a

===============================================================================

Lock Management
---------------

Lock Summary per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
Total Lock Requests 64.2 23.2 7668 n/a
Avg Lock Contention 0.0 0.0 0 0.0 %
Deadlock Percentage 0.0 0.0 0 0.0 %


Lock Detail per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------

Exclusive Table
Granted 1.1 0.4 128 100.0 %
Waited 0.0 0.0 0 0.0 %
------------------------- ------------ ------------ ----------
Total EX-Table Requests 1.1 0.4 128 1.7 %


Shared Table
Granted 0.1 0.0 6 100.0 %
Waited 0.0 0.0 0 0.0 %
------------------------- ------------ ------------ ----------
Total SH-Table Requests 0.1 0.0 6 0.1 %


Exclusive Intent
Granted 2.7 1.0 319 100.0 %
Waited 0.0 0.0 0 0.0 %
------------------------- ------------ ------------ ----------
Total EX-Intent Requests 2.7 1.0 319 4.2 %


Shared Intent
Granted 6.1 2.2 730 100.0 %
Waited 0.0 0.0 0 0.0 %
------------------------- ------------ ------------ ----------
Total SH-Intent Requests 6.1 2.2 730 9.5 %


Exclusive Page
Granted 6.3 2.3 749 100.0 %
Waited 0.0 0.0 0 0.0 %
------------------------- ------------ ------------ ----------
Total EX-Page Requests 6.3 2.3 749 9.8 %


Update Page
0.0 0.0 0 n/a
------------------------- ------------ ------------ ----------
Total UP-Page Requests 0.0 0.0 0 0.0 %


Shared Page
Granted 13.2 4.8 1581 100.0 %
Waited 0.0 0.0 0 0.0 %
------------------------- ------------ ------------ ----------
Total SH-Page Requests 13.2 4.8 1581 20.6 %


Exclusive Address
Granted 15.5 5.6 1852 100.0 %
Waited 0.0 0.0 0 0.0 %
------------------------- ------------ ------------ ----------
Total EX-Address Requests 15.5 5.6 1852 24.2 %


Shared Address
Granted 19.3 7.0 2303 100.0 %
Waited 0.0 0.0 0 0.0 %
------------------------- ------------ ------------ ----------
Total SH-Address Requests 19.3 7.0 2303 30.0 %


Last Page Locks on Heaps
Granted 1.8 0.7 220 100.0 %
Waited 0.0 0.0 0 0.0 %
------------------------- ------------ ------------ ----------
Total Last Pg Locks 1.8 0.7 220 2.9 %


Deadlocks by Lock Type per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
0.0 0.0 0 n/a


Deadlock Detection
Deadlock Searches 0.0 0.0 0 n/a


Lock Promotions
0.0 0.0 0 n/a

===============================================================================

Data Cache Management
---------------------

Cache Statistics Summary (All Caches)
-------------------------------------

Cache Search Summary
Total Cache Hits 65.0 23.5 7760 98.0 %
Total Cache Misses 1.3 0.5 161 2.0 %
------------------------- ------------ ------------ ----------
Total Cache Searches 66.3 24.0 7921


Cache Turnover
Buffers Grabbed 0.8 0.3 99 n/a
Buffers Grabbed Dirty 0.0 0.0 0 0.0 %


Cache Strategy Summary
Cached (LRU) Buffers 93.0 33.7 11110 100.0 %
Discarded (MRU) Buffers 0.0 0.0 0 0.0 %


Large I/O Usage
Large I/Os Performed 0.7 0.2 82 88.2 %
Large I/Os Denied 0.1 0.0 11 11.8 %
------------------------- ------------ ------------ ----------
Total Large I/O Requests 0.8 0.3 93


Large I/O Effectiveness
Pages by Lrg I/O Cached 0.0 0.0 2 n/a
Pages by Lrg I/O Used 0.0 0.0 0 0.0 %


Dirty Read Behavior
Page Requests 0.0 0.0 0 n/a

-------------------------------------------------------------------------------

default data cache
per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------

0.0 0.0 0 n/a
Utilization n/a n/a n/a 91.0 %

Cache Searches
Cache Hits 59.4 21.5 7098 98.4 %
Found in Wash 0.2 0.1 25 0.4 %
Cache Misses 0.9 0.3 113 1.6 %
------------------------- ------------ ------------ ----------
Total Cache Searches 60.4 21.9 7211


Pool Turnover
2 Kb Pool
LRU Buffer Grab 0.8 0.3 98 100.0 %
Grabbed Dirty 0.0 0.0 0 0.0 %



------------------------- ------------ ------------ ----------
Total Cache Turnover 0.8 0.3 98


Buffer Wash Behavior
Statistics Not Available - No Buffers Entered Wash Section Yet


Cache Strategy
Cached (LRU) Buffers 88.2 31.9 10535 100.0 %
Discarded (MRU) Buffers 0.0 0.0 0 0.0 %


Large I/O Usage
0.0 0.0 0 n/a


Large I/O Detail
No Large Pool(s) In This Cache

Dirty Read Behavior
Page Requests 0.0 0.0 0 n/a

-------------------------------------------------------------------------------

testcache
per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------

0.0 0.0 0 n/a
Utilization n/a n/a n/a 9.0 %

Cache Searches
Cache Hits 5.5 2.0 662 93.2 %
Found in Wash 0.0 0.0 0 0.0 %
Cache Misses 0.4 0.1 48 6.8 %
------------------------- ------------ ------------ ----------
Total Cache Searches 5.9 2.2 710


Pool Turnover

4 Kb Pool
LRU Buffer Grab 0.0 0.0 1 100.0 %
Grabbed Dirty 0.0 0.0 0 0.0 %


------------------------- ------------ ------------ ----------
Total Cache Turnover 0.0 0.0 1


Buffer Wash Behavior
Statistics Not Available - No Buffers Entered Wash Section Yet


Cache Strategy
Cached (LRU) Buffers 4.8 1.7 575 100.0 %
Discarded (MRU) Buffers 0.0 0.0 0 0.0 %


Large I/O Usage
Large I/Os Performed 0.7 0.2 82 88.2 %
Large I/Os Denied 0.1 0.0 11 11.8 %
------------------------- ------------ ------------ ----------
Total Large I/O Requests 0.8 0.3 93


Large I/O Detail

4 Kb Pool
Pages Cached 0.0 0.0 2 n/a
Pages Used 0.0 0.0 0 0.0 %


Dirty Read Behavior
Page Requests 0.0 0.0 0 n/a

===============================================================================

Procedure Cache Management per sec per xact count % of total
--------------------------- ------------ ------------ ---------- ----------
Procedure Requests 2.2 0.8 260 n/a
Procedure Reads from Disk 0.1 0.0 6 2.3 %
Procedure Writes to Disk 0.0 0.0 0 0.0 %
Procedure Removals 0.0 0.0 2 n/a

===============================================================================

Memory Management per sec per xact count % of total
--------------------------- ------------ ------------ ---------- ----------
Pages Allocated 0.0 0.0 0 n/a
Pages Released 0.0 0.0 0 n/a

===============================================================================

Recovery Management
-------------------

Checkpoints per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
0.0 0.0 0 n/a

===============================================================================

Disk I/O Management
-------------------

Max Outstanding I/Os per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
Server n/a n/a 10 n/a
Engine 0 n/a n/a 10 n/a


I/Os Delayed by
Disk I/O Structures n/a n/a 0 n/a
Server Config Limit n/a n/a 0 n/a
Engine Config Limit n/a n/a 0 n/a
Operating System Limit n/a n/a 0 n/a


Total Requested Disk I/Os 4.6 1.7 548 n/a

Completed Disk I/O's
Engine 0 4.6 1.7 548 100.0 %
------------------------- ------------ ------------ ---------- ----------
Total Completed I/Os 4.6 1.7 548


Device Activity Detail
----------------------

d:\sybase\DATA\SYBPROCS.DAT
sysprocsdev per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
0.0 0.0 0 n/a
------------------------- ------------ ------------ ---------- ----------
Total I/Os 0.0 0.0 0 0.0 %


---------------------------------------------------------------------------

d:\sybase\data\psdemodb.dev
psdemodb_dev per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
0.0 0.0 0 n/a
------------------------- ------------ ------------ ---------- ----------
Total I/Os 0.0 0.0 0 0.0 %


---------------------------------------------------------------------------

d:\sybase\data\pubs2d.dat
pubs2d1 per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
Reads 0.0 0.0 3 0.8 %
Writes 3.2 1.2 383 99.2 %
------------------------- ------------ ------------ ---------- ----------
Total I/Os 3.2 1.2 386 70.4 %

Device Semaphore Granted 3.2 1.2 386 100.0 %
Device Semaphore Waited 0.0 0.0 0 0.0 %

---------------------------------------------------------------------------

d:\sybase\data\pubs2d2.dat
pubs2d2 per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
Reads 0.8 0.3 96 59.3 %
Writes 0.6 0.2 66 40.7 %
------------------------- ------------ ------------ ---------- ----------
Total I/Os 1.4 0.5 162 29.6 %

Device Semaphore Granted 1.4 0.5 162 100.0 %
Device Semaphore Waited 0.0 0.0 0 0.0 %

---------------------------------------------------------------------------

d:\sybase\data\tempdb.dev
tempdb_dev per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
0.0 0.0 0 n/a
------------------------- ------------ ------------ ---------- ----------
Total I/Os 0.0 0.0 0 0.0 %


---------------------------------------------------------------------------

master.dat
master per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
0.0 0.0 0 n/a
------------------------- ------------ ------------ ---------- ----------
Total I/Os 0.0 0.0 0 0.0 %


---------------------------------------------------------------------------

testdb1.dat
testdb1 per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
0.0 0.0 0 n/a
------------------------- ------------ ------------ ---------- ----------
Total I/Os 0.0 0.0 0 0.0 %


---------------------------------------------------------------------------

testlog1.dat
testlog1 per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
0.0 0.0 0 n/a
------------------------- ------------ ------------ ---------- ----------
Total I/Os 0.0 0.0 0 0.0 %


---------------------------------------------------------------------------

===============================================================================

Network I/O Management
----------------------

Total Network I/O Requests 5.5 2.0 652 n/a
Network I/Os Delayed 0.0 0.0 0 0.0 %


Total TDS Packets Received per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
0.0 0.0 0 n/a
------------------------- ------------ ------------ ---------- ----------
Total TDS Packets Rec'd 0.0 0.0 0


Total Bytes Received per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
0.0 0.0 0 n/a
------------------------- ------------ ------------ ---------- ----------
Total Bytes Rec'd 0.0 0.0 0


-----------------------------------------------------------------------------

Total TDS Packets Sent per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
0.0 0.0 0 n/a
------------------------- ------------ ------------ ---------- ----------
Total TDS Packets Sent 0.0 0.0 0


Total Bytes Sent per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
0.0 0.0 0 n/a
------------------------- ------------ ------------ ---------- ----------
Total Bytes Sent 0.0 0.0 0


=============================== End of Report =================================
(return status = 0)

Thursday 1 December 2011

How to Install a warm standby Replication Server

This section will contain a step by step instruction on how to setup a warm standby replication.
Preparation of the Sybase ASE-servers
Create a maintenance user on both ASE's

The maintenance user is used by the replication server to apply transactions. Make sure that the name and password of the maintenance user on both servers are identical. For practical reasons make the maintenance user aliased to "dbo" in the database. Since a dump-load scenario is used to materialize the standby database, make sure that the suid of the maintenance user on both servers are identical.

This assumes that the databases in and the databases on are present and exactly the same size. The databases on do not need to have data in it, but need to be created and online.

isql –Usa –P -S

sp_addlogin "maint_user","maint123"
go
grant role replication_role to "maint_user"
go
-- check the value of the suid
select suser_id("maint_user")
go
use
go
sp_addalias "maint_user","dbo"
go

isql –Usa –P -S

sp_addlogin "maint_user","maint123"
go
grant role replication_role to "maint_user"
go
-- check the value of the suid
select suser_id("maint_user")
go
use
go
sp_addalias "maint_user","dbo"
go


Install the replication server stored procedures and tables

To do this, make a copy of the script rs_install_primary.sql located in the $SYBASE/$SYBASE_REP/scripts directory. Remove the last two commands of the script (the dbcc settrunc and the sp_setreplicate commands). The commands that are skipped will be executed at a later stage, when the replication agent is configured. Apply the script on the active server in the right database.

isql -Usa -P -S –D -i changed_rs_install_primary.sql
isql -Usa -P -S –D -i changed_rs_install_primary.sql


Configure both servers for replication

This step can be repeated several times. The setting is dynamic and no restart of ASE is necessary.

isql -Usa -P -S

sp_configure "enable rep agent threads",1
go

isql -Usa -P -S
sp_configure "enable rep agent threads",1
go


Preparation of the Replication Server
Create a logical connection on the replication server

The name of it does not have to match with the name of the primary database server and database, but this convention is widely used.

isql -Usa -P -S_rs

create logical connection to .
go


Create a connection from the replication server to the active database

isql -Usa -P -S_rs

create connection to .
set error class to rs_sqlserver_error_class
set function string class to rs_sqlserver_function_class
set username to
set password to
with log transfer on
as active for .
go

Create a login in the replication server

This login is used by the rep-agent running in the ASE to connect to the replication server.

isql -Usa -P -S_rs

create user set password
go
grant connect source to
go


Configure the RepAgent

The configuration of the Replication Agent within the active ASE should now be done. All steps within this paragraph should be executed within a controlled time frame since the transaction log cannot be cleared between the execution of the first sp_config_rep_agent and the sp_start_rep_agent. The configuration is only needed on the primary server. Since we use a dump-load scenario the configuration is copied to the standby server during the materialization phase.

isql -Usa -P -S

use
go
-- This will clear previously installed rep agents. How harm if none are present.
sp_config_rep_agent "", "disable"
go
-- Continue installing rep agent.
sp_config_rep_agent "", "enable", "_rs", "", ""
go
sp_config_rep_agent "", "send warm standby xacts", true
go
sp_setreplicate rs_marker,"true"
go
sp_setreplicate rs_update_lastcommit,"true"
go
sp_start_rep_agent ""
go


Mark the database for replication

Execute the sp_reptostandby stored procedure in the active ASE to activate replication from the active database to the replication server.

isql -Usa -P -S

use
go
sp_reptostandby "","all"
go

Configure the replication server for the standby database

All steps within this paragraph should be executed within a controlled time frame since the stable queue in the replication server cannot be cleared between the execution of the create connection and resume connection.

Create a connection from the replication server to the standby server


isql -Usa -P -S_rs

create connection to .
set error class to rs_sqlserver_error_class
set function string class to rs_sqlserver_function_class
set username to
set password to
with log transfer on
as standby for .
use dump marker
go

STOP: Before continuing perform the following checks.

isql -Usa -P -S_rs

admin logical_status
go


This should show both connections active and with the /Awaiting to enable marker clause at the standby connection. Nowhere should it read suspended.

isql -Usa -P -S_rs

admin who_is_down
go

There should be only 2 entries. DSI down . and DSI down .pcrdb. Everything else should be up.
Dump the database on the active server so it can be loaded into the standby server

isql -Usa -P -S

dump database to ""
go

Load the database dump into the standby server

isql -Usa -P -S

load database from ""
go
online database
go


Start the connection from the replication server to the standby database

isql -Usa -P -S_rs

resume connection to .
go


Test Replication Connection


isql -Usa -P -S

use
go
--create a dummy table. Skip this step if this table already exists.
create table test (a int)
go
insert test values(1)
go


isql -Usa -P -S

use
go
select * from test
go
--you should see the following
a
-----
1