DB2开启归档模式

来源:互联网 发布:老人打字软件 编辑:程序博客网 时间:2024/06/06 14:10

[db2inst9@th1 ~]$ db2 get db cfg for test9 |grep log
 User exit for logging status                            = NO
 Catalog cache size (4KB)              (CATALOGCACHE_SZ) = 300
 Number of primary log files                (LOGPRIMARY) = 13
 Number of secondary log files               (LOGSECOND) = 4
 Changed path to log files                  (NEWLOGPATH) = 
 Path to log files                                       = /data/db2inst9/db2inst9/NODE0000/SQL00001/SQLOGDIR/
 Overflow log path                     (OVERFLOWLOGPATH) = 
 Mirror log path                         (MIRRORLOGPATH) = 
 First active log file                                   = 
 Block log on disk full                (BLK_LOG_DSK_FUL) = NO
 Block non logged operations            (BLOCKNONLOGGED) = NO
 Percent max primary log space by transaction  (MAX_LOG) = 0
 Num. of active log files for 1 active UOW(NUM_LOG_SPAN) = 0
 Percent log file reclaimed before soft chckpt (SOFTMAX) = 520
 User exit for logging enabled                (USEREXIT) = OFF
 HADR log write synchronization mode     (HADR_SYNCMODE) = NEARSYNC
 First log archive method                 (LOGARCHMETH1) = OFF
 Options for logarchmeth1                  (LOGARCHOPT1) = 
 Second log archive method                (LOGARCHMETH2) = OFF
 Options for logarchmeth2                  (LOGARCHOPT2) = 
 Failover log archive path                (FAILARCHPATH) = 
 Number of log archive retries on error   (NUMARCHRETRY) = 5
[db2inst9@th1 ~]$ cd /data/db2inst9/arch/
#####################db2 update db cfg for test9 using LOGRETAIN ON
[db2inst9@th1 arch]$ db2 update db cfg for test9 using logretain recovery  
DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
[db2inst9@th1 arch]$ db2 force application all
[db2inst9@th1 arch]$ db2 terminate
[db2inst9@th1 arch]$ db2 backup db test9 to /data/db2inst9/

Backup successful. The timestamp for this backup image is : 20150813144518

[db2inst9@th1 arch]$ db2 connect to test9

   Database Connection Information

 Database server        = DB2/LINUXX8664 9.7.10
 SQL authorization ID   = DB2INST9
 Local database alias   = TEST9

[db2inst9@th1 arch]$ db2 get db cfg for test9|grep -i log 
 Log retain for recovery status                          = RECOVERY
 User exit for logging status                            = NO
 Catalog cache size (4KB)              (CATALOGCACHE_SZ) = 300
 Log buffer size (4KB)                        (LOGBUFSZ) = 256
 Log file size (4KB)                         (LOGFILSIZ) = 1024
 Number of primary log files                (LOGPRIMARY) = 13
 Number of secondary log files               (LOGSECOND) = 4
 Changed path to log files                  (NEWLOGPATH) = 
 Path to log files                                       = /data/db2inst9/db2inst9/NODE0000/SQL00001/SQLOGDIR/
 Overflow log path                     (OVERFLOWLOGPATH) = 
 Mirror log path                         (MIRRORLOGPATH) = 
 First active log file                                   = S0000000.LOG
 Block log on disk full                (BLK_LOG_DSK_FUL) = NO
 Block non logged operations            (BLOCKNONLOGGED) = NO
 Percent max primary log space by transaction  (MAX_LOG) = 0
 Num. of active log files for 1 active UOW(NUM_LOG_SPAN) = 0
 Percent log file reclaimed before soft chckpt (SOFTMAX) = 520
 Log retain for recovery enabled             (LOGRETAIN) = RECOVERY
 User exit for logging enabled                (USEREXIT) = OFF
 HADR log write synchronization mode     (HADR_SYNCMODE) = NEARSYNC
 First log archive method                 (LOGARCHMETH1) = LOGRETAIN
 Options for logarchmeth1                  (LOGARCHOPT1) = 
 Second log archive method                (LOGARCHMETH2) = OFF
 Options for logarchmeth2                  (LOGARCHOPT2) = 
 Failover log archive path                (FAILARCHPATH) = 
 Number of log archive retries on error   (NUMARCHRETRY) = 5
 Log archive retry Delay (secs)         (ARCHRETRYDELAY) = 20
 Log pages during index build            (LOGINDEXBUILD) = OFF
[db2inst9@th1 arch]$ db2 update db cfg for test9 using LOGARCHMETH1 "DISK: /data/db2inst9/arch/" 
SQL0104N  An unexpected token "/data/db2inst9/arch/" was found following 
"<identifier>".  Expected tokens may include:  "ALT_COLLATE".  SQLSTATE=42601
[db2inst9@th1 arch]$ db2 update db cfg for test9 using LOGARCHMETH1 "DISK:/data/db2inst9/arch/" 
DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
[db2inst9@th1 arch]$ ls
db2inst9
[db2inst9@th1 arch]$ db2 ARCHIVE LOG FOR DATABASE test9 
SQL1493N  The application is already connected to an active database.
[db2inst9@th1 arch]$ db2 force application all
DB20000I  The FORCE APPLICATION command completed successfully.
DB21024I  This command is asynchronous and may not be effective immediately.

[db2inst9@th1 arch]$ db2 terminate
DB20000I  The TERMINATE command completed successfully.
[db2inst9@th1 arch]$ db2 ARCHIVE LOG FOR DATABASE test9 
DB20000I  The ARCHIVE LOG command completed successfully.
[db2inst9@th1 arch]$ ls
db2inst9
[db2inst9@th1 arch]$ cd db2inst9/
[db2inst9@th1 db2inst9]$ ls
TEST9
[db2inst9@th1 db2inst9]$ cd TEST9/
[db2inst9@th1 TEST9]$ ls
NODE0000
[db2inst9@th1 TEST9]$ cd NODE0000/
[db2inst9@th1 NODE0000]$ ls
C0000000
[db2inst9@th1 NODE0000]$ cd C0000000/
[db2inst9@th1 C0000000]$ ls
S0000000.LOG
[db2inst9@th1 C0000000]$ db2 ARCHIVE LOG FOR DATABASE test9 
DB20000I  The ARCHIVE LOG command completed successfully.
[db2inst9@th1 C0000000]$ ls
S0000000.LOG  S0000001.LOG
[db2inst9@th1 C0000000]$ db2 LIST HISTORY  ARCHIVE LOG all for test9 

                    List History File for test9

Number of matching file entries = 4


 Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log  Backup ID
 -- --- ------------------ ---- --- ------------ ------------ --------------
  X  D  20150813144636      1    D  S0000000.LOG C0000000      
 ----------------------------------------------------------------------------

 ----------------------------------------------------------------------------
    Comment: 
 Start Time: 20150813144636
   End Time: 20150813144637
     Status: A
 ----------------------------------------------------------------------------
  EID: 4 Location: /data/db2inst9/arch/db2inst9/TEST9/NODE0000/C0000000/S0000000.LOG


 Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log  Backup ID
 -- --- ------------------ ---- --- ------------ ------------ --------------
  X  D  20150813144636      N                    S0000000.LOG  
 ----------------------------------------------------------------------------

 ----------------------------------------------------------------------------
    Comment: ARCHIVE LOG
 Start Time: 20150813144636
   End Time: 20150813144636
     Status: A
 ----------------------------------------------------------------------------
  EID: 5


 Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log  Backup ID
 -- --- ------------------ ---- --- ------------ ------------ --------------
  X  D  20150813144658      1    D  S0000001.LOG C0000000      
 ----------------------------------------------------------------------------

 ----------------------------------------------------------------------------
    Comment: 
 Start Time: 20150813144658
   End Time: 20150813144659
     Status: A
 ----------------------------------------------------------------------------
  EID: 6 Location: /data/db2inst9/arch/db2inst9/TEST9/NODE0000/C0000000/S0000001.LOG


 Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log  Backup ID
 -- --- ------------------ ---- --- ------------ ------------ --------------
  X  D  20150813144658      N                    S0000001.LOG  
 ----------------------------------------------------------------------------

 ----------------------------------------------------------------------------
    Comment: ARCHIVE LOG
 Start Time: 20150813144658
   End Time: 20150813144658
     Status: A
 ----------------------------------------------------------------------------
  EID: 7

[db2inst9@th1 C0000000]$ 



切换归档
可以利用db2 archive log for db sample 命令来强制归档

0 0
原创粉丝点击