Sybase DBA User Guide For Beginners
Sybase DBA User Guide For Beginners
Sybase DBA User Guide For Beginners
Sybase DBA
It is a humble attempt from our end to welcome the readers into the intriguing and amazing world of
SYBASE. Outmost care has been taken to ensure that it is easily grasped even by the novices. This
document hopefully will become the first step before you launch yourself into the profession of
DATABASE ADMINISTRATION. Few of the topics have been copied from www.sybase.com.
Sybase DBA Manual
Contents
What is DBMS/RDBMS? 4
Duties of DBA 4
What is Database? 5
Disk Initialization 9
Segments 11
Thresholds 12
Db_options 16
Configuration Parameters 16
Indexes 17
Hit/Miss Diagram 24
Page 2
Sybase DBA Manual
Backup/Recovery/Refresh/Restore 26
Dbcc 27
MDA Tables 28
Utilities 29
Troubleshooting 30
Calculations 33
Sybase Diagram 34
Crontab 37
Page 3
Sybase DBA Manual
What is DBMS/RDBMS?
A Data Base Management System is a collection of programs that enable users to create and maintain a
database. It can also be said that DBMS is a process of managing data for efficient retrieval and storage
of data. Hence it is general purpose software that facilitates the processes of defining, constructing,
manipulating and sharing databases among various users.
The RDBMS is a database management system that that stores data in the form of tables and there is
also a relationship that exists between the tables. In a RDBMS data and information is acquired by the
relations or tables.
Duties of DBA
The following are some of the duties of a DBA-
Checking the server status (automate the job in crontab to monitor the server status).
Ensure that backups happen daily.
Health check for all the databases.
Performance related tasks (automate Update statistics & sp_recompile in crontab).
Rebooting the servers during maintenance window.
Security Management (adding logins/users with proper approvals from application/technical
leads).
Proactively monitoring the database data & log growth (threshold setup).
Monitoring error logs.
Adaptive Server Enterprise (ASE) has long been noted for its reliability, low total cost of ownership and
superior performance. With its latest version, ASE 15, it has been dramatically enhanced to deliver
capabilities urgently needed by enterprises today. It lays the long-term foundation for strategic agility
and continuing innovation in mission-critical environments. ASE 15 provides unique security options and
a host of other new features that boost performance while reducing operational costs and risk. Find out
how you can exploit new technologies such as grids and clusters, service-oriented architectures and
real-time messaging.
ASE 15 meets the increasing demands of large databases and high transaction volumes, while providing
a cost effective database management system. Its key features include on-disk encryption, smart
partitions and new, patent-pending query processing technology that has demonstrated a significant
increase in performance, as well as enhanced support for unstructured data management. ASE is a high-
performance, mission-critical database management system that gives Sybase customers an operational
advantage by lowering costs and risks.
Page 4
Sybase DBA Manual
SHARED MEMORY
<Servername>.krg
Wash Area
NH
Master Device Initialized
System Processes
ASE
Master DB recovered
SH
DH MRU LRU
Pool POOL
Page 5
Sybase DBA Manual
What is Database?
Database is collection of data objects (Tables, Views, Stored Procedures, Functions, Triggers and
indexes).
Number of databases that can be created under one adaptive server depends on the
configuration parameter “number of databases”
All the information regarding databases created in single adaptive server can be viewed in
system table SYSDATABASES and the database space usage in SYSUSAGES.
Databases are broadly divided into system and user databases.
o System databases are default databases created during adaptive server installation
(master, model, tempdb & sysbsystemprocs) few system databases are optional and can
be created/configured by DBA (sybsecurity, sybsyntax, DBCC and sybsystemdb). Some of
them are Sybsecurity, sybsystemdb, pubs, sybsyntax, and dbcc.
o User databases can only be created by the system administrator or whoever has the
system administrator privileges. A max of 256 Databases can be created on single
adaptive server.
Syntax
Create database database_name
[On {default | database_device} [= size]
[, database_device [= size]]...]
[Log on database_device [= size]
[, database_device [= size]]...]
[With {override | default_location = "pathname"}]
[For {load | proxy_update}]
Options:
With override: must be specified when data and log segments are placed on a same Database
device.
For load: does not initialize the allocated space which saves times when a dump will be loaded
next
Alter database db_name on data_dev2= '100M'
Drop database db_name: drops the database which is not currently in use and not contain any
constraints referring to other databases.
Dbcc dbrepair (db_name, dropdb)
Sp_helpdb: displays information about specified database. When used without any db name
displays information about all databases. When db name is current database then displays even
segment information.
Page 6
Sybase DBA Manual
sp_spaceused: Displays total space used by all the tables in current database
sp_spaceused appl3
Master DB stores information regarding all other databases, Logins, Devices, etc. It keeps track of
all the databases. It has nearly 32 system tables. Some of them are syslogins, sysdb, sysdevices,
sysroles, sysprocess, etc. Server wide details are stored in here. It’s the heart of the Server.
Model DB is the template for all the databases, excluding the Master.
Temp DB can be referred as a workspace for the users to perform operations. It’s a volatile
memory, so whenever the server is rebooted, it has to be recreated using the template from
Model DB. Three kinds of table are created in the Tempdb,
o Session level (table name prefixed with #) - A session level temporary table exists till the
expiry of the session of the user
o Global level (table name prefixed with tempdb) - A global level temporary tables exists
till the server is rebooted
o Workable tables- System creates this kind of tables like for sorting purpose.
2K logical page size 4K logical page size 8K logical page size 16K logical page size
250 506 1018 2042
Global Allocation Map (SYSGAMS system table) records and tracks all the information of all the
AU’s in the particular database. SYSGAMS is not accessible by any user. For every 8GB of disk
space a new GAM is created.
Page 7
Sybase DBA Manual
Latch: - Latches are non transactional synchronization mechanisms used to guarantee the physical
consistency of a page. While rows are being inserted, updated or deleted, only one Adaptive Server
process can have access to the page at the same time. Latches are used for datapages and datarows
locking but not for all pages locking.
Note: - The most important distinction between a lock and a latch is the duration
Latch Lock
A latch is held only for the time required to A lock can persist for a long period of time: while
insert or move a few bytes on a data page, to a page is being scanned, while a disk read or
copy pointers, columns or rows, or to acquire a network write takes place, for the duration of a
latch on another index page statement, or for the duration of a transaction
Page 8
Sybase DBA Manual
Disk Initialization
Disk initialization is the process of allocating disk space to server. During initialization adaptive
server will divide the new allocated disk into allocation units and an entry is made in sysdevices
system table.
All the information regarding devices connected to the Server, can be viewed in system table
SYSDEVICES.
Device that can be connected to a server was up to 256 till version 12.5, later got unlimited from
version 15.
A disk that is allocated to a server cannot be shared with other servers. Any number of
databases can use a disk as long as they are in the same server, restricting to a single file system.
Number of devices that can be allocated to the adaptive server depends on the configuration
parameter “number of devices”
Disk once initialized to the adaptive server can only be dropped when all the associated
databases are dropped
Disk default option for system database has to be turned off.
Syntax
Disk init
Name = "device_name" ,
Physname = "physicalname" ,
[Vdevno = virtual_device_number,]
Size = number_of_blocks
[, vstart = virtual_address
, cntrltype = controller_number]
[, contiguous]
[, dsync = {true | false}]
ASE 15.0
Page 9
Sybase DBA Manual
GAM
Previous NEXT
AU1 AU2 Page Header
1
2
3 2 1
3
AP OAM AP OAM
OAM
Extent
The object is extended to another AU
AU1 AU2
Whenever a user inserts some data it first checks for available pages in the current extent (OAM) and
inserts into it. If not found a new extent is allocated for that object in the same allocation unit with the
help of the allocation page. This extent is mapped to the OAM of the object. If the extent is not available
in the same allocation unit it checks with GAM for a new allocation unit (available extent), allocation
page where a new extent can be allocated. After the extent is allocated to the object in a different
allocation unit, this extent is mapped with the OAM of the object present in the other allocation unit. If
there are no allocation units available for the current requested page in the current GAM, a new GAM is
created and later altogether the whole process for new page is processed. If the data exceeds 8GB, new
GAM comes into picture. In this way GAM, AU, AP, OAM come into picture when a new request for a
page is requested.
Page 10
Sybase DBA Manual
Segments
Segment can be describes as the logical name that can be give to a single/fraction/more devices.
Two types of segments- System and User
System defined- System, Default & Log
System- stores all the data related to system tables in that particular database
Log- all data modifications in the database are temporarily stored in log
Default- stores the data related to user created data objects
User defined- A max of 32 segments can be created in a database including the 3 system
segments.
SYSSEGMENTS, SYSUSAGES system tables stores detail information regarding the segments, DB
size, etc.
The Data and Log segments for a single database should not be placed on a single device in
order to improve the performance and recovery is impossible.
Before deleting the segments we should ensure that the objects associated to that segment are
dropped.
When we add the additional space to the database system and default segments will
automatically extends on new device where as user created segments has to be manually
extended.
There are 3 ways in which we can move tables form one segment to another.
o Using bcp- Take a backup of the objects and then copy them back to new segment.
o Using clustered index- By re-creating a clustered index for the object on new segment.
o Using sp_placeobject – It moves the next upcoming records to the new segment.
Syntax
Creates seg_name in the current database and device name
sp_addsegment seg_name, db_name, device_name: db_name matches to current database
sp_helpsegment seg_name: Displays information about all the segments in current database. If
specified display information about only one segment which is specified
Page 11
Sybase DBA Manual
Thresholds
Thresholds monitor the free space in a database and alert the DBA to take appropriate action to
prevent the max usage of the database segments coz if neglected the server will hang and is
users cannot access.
Thresholds can be defined on data and log segments.
Two types of thresholds : System & User
o System level- Last chance Threshold. Usually 18% of log space is reserved for LCT. LCT
threshold limit value cannot be modified and is set by the adaptive server automatically.
We can only modify the stored procedure Sp_thresholdaction.
o User level- Free chance Threshold. FCT is defined by the user as per the usage of the
database and log segment size.
Sp_thresholdaction sends alert if transaction crosses the LCT.
A max of 256 thresholds can be created for a Database.
All the details regarding the thresholds can be found in SYSTHRESHOLD.
FCT’s can be dropped or modified.
Syntax
Sp_addthreshold dbname, segname, free_space, proc_name: To add a threshold.
Sp_modifythreshold dbname, segname, free_space [, new_proc_name] [, new_free_space] [,
new_segname]: To modify a given threshold.
Roles provide individual accountability for users performing system administration and security-
related tasks. Roles are granted to individual server login accounts, and actions performed by
these users can be audited and attributed to them
SYSTEMTABLE: sysroles
Groups provide a convenient way to grant and revoke permissions to more than one user in a
single statement.
The sp_addgroup system procedure adds a row to Sysusers in the current database. In other
words, each group in a database-as well as each user-has an entry in Sysusers.
By default ASE databases has default group as public group.
Below are a few descriptions of ROLES-
o System Administrator (sa_role )
o System Security Officer (SSO_role)
o Operator (oper_role )
o Sybase technical support (sybase_ts_role)
o Replication (replication_role)
o Distributed transaction manager (dtm_tm_role)
Page 12
Sybase DBA Manual
Syntax
Create role role_name [with passwd "password"[, {passwd expiration | min passwd length |
max failed_logins} option_value] ]: To create a role.
Sp_addgroup grpname: To create a group.
SYSLOGIN holds the details which allow people to access the Server level.
SYSUSERS holds the details which allow people to access the Databases level.
These two above table are related with the column ‘suid’.
Syslogins: Suid, dbname, name, password, srvname, procid.
Sysusers: Suid, uid, gid, name.
Syntax
Sp_addlogin loginame, passwd [, defdb][, deflanguage][, fullname][, passwdexp]: To create a
login with a default database.
Sp_adduser loginame [, name_in_db [, grpname]]: To create a user for a login for a database.
An interface file contains network information about all servers on your network, including
Adaptive Server, Backup Server, and XP Server, plus any other server applications such as
Monitor Server, Replication Server, and any other Open Server applications.
The network information in the file includes the server name, network name or address of the
host machine, and the port, object, or socket number (depending on the network protocol) on
which the server listens for queries.
Dsedit or Dscp utility are used to create an interface file. Using Dsedit or Dscp is preferred than
text editor as it’s easier to use and ensures that the interface file is consistent in format.
Error log is stored externally. All the server level events and severity level >16 will be recorded in
the error log.
Page 13
Sybase DBA Manual
We notice error number, severity level >16 and error message in the errorlog.
These error messages can be found in the table sysmessages.
Severity level less than 17 are not recorded in the error log, as the affect is minimal. Object level
error messages are not included in the error log.
We cannot start the ASE without errorlog file.
Page 14
Sybase DBA Manual
The higher levels and parts of the lower levels of frequently used indexes
Recently accessed data pages
The key points for memory configuration are:
o The system administrator should determine the size of shared memory available to
Adaptive Server and set 'max memory' to this value.
o The configuration parameter 'allocate max shared memory' can be turned on during
boot-time and run-time to allocate all the shared memory up to 'max memory' with the
least number of shared memory segments. Large number of shared memory segments
has the disadvantage of some performance degradation on certain platforms. Please
check your operating system documentation to determine the optimal number of
shared memory segments. Note that once a shared memory segment is allocated, it
cannot be released until the next server reboot.
o Configure the different configuration parameters, if the defaults are not sufficient.
o Now the difference between 'max memory' and 'total logical memory' is additional
memory available for procedure, data caches or for other configuration parameters.
o The amount of memory to be allocated by Adaptive Server during boot-time is
determined by either 'total logical memory' or 'max memory'. If this value too high:
o Adaptive Server may not start, if the physical resources on your machine does is not
sufficient.
o If it does start, the operating system page fault rates may rise significantly and the
operating system may need to re configured to compensate.
For a good performance, the Hit/Miss ratio should be over 90% and can be found by stored
procedure sp_sysmon.
Page 15
Sybase DBA Manual
Db_options
To change the default settings for the database we use database options.
Sp_dboption- displays or changes database options.
List of database options are-
Configuration Parameters
Config parameter defines the server wide settings and is divided in to static and dynamic.
All the static configured parameters values are stored in table sysconfigure.
All the dynamic configured parameters values are stored in table syscurconfigure.
Config values also stored in the <server name>.cfg file and every time you modify the config
values the current <server name>.cfg file will be saved as <server name>.001 and new config
values will be appeared in <server name>.cfg file.
We cannot start the ASE without valid config file.
Always have the backup for config file
Page 16
Sybase DBA Manual
Indexes
Indexes are created for the faster retrieval of the data. Indexes are preferred when the total
requested records are less than or equal to 5% of total table rows.
Whenever a new record is inserted into a table with no index, it stored into the last available
page called hot spot. Table without a clustered index is known a Heap Table.
When there is no index on the table the user requested query will perform the table scans
(scanning each page that is allocated to the object). To avoid the table scan we prefer indexes.
Indexes can be broadly divided into two types
o Clustered Indexes- There can only one clustered index for a table in binary tree format.
The leaf nodes contain the data itself. Data is stored in physical order (asc/desc). Total 3
levels (root, intermediate & data/leaf). Whenever we recreate the clustered index the
non-clustered index (if exists) will be automatically recreated and update statistics will
run on the object automatically (ASE will run internally).
o Nonclustered Indexes- There can be as many as 249 non clustered indexes for a table.
The leaf nodes contain pointers that map to the actual data. This is the reason why it
takes more time for nonclustered index data. It is logical. Total 4 levels (root,
intermediate. Leaf & data).
All the indexes can be found in table sysindexes for a database. Table is identified by value 0;
Clustered index is identified by value 1, where as rest non clustered indexes are identified from
2 to 249.
Diagrams that explain clearly about clustered and non clustered index pages.
Page 17
Sybase DBA Manual
Page 18
Sybase DBA Manual
Page 19
Sybase DBA Manual
Page 20
Sybase DBA Manual
o Update locks-Adaptive Server applies an update lock during the initial phase of an
update, delete, or fetch (for cursors declared for update) operation while the page or
row is being read. Update locks help avoid deadlocks and lock contention. If the page or
row needs to be changed, the update lock is promoted to an exclusive lock as soon as no
other shared locks exist on the page or row.
Table locks
o Intent lock-An intent lock indicates that page-level or row-level locks are currently held
on a table. Adaptive Server applies an intent table lock with each shared or exclusive
page or row lock, so an intent lock can be either an exclusive lock or a shared lock.
Setting an intent lock prevents other transactions from subsequently acquiring
conflicting table-level locks on the table that contains that locked page. An intent lock is
held as long as page or row locks are in effect for the transaction.
o Shared lock-This lock is similar to a shared page or lock, except that it affects the entire
table. A create nonclustered index command also acquires a shared table lock.
o Exclusive lock-This lock is similar to an exclusive page or row lock, except it affects the
entire table. For example, Adaptive Server applies an exclusive table lock during create
clustered index command. Update and delete statements require exclusive table locks if
their search arguments do not reference indexed columns of the object.
Syslocks contains information about active locks, and built dynamically when queried by a user.
No updates to Syslocks are allowed.
Deadlock can be tuned with two options –
o Deadlock checking period specifies the minimum amount of time (in milliseconds)
before Adaptive Server initiates a deadlock check for a process that is waiting on a lock
to be released.
o Deadlock retries specifies the number of times a transaction can attempt to acquire a
lock when deadlocking occurs during an index page split or shrink.
Spinlock ratio- A spinlock is a simple locking mechanism that prevents a process from accessing
the system resource currently used by another process. All processes trying to access the
resource must wait (or “spin”) until the lock is released. If 100 are specified for the spinlock
ratio, Adaptive Server allocates one spinlock for each 100 resources. The number of spinlocks
allocated by Adaptive Server depends on the total number of resources as well as on the ratio
specified. The lower the value specified for the spinlock ratio, the higher the number of
spinlocks.
Sp_lock reports information about processes that currently hold locks.
Lock promotion can only happen from row to table and page to table level.
Config parameters related to locks are :
o Number of locks
o Lock scheme
o Lock wait period
o Lock spinlock ratio
o page lock promotion HWM
Page 21
Sybase DBA Manual
Page 22
Sybase DBA Manual
Server has detected serious error Kill command not recommended. Server reboot
Infected
condition; extremely rare probably required to clear process
Page 23
Sybase DBA Manual
Hit/Miss Diagram
During the execution of a query, it goes through many phases, which can result as a HIT or a
MISS depending on the availability of the data in the cache.
The below diagrams clearly explain the steps involved during HIT or MISS.
Shared Memory
Max Memory
ASE
Interface file Connection Established
ASE E&O
Network Handler
Configuration
file
Executes Query
Parser
Running
Page 24
Sybase DBA Manual
Shared Memory
Max Memory
ASE
Interface file Connection Established
ASE E&O
Network Handler
Configuration
file
DISK
Data Fetched back to USER Data Cache
Unused Space
User
Send Sleep Procedure MISS
Cache
Receive Sleep Sleeping
Executes Query
Parser
If query plan not found
Compiler
Session Created
ser Log Cache in Shared Memory Execute Optimizer prepares Query Plan
Running
TABLE SYSQUERYPLANS
SYSSTATISTICS
UPDATE STATS
Page 25
Sybase DBA Manual
Backup/Recovery/Refresh/Restore
Recovery- Getting the database to the current state of data from a previously maintained
backup.
Refresh- Loading data from one database to another irrespective of sever.
Restore- Taking the database to a previous state.
Backup- Taking an extra copy of the existing data.
Page 26
Sybase DBA Manual
dba_remap_users.tx
t
Dbcc
Database consistency checker (dbcc) checks the logical and physical consistency of a database
and provides statistics, planning, and repair functionality.
dbcc Tablealloc checks the specified user table to ensure that-
o All pages are correctly allocated.
o Partition statistics on the allocation pages are correct.
o No page is allocated that is not used.
o All pages are correctly allocated to the partitions in the specified table and no page is
used until allocated.
o No page is used that is not allocated.
dbcc Checkalloc ensures that-
o All pages are correctly allocated
o Partition statistics on the allocation pages are correct
o No page is allocated that is not used
o All pages are correctly allocated to individual partitions and no page used until
allocated.
o No page is used that is not allocated
o dbcc Checkalloc [(database_name [, fix | nofix] )]
dbcc Tablealloc checks the specified user table to ensure that-
Page 27
Sybase DBA Manual
PROXY TABLES
Sp_addserver PROX_<server name>,NULL,<server name that u mention in interface file>
Sp_addexternlogin PROX_<server name>, <login name in source server>, <user at remote
server>, <password at remote server>
Sp_addobjectdef proxy_<table name>, “PROX_<server name>,<remote database
name>,<remote object owner>,<object name>”,”table”
Page 28
Sybase DBA Manual
MDA Tables
MDA tables provides detailed information about server status, the activity of each process in the
server, the utilization of resources such as data caches, locks and the procedure cache, and the
resource impact of each query that’s run on the server.
Steps that need to be followed during installing MDA tables-
o Check for sp_configure ‘enable cis’ and set to 1.
o Add ’loopback’ server name alias in master - sp_addserver loopback, null,
@@servername
o Install MDA tables - isql -U sa -P <password> -S<Server Name> –i
~/scripts/installmontables
o Assign 'Mon_role' to logins allowed MDA access- grant role Mon_role to sa
o To test for basic configuration – select * from master..monstate
o Assign several configuration parameters like enable monitoring to 1, sql text pipe active
to 1, sql text pipe max messages to 100, plan text pipe active to 1, plan text pipe max
messages to 100, statement pipe active to 1, statement pipe max messages to 100,
errorlog pipe active to 1, errorlog pipe max messages to 100, deadlock pipe active to 1,
deadlock pipe max messages to 100, wait event timing to 1, process wait events to 1,
object lockwait timing to 1, sql batch capture to 1, statement statistics active to 1, per
object statistics active to 1, max sql text monitored to 2048
Utilities
Optdiag -Displays optimizer statistics or loads updated statistics into system tables.
The advantages of Optdiag are-
o Optdiag can display statistics for all tables in a database, or for a single table.
Page 29
Sybase DBA Manual
o Optdiag output contains addition information useful for understanding query costs, such
as index height and the average row length.
o Optdiag is frequently used for other tuning tasks, so you should have these reports on
hand.
Isql - Interactive SQL parser to Adaptive Server.
Syntax –isql –Uuser –Sserver –Ddatabase.
When connecting to the server with isql, it goes to the file (sql.ini for Windows/interface.ini for
Solaris), and finds the path for the server.
ddlgen- This is used to take a back up of a table structure
Defncopy- This is used to take a backup of defaults, views, rules stored procedures and triggers.
Bcp – two options in and out. Out is to extract the data from the e object to flat file and In is vice
versa. Again In have two options, fast bcp (non-logged) and slow bcp (logged). For copying
back the data the option must be set to true- sp_dboption “select into /pllsort”, true.
Troubleshooting
If server config value has reached the max threshold limit for ‘number of open databases’,
‘number of open objects’, ‘number of open indexes’, ‘number of user connections’ & ‘number of
locks’. Please follow the steps below.
Sp_countmetadata- Gives information about the total number of objects like tables, sp’s, views,
triggers, etc. sp_countmetadata "configname" [, dbname].
Sp_monitorconfig- Gives information about max usage/current max value of the above
mentioned config parameters.
Sp_configure- To reconfigure the parameters with new value.
To check if the port is opened
Telnet <IP ADDRESS> <Port Number>
if the port is opened you will see a blank screen in command prompt....
To abort all the open transactions when log is full- Select LCT_admin(abort, pid, dbid).
a. The PID for the current running transaction can be identified from table SYSLOGSHOLD.
b. Once the PID is identified, the user details can be found from the table SYSPROCESSES.
c. Execute dbcc TRACEON (3604): Turning on the trace flag will display the trace output on
console rather than the error log.
d. Execute dbcc SQL TEXT (spid) : to view the details of the transaction
e. Execute dbcc TRACEOFF (3604)
f. To Kill Process- kill PID.
To view server status in Unix- showserver, & ps-esf |grep Sybase.
To know server version details- select @@version OR records in error log OR dataserver –v.
To know the current isolation level used by the server- select @@isolation.
For manually clearing shared segments- ipcrm –s/m<pid> and verify the values with <server
name>.krg file and once you clear the memory then delete the <server name>.krg file.
Page 30
Sybase DBA Manual
Also check for any active Sybase process ps –eaf |grep Sybase. Kill the active Sybase process
related to the particular server.
Memory Jam- It occurs due to the non de-allocation of the shared segments in the shared
memory.
To recover this we have to check out the number of servers running. Later we have to match the
<servername>.krg file with the details available on the shared segment allocated to the server.
Delete the identified segment by using- ipcrm –s<PID>.
It’s always a better practice to hold a backup of the <servername>.krg file, as it is deleted once
the server gets shut down.
a. Recovering master Database can be done only if a valid dump of Master database exists.
b. To build it again, steps followed are
i. Dataserver –d<device name> -z<page size> -b<size>.
ii. User should log into the server, in single user mode.
iii. Load the Master DB from previous backup.
iv. Restart the server.
Page 31
Sybase DBA Manual
Point-In-Time Recovery
a. PITR can be done only if a valid full dump of database, transaction log dumps and the
dump of current transaction log (dump tran <db name> to ‘<file name>’ with
no_truncate, this option will allow to perform the backup if database device fails.).
b. To do PITR, steps followed are
i. Restore the full backup
ii. Restore all the transaction logs in the sequence
iii. Restore the most recent transaction log which was dumped with no_truncate
option
iv. Bring the database online.
Log free space issue (showing minus value in log segment usage)
Use master
Go
Sp_stop_rep_agent <database name >
go
admin health
go
suspend connection to
go
admin who
go
admin health
go
admin disk_space
go
Page 32
Sybase DBA Manual
use master
go
sp_dboption <database name >, ‘dbo use’,true
go
sp_dboption <database name >, ‘single user’,true
go
select spid from sysprocesses where dbid=db_id(‘<database name >’)
go
(if find any active process kill them)
use <database name >
go
checkpoint
go
dbcc traceon(3604)
go
dbcc dbrepair(<database name >,’fixlogfreespace’)
go
dbcc traceon(3604)
go
use master
go
sp_dboption <database name >, ‘dbo use’,false
go
sp_dboption <database name >, ‘single user’,false
go
admin health
go
resume connection to
go
admin who
go
admin health
go
admin disk_space
go
use master
go
sp_start_rep_agent <database name >
go
Page 33
Sybase DBA Manual
TIPS
To find the ROWID
select rownum = identity(10) , <column name> into #<temp table name> from
<table name>
select * from #<temp table name>
drop #<temp table name>
go
Page 34
Sybase DBA Manual
s. If any of the hot fix is causing undesired results do not deploy the fix until further
testing.
t. Once the test environment looks stable with the new patch deployments and all issues
seen during the deployment are resolved the same can be moved to production.
u. Document all the steps, observations and workarounds that have been carried out
during the testing phase.
v. Prepare a Checklist.
w. Plan for roll out into production.
Sp_monitor - Displays statistics about Adaptive Server. Adaptive Server keeps track of how
much work it has done in a series of global variables. Sp_monitor displays the current values of
these global variables and how much they have changed since the last time the procedure
executed.
Sp_sysmon - Displays performance information, displays information about Adaptive Server
performance. It sets internal counters to 0, and then waits for the specified interval while
Page 35
Sybase DBA Manual
activity on the server causes the counters to be incremented. When the interval ends,
sp_sysmon prints information from the values in the counters .
If you face the performance issues.
Check the physical_io in sysprocesses table and trace the spid details
Dbcc traceon(3604)
Dbcc sqltext(spid)
Sp_who
Sp_lock
Sp_object_stats “00:10:00”
Sp_monitorconfig “all”
Calculations
To find vdev number- Select max (low/16777218) from Master..sysdevices.
Procedure cache size= (max number of concurrent users)*(4+size of largest plan)*1.25.
Minimum procedure cache size needed=(number of main procedures)*(Average plan size).
To get a rough estimate of the size of a single stored procedure, view, or trigger, use:
select(count(*) / 8) +1 from sysprocedures where id = object_id("procedure_name").
number of worker processes = [max parallel degree] X [the number of concurrent connections
wanting to run queries in parallel] X [1.5].
Size of the tempdb = 20% of sum up of all the user databases.
Size of Log disk= 10 % of the data disk of the particular device.
Size of DBCC database- can be found out from sp_plan_dbccdb.
Stored procedure to get the segment usage report
get_segment_space.
txt
Page 36
Sybase DBA Manual
Sybase Diagram
Sybase Diagram.doc
Page 37
Sybase DBA Manual
called the Replication Agent. However, you still need to use an LTM for non-ASE sources. When
replication is active, one connection per each replicated database in the source dataserver
(sp_who).
Replication Server (s) - The replication server is an Open Server/Open Client application. The
server part receives transactions being sent by either the source ASE or the source LTM. The
client part sends these transactions to the target server which could be another replication
server or the final dataserver.
Replicate (target) Dataserver – It is the server in which the final replication server (in the queue)
will repeat the transaction done on the primary. One connection for each target database, in the
target dataserver when the replication server is actively transferring data (when idle, the
replication server disconnects or fades out in replication terminology).
Stable Queue- after Replication Server is installed; a disk partition is set up used by Replication
Server to establish stable queues. During replication operations, Replication Server temporarily
stores updates in these queues. There are three different types of stable queues, each of which
stores different type of data.
o Inbound Queue- holds messages only from a Replication Agent. If the database you add
contains primary data, or if request stored procedures are to be executed in the
database for asynchronous delivery, Replication Server creates an inbound queue and
prepares to accept messages from a Replication Agent for the database.
o Outbound Queue- holds messages for a replicate database or a replicate Replication
Server. There is one outbound queue for each of these destinations:
For each replicate database managed by a Replication Server, there is a Data
Server Interface (DSI) outbound queue.
For every Replication Server to which a Replication Server has a route, there is a
Replication Server Interface (RSI) outbound queue.
o Subscription Materialization Queue- holds messages related to newly created or
dropped subscriptions. This queue stores a valid transactional “snapshot” from the
primary database during subscription materialization or from a replicate database
during dematerialization.
Stable Queue Manager manages all these operations related to Stable Device.
Data Server Interface- It connects RDS and Rep Server. It reads data from Outbound Queue and
replicates to RDS according to the subscriptions.
Distributor- It takes care of sending committed transaction from inbound queue to outbound
queue with the help of Stable Queue Transaction (SQT) Reader.
Any exceptions encountered during the process are recorded into rs_exception.
o Whenever two servers required to be connected over WAN, they both have to be set
into a single domain.
o If Rep Servers are more than 10, Rep monitoring service (RMS) is required to manage all
of them. Otherwise they are managed by Replication Manager.
o There can be multiple rep definitions for a single table.
o Multiple servers can be connected in two ways- Hierarchal and Star.
Page 38
Sybase DBA Manual
Page 39
Sybase DBA Manual
NAM
Transaction log Committed Transactions
NM
STABLE DEVICE
BM
Stable Queue
Secondary Transaction Point found in rs_loacter
Managed by Stable Queue Manager
Page 40
Sybase DBA Manual
Crontab
Job scheduling at UNIX level is done in crontab. All the DBA jobs are scheduled to run
automatically in crontab. Each user on UNIX level has own crontab and one should have the
privilege to add/modify the crontab.
Syntax- crontab [ -e [opens the crontab editor] | -l [lists all the crontab entries] | -r [removes the
crontab file].
Always have the backup for crontab.
Page 41
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: