Question
Informix Server: Buffered vs. Unbuffered Logging
Answer
Overview
Starting with Continuus/CM Release 4.5, the Informix Server's default configuration was modified to use the unbuffered logging method for maintaining its logical log buffers for each database. The purpose of this bulletin is to:
· Explain logical logging and the various logging modes
· Describe the steps in determining which logging method is currently be used for each database within an existing Informix online Server (UNIX and NT Servers).
· Outline how to change the logging mode (UNIX and NT Servers).
Details
Informix Servers configured with logging allow the server to recover from system crashes, such as power outages or system crashes, to a consistent state. The Informix Server uses the logical log (a collection of logs) to store database transactions (changes). The goal is to first restore the system to its most recent point of known physical consistency, which is the last checkpoint. It then applies the transactions found in the logical logs to the system, replaying all the transactions since the time of the checkpoint. It rolls back any transactions that were not committed at the time of the failure. With Informix servers, the same set of logs is shared by all databases; transactions from different databases are interleaved within the transaction logs.
Because the amount of data written to these logs can be quite large, the data is first cached in buffers, to be flushed out to disk at a later point. This helps reduce the amount of physical I/O needed to write the data to disk. By default, the server allocates three buffers for use with the logical logs and stores them in the Resident Portion of shared memory.
The flushing of the logical log buffer is determined by the logging mode of the database(s) being accessed as follows:
Buffered logging The buffer will not be flushed until it is full. There is a potential loss of data should a system crash occur before the buffer is flushed to disk.
Unbuffered logging The buffer is flushed as soon as any transaction is complete (i.e. a commit or rollback record is written to the log buffer). This mode guarantees that the log data will be saved.
If there are transactions against databases with both buffered and unbuffered logging (i.e. some databases use buffered logging, others use unbuffered logging), then the buffer will be flushed either when it is full or when transactions against the database(s) with unbuffered logging complete. The events that cause the logical log buffer to be flushed to disk:
· A checkpoint.
· One of the logical log buffers becomes full.
· A transaction is completed in a database that uses unbuffered logging.
· A database session ends for a database that does not use transaction logging.
Note: By default, CM Synergy databases are set up to have LTAPEDEV set to /dev/null. Therefore, when the logical logs get full, the backup of the logical logs is thrown away. Essentially, transaction logging is turned off. The reason for this is that most sites are not willing to incur the overhead of swapping out tapes or backing up files when the logs become full to gain the ability to recover to the latest transaction.
Determining Current Logging Mode
Informix 5.x (C/CM 4.5 on UNIX)
All UNIX-based Informix Servers in CM Synergy versions up to and including 4.5 use Informix version 5.X. one method to determine the logging mode of a database using Informix 5.X is to login as user informix on the server machine, set the environment variables and run "tbmonitor". The steps are outlined below:
1. Login as user informix on the server machine.
2. Set the Informix environment variables (assuming CCM_HOME is set correctly) :
using csh:
% setenv INFORMIXDIR $CCM_HOME/informix
% setenv TBCONFIG <servername>
% setenv PATH $INFORMIXDIR/bin:$PATH
using sh or ksh:
% INFORMIXDIR=$CCM_HOME/informix; export INFORMIXDIR
% TBCONFIG=<servername>; export TBCONFIG
% PATH=$INFORMIXDIR/bin:$PATH; export PATH
3. Start the Informix tbmonitor facility.
%tbmonitor
4. Select Status (User arrow keys to highlight and then hit Enter).
5. Select Databases and scroll down for the database you are interested in. The log status will
be in the right hand column. (B=buffered logging, U=unbuffered logging, N=no logging)
6. Press ESC to return to the Status Menu, then select Exit -> Exit to exit tbmonitor.
Informix 7.x (all C/CM 5.0, 5.0.1, 5.1 and C/CM 4.5 on Windows NT) and Informix 9.x (5.0, 5.0.1, 5.1 on LINUX)
The logging mode of the database can be determined by querying the sysdatabases table from the sysmaster database on the server machine and checking the column of "is_logging" and "is_buff_log". The steps are outlined below:
1. Login as user informix on the server machine.
2. Set the Informix environment variables by executing %CCM_HOME%\informix\setenv.cmd on Windows NT, or on the other platforms as follows :
Set the environment variables: INFORMIXDIR, INFORMIXSERVER, onCONFIG and PATH:
using csh:
% setenv INFORMIXDIR $CCM_HOME/informix
% setenv INFORMIXSERVER <servername>
% setenv PATH $INFORMIXDIR/bin:$PATH
using sh or ksh:
% INFORMIXDIR=$CCM_HOME/informix; export INFORMIXDIR
% INFORMIXSERVER=<servername>; export INFORMIXSERVER
% PATH=$INFORMIXDIR/bin:$PATH; export PATH
3. Run "dbaccess".
4. Choose the following menus: (Use arrow keys to highlight and hit enter).
Database -> Select -> sysmaster -> Exit -> Query Language -> New
5. Type the following (spaces are important before and after the '=') :
select * from sysdatabases where name = "dbname"
(Replace dbname with the name of the database in all lower case letters.)
6. Hit the ESC key and then choose Run from the menu.
The output should appear as below:
name dbname
partnum 3145760
owner ccm_root
created 05/11/1998
is_logging 1
is_buff_log 0
is_ansi 0
is_nls 0
flags 1
If "is_logging" is 1 then the database is in logging mode (can be buffered or unbuffered).
If "is_buff_log" is 1 then it's buffered logging.
7. Select Exit -> Exit to exit dbaccess.
Change Logging Mode
Informix 5.x (C/CM 4.5 on UNIX)
Switching between buffered and unbuffered logging can be done using tbtape.
1. Run "su informix" to become user informix on server machine.
2. Set up environment:
using csh:
% setenv INFORMIXDIR $CCM_HOME/informix
% setenv TBCONFIG <servername>
% setenv PATH $INFORMIXDIR/bin:$PATH
using sh or ksh:
% INFORMIXDIR=$CCM_HOME/informix; export INFORMIXDIR
% TBCONFIG=<servername>; export TBCONFIG
% PATH=$INFORMIXDIR/bin:$PATH; export PATH
3. Run "tbtape -U dbname" will set the logging mode to Unbuffered logging.
4. Run "tbtape -B dbname" will set the logging mode to Buffered logging.
Informix 7.x (all C/CM 5.0, 5.0.1, 5.1 and C/CM 4.5 on Windows NT) and Informix 9.x (5.0, 5.0.1, 5.1 on LINUX)
Switching between buffered and unbuffered logging can be done using ontape.
1. Login as user ccm_root or informix on Server machine.
2. Change directory to %CCM_HOME\informix.
4. Set the Informix environment variables by executing %CCM_HOME%\informix\setenv.cmd on Windows NT, or on the other platforms as follows :
Set the environment variables: INFORMIXDIR, INFORMIXSERVER, onCONFIG and PATH:
using csh:
% setenv INFORMIXDIR $CCM_HOME/informix
% setenv INFORMIXSERVER <servername>
% setenv onCONFIG <servername>
% setenv PATH $INFORMIXDIR/bin:$PATH
using sh or ksh:
% INFORMIXDIR=$CCM_HOME/informix; export INFORMIXDIR
% INFORMIXSERVER=<servername>; export INFORMIXSERVER
% onCONFIG=<servername>; export onCONFIG
% PATH=$INFORMIXDIR/bin:$PATH; export PATH
4. Run ontape -U <dbname>" will set the logging mode to Unbuffered logging.
5. Run ontape -B <dbname>" will set the logging mode to Buffered logging.
CM Synergy 4.5, 5.x, 6.xTB155ContentProduct versionPartner ContentInternal ContentCategoryReference I'Informix > informix reference' 카테고리의 다른 글
Avoiding system generated index and constraint names (0) | 2011.12.01 |
---|---|
How to identify 'BAD' indices in a database (0) | 2011.11.22 |
Determining the type of Enterprise Replication (0) | 2011.11.20 |
C-ISAM version and serial number -- Determining what they are for an existing C-ISAM installation. (0) | 2011.11.20 |
How to tell the version of Informix Products or Libraries Installed (0) | 2011.11.20 |