Firebird Documentation IndexFirebird 2.1 Release NotesGlobal Improvements in Firebird 2.1 → Databases on Raw Devices
Firebird Home Firebird Home Prev: Global Improvements in Firebird 2.1Firebird Documentation IndexUp: Global Improvements in Firebird 2.1Next: Remote Interface Improvements

Databases on Raw Devices

A. Peshkov

Moving a Database to a Raw Device
Special Issues for nbak/nbackup
Further Advice about Raw Devices

File system I/O can degrade performance severely when a database in Forced Writes mode grows rapidly. On Linux, which lacks the appropriate system calls to grow the database efficiently, performance with Forced Writes can be as much as three times slower than with asynchronous writes.

When such conditions prevail, performance may be greatly enhanced by bypassing the file system entirely and restoring the database directly to a raw device. A Firebird database can be recreated on any type of block device.

Moving a Database to a Raw Device

Moving your database to a raw device can be as simple as restoring a backup directly to an unformatted partition in the local storage system. For example,

 gbak -c my.fbk /dev/sda7
      

will restore your database on the third logical disk in the extended partition of your first SCSI or SATA hard-drive (disk0).

Note

The database does not have a “database name” other than the device name itself. In the example given, the name of the database is '/dev/sda7'.

Special Issues for nbak/nbackup

The physical backup utility nbackup must be supplied with an explicit file path and name for its difference file, in order to avoid this file being written into the /dev/ directory. You can achieve this with the following statement, using isql:

# isql /dev/sda7
SQL> alter database add difference file '/tmp/dev_sda7';
      

To keep the size of the nbak copy within reasonable bounds, it is of benefit to know how much storage on the device is actually occupied. The '-s' switch of nbackup will return the size of the database in database pages:

# nbackup -s -l /dev/sda7
77173
        

Don't confuse the result here with the block size of the device. The figure returned—77173—is the number of pages occupied by the database. Calculate the physical size (in bytes) as (number of pages * page size). If you are unsure of the page size, you can query it from the database header using gstat -h:


  # gstat -h /dev/sda7
  Database "/dev/sda7"
  Database header page information:
          Flags                   0
          Checksum                12345
          Generation              43
          Page size               4096  <———
          ODS version             11.1
   . . . . . . .
        

Examples of nbackup Usage with a Raw Device

  1. A backup can be performed in a script, using the output from the '-s' switch directly. For example,

    # DbFile=/dev/sda7
    # DbSize=`nbackup -L $DbFile -S` || exit 1
    # dd if=$DbFile ibs=4k count=$DbSize | # compress and record DVD
    # nbackup -N $DbFile
                
  2. A physical backup using nbackup directly from the command line:

    # nbackup -B 0 /dev/sda7 /tmp/lvl.0
                

Further Advice about Raw Devices

Although no other specific issues are known at this point about the use of raw device storage for databases, keep in mind that

  • the growth and potential growth of the database is less obvious to end-users than one that lives as a file within a file system. If control of the production system's environment is out of your direct reach, be certain to deploy adequate documentation for any monitoring that will be required!

  • the very Windows-knowledgeable might want to try out the concept of raw device storage on Windows systems. It has not been a project priority to explore how it might be achieved on that platform. However, if you think you know a way to do it, please feel welcome to test the idea in your Windows lab and report your observations—good or bad or indifferent—back to the firebird-devel list.

  • Tip

    Maintain your raw devices in aliases.conf. That way, in the event of needing to reconfigure the storage hardware, there will be no need to alter any connection strings in your application code.

Prev: Global Improvements in Firebird 2.1Firebird Documentation IndexUp: Global Improvements in Firebird 2.1Next: Remote Interface Improvements
Firebird Documentation IndexFirebird 2.1 Release NotesGlobal Improvements in Firebird 2.1 → Databases on Raw Devices