cancel
Showing results for 
Search instead for 
Did you mean: 

DB2 Log Chain

01-05-2013 3:39 PM
1114 views 7 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Dear all,

happy new year ;o)

I have a question regarding db6.

Does anyone know where db2 stores information about the current log chain?   Is there a file ?

Thanks a lot for your help.

Best Regards,

Andreas

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

Hi Andreas,

Happy 2013 to you too.

The DB2 transaction log files have consecutive names from S00000000.LOG to S99999999.LOG.

If a log file is full, DB2 creates a new log file with the next number.

In some special cases DB2 can create log files with the same name but different contents - stored in different directories identified by the chain number.

As you probably know, log file chains are created if the database is restored to a point in time.

If you understand a retore was done, then you should find the log chain info in the directories where the logs are stored.

regards,

Javier

Former Member
0 Likes

Good Morning Javier and Gaurav,

thanks for your responses.

I know why and when db2 creates log chains.

But do you know where db2 stores the information about log chains? Or how db2 calculates the next log chain? For example if I create a new database  and restore the db content from an backup image the current log chain e.g. 06 is created and not 00.  So I guess this information is stored in the backup image somewhere and maybe written into a file...

if yes do you know where?

Thanks again.

BR,

Andreas

Former Member
0 Likes

Hello Andreas,

I guess you might be talking about log control file which is created under db2 database directory. Log control file contains information about active logs and the information is used during crash recovery.

You can refer to DB2 information center for more details.

Database directories and files

Log control files

Regards,

Masako

former_member227150
Active Participant
0 Likes

Hi Andreas,

Are you talking about control files in log directory.

Please check if below file is of any help.

/db2/<SID>/db2<sid>/NODE0000/SQL00001/SQLOGCTL.GLFH.1

This is log control file.

Let me know if any issue.

Regards,

Gaurav

Former Member
0 Likes

Hi Gaurav,

thank you very much.

Yes it seems the log chain is stored in the log  header file.

Best Regards,

Andreas

Answers (1)

Answers (1)

former_member227150
Active Participant
0 Likes

In SAP, The default location for DB2 log files is/db2/<DB_SID>/log_dir

DB2 automatically adds database partition as NODE<nnnn> in the above logpath.

Log files starts with convention like S<nnnnnnn>.LOG

Now, there are two types of logging methods:

1) Circular Logging

2) Archival Loging

Circular Logging is used by default. Here DB2 handles logfiles in a circular fashion.

Circular fashion means if last logfile is full, then it writes to the first file and this process continues.

This type of logging is not recommended for Prod environments.

 

In Archival Logging, a log is stored at a Archiving Location as soon as logfile is full. Online backup can be taken for Database with this type of logging.

Recommended for Production usage.

 

You can use Parameters LOGARCHMETH1 and LOGARCHMETH2 to set logging type.

If both the abive parameters are set OFF then DB2 follows Circular Logging.

Regards

Gaurav

Former Member
0 Likes

Hi Andreas,

Please try with the following two commands to get the current log sequence number ( in case of both cicular and archive log mode ).

db2 get snapshot for database on <DB>

db2 get snapshot for database on <DB> | grep -i 'Log space'

Regards,

Dipam