2016-08-19

System database's devices

Information regarding devices in Sybase/ SAP ASE can be found in many system tables, however this will be a very bad idea to modify them directly. When you need a new device some dedicated commands should be used.

System databases are created during installation and normally you don't need to create them manually. Probably the only moment when a manual creation of databases will be required is when installation has been somehow damaged and you need to recover from the disaster.

During installation following devices have been created:

SELECT name,phyname FROM sysdevices

name                           phyname                                                       
------------------------------ -------------------------------------------------
master                         /opt/sap/data/master.dat       
tapedump1                      /dev/nst0                         
tapedump2                      /dev/nst1                         
sysprocsdev                    /opt/sap/data/sysprocs.dat
systemdbdev                    /opt/sap/data/sybsysdb.dat
tempdbdev                      /opt/sap/data/tempdbdev.dat
sybmgmtdev                     /opt/sap/data/sybmgmtdb.dat 

and those devices are used by following databases (we are skipping tape devices here as you see in WHERE clause):

SELECT
    d.name as 'device name',d.phyname, d.vdevno,
    u.size,
    db.name AS 'database name'
FROM sysdevices d
JOIN sysusages u ON d.vdevno = u.vdevno
JOIN sysdatabases db ON u.dbid = db.dbid
WHERE d.name NOT LIKE 'tape%' 

result is like this:

device name         phyname                       vdevno      size       database name                  
------------------- ----------------------------- ----------- ---------- --------------- 
master              /opt/sap/data/master.dat               0        6656 master                         
master              /opt/sap/data/master.dat               0        1536 tempdb                         
master              /opt/sap/data/master.dat               0        1536 model                          
master              /opt/sap/data/master.dat               0        1536 sybsystemdb                    
sysprocsdev         /opt/sap/data/sysprocs.dat             1       50176 sybsystemprocs                 
systemdbdev         /opt/sap/data/sybsysdb.dat             2        7680 sybsystemdb                    
tempdbdev           /opt/sap/data/tempdbdev.dat            3       25600 tempdb                         
sybmgmtdev          /opt/sap/data/sybmgmtdb.dat            4       19456 sybmgmtdb                      

As you can see:

  • master device hosts master, tempdb, model sybsystemdb databases
  • sysprocsdev hosts sysbsystemprocs database
  • systempdbdev device hosts sybsystemtempdb database
  • temdbdev device hosts tempdb database
  • and finally sybmgmtdev device hosts sybmgmtdb database
You may be surprised that master device (we can say the most important device on the server) hosts so many databases and additionaly among them the "database trash" - tempdb! No worries - this is only an initial fragment of temdb, not the entire temp database ;)

User databases are created using disk init command. Exception is sybsecurity database that's device will be created using auditinit command. A big exception is also... no surprise a master device.

To create master device you should use dataserver command. Yes, this is the same command that is the server itself! Passing some special parametrs this command apart from starting ASE will also create master device. The syntax is:

dataserver -d master_device_name -b <master device size> -z <logical page size>

The option -d is normally also used when server is started. It simply point to file or raw device, where master device is located on filesystem. Option -b determines the size of the device being created (it can be a number of 2KB virtual pages or a number with suffix K, M, G, T like 100M). Option -z determines  the size of logical page. (See also: Pages in SAP ASE: Virtual and Logical pages to learn the difference between virtual and logical page).

BTW, to display devices available on server you can use a dedicated stored procedure:

exec sp_helpdevice

Result is similiar to output of selecting all rows from sysdevices table.

No comments:

Post a Comment

SAP Adaprive Server Enterprise

SAP Adaprive Server Enterprise
SAP Adaprive Server Enterprise