Chinaunix首页 | 论坛 | 博客
  • 博客访问: 544496
  • 博文数量: 92
  • 博客积分: 980
  • 博客等级: 准尉
  • 技术积分: 1427
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-25 20:34
文章分类

全部博文(92)

文章存档

2015年(3)

2014年(15)

2013年(27)

2012年(38)

2011年(9)

分类: DB2/Informix

2013-07-19 09:13:13

 
    1. 启动一个在线备份

    arlqsap01:db2qsa:QSA:/db2/QSA/db2qsa> db2 list utilities

     

    ID                               = 1002045

    Type                             = BACKUP

    Database Name                    = QSA

    Partition Number                 = 0

    Description                      = online db

    Start Time                       = 07/16/2013 03:43:28.850911

    State                            = Executing

    Invocation Type                  = User

    Throttling:

       Priority                      = Unthrottled

    Progress Monitoring:

       Estimated Percentage Complete = 4

    1. 查看数据库当前的application中由db2连接进来的进程

     

    注意,这里的db2bp是代表来自CLP的数据库连接,而不是备份进程;一个CLP对应一个db2bp

    CLPThe command line processor consists of two processes: the front-end process (the DB2 command), which acts as the user interface, and the back-end process (db2bp), which maintains a database connection.

     

    db2 list applications |grep -i db2bp

    Auth Id  Application    Appl.      Application Id                                                 DB       # of

             Name           Handle                                                                    Name    Agents

    -------- -------------- ---------- -------------------------------------------------------------- -------- -----

    DB2QSA   db2bp          33467      *LOCAL.db2qsa.130716014325                                     QSA      5   

    DB2QSA   db2bp          33587      *LOCAL.db2qsa.130716022251                                     QSA      1   

    QSAADM   db2bp          10981      *LOCAL.db2qsa.130524085441                                     QSA      1   

     

    1. 查看具体的application在做什么

    arlqsap01:db2qsa:QSA:/db2/QSA/db2qsa> db2pd -d qsa -applications 33467

     

    Database Partition 0 -- Database QSA -- Active -- Up 130 days 17:05:58 -- Date 07/16/2013 04:41:26

     

    Applications:

    Address            AppHandl [nod-index] NumAgents  CoorEDUID  Status                  C-AnchID C-StmtUID  L-AnchID L-StmtUID  Appid                                                            WorkloadID  WorkloadOccID CollectActData          CollectActPartition     CollectSectionActuals 

    0x0780000001C60080 33467    [000-33467] 5          79387      PerformingBackup        0        0          0        0          *LOCAL.db2qsa.130716014325                                       1           157001        N                       C                       N 

     

    External Connection Attributes

    Address            AppHandl [nod-index] ClientIPAddress                          EncryptionLvl SystemAuthID                                                                                                                   

    0x0780000001C60080 33467    [000-33467] n/a                                      None          DB2QSA                                                                                                                         

     

    Trusted Connection Attributes

    Address            AppHandl [nod-index] TrustedContext                                                                                                                   ConnTrustType                RoleInherited                                                                                                                  

    0x0780000001C60080 33467    [000-33467] n/a                                                                                                                              non trusted                  n/a                                                                                                                            

     

    Autonomous Routine Connections

    Address            AppHandl [nod-index] Status          Autonomous Routine Handl [nod-index] Status                

     

     

    arlqsap01:db2qsa:QSA:/db2/QSA/db2qsa> db2pd -d qsa -applications  33587

    Database Partition 0 -- Database QSA -- Active -- Up 130 days 17:06:25 -- Date 07/16/2013 04:41:53

     

    Applications:

    Address            AppHandl [nod-index] NumAgents  CoorEDUID  Status                  C-AnchID C-StmtUID  L-AnchID L-StmtUID  Appid                                                            WorkloadID  WorkloadOccID CollectActData          CollectActPartition     CollectSectionActuals 

    0x0780000001E70080 33587    [000-33587] 1          79243      UOW-Waiting             0        0          625      4527       *LOCAL.db2qsa.130716022251                                       1           157053        N                       C                       N 

     

    External Connection Attributes

    Address            AppHandl [nod-index] ClientIPAddress                          EncryptionLvl SystemAuthID                                                                                                                   

    0x0780000001E70080 33587    [000-33587] n/a                                      None          DB2QSA                                                                                                                         

     

    Trusted Connection Attributes

    Address            AppHandl [nod-index] TrustedContext                                                                                                                   ConnTrustType                RoleInherited                                                                                                                  

    0x0780000001E70080 33587    [000-33587] n/a                                                                                                                              non trusted                  n/a                                                                                                                            

     

    Autonomous Routine Connections

    Address            AppHandl [nod-index] Status          Autonomous Routine Handl [nod-index] Status   

     

    可以看到application 33467是在进行备份操作。   

     

    1. 进行备份的EDU

    arlqsap01:db2qsa:QSA:/db2/QSA/db2qsa> db2pd -edus | grep -i 79243

    79243     79243          26608377       db2agent (QSA) 0                    7064.905725   808.179431

     

    由此可见,在进行备份的时候,连接到数据库的应用,会自动再新启动一个应用,用来响应备份的需求(供所谓的备份工具来使用,即用db2 list utilities能够看到那个备份任务)

    但是否真的这样呢?下面将开始验证:

    1. 断开连接,从新的ssh客户端登录,不连接数据库,直接查询当前数据库上面的应用

    arlqsap01:db2qsa 3> db2 list applications | grep -i db2bp

    Auth Id  Application    Appl.      Application Id                                                 DB       # of

             Name           Handle                                                                    Name    Agents

    -------- -------------- ---------- -------------------------------------------------------------- -------- -----

     

    DB2QSA   db2bp          33467      *LOCAL.db2qsa.130716014325                                     QSA      5

    QSAADM   db2bp          10981      *LOCAL.db2qsa.130524085441                                     QSA      1

    arlqsap01:db2qsa 4>

    arlqsap01:db2qsa 6> db2pd -db qsa -agents | grep -i db2bp | grep -i qsa

    Address            AppHandl [nod-index] AgentEDUID Priority    Type     State       ClientPid  Userid   ClientNm Rowsread   Rowswrtn   LkTmOt DBName   LastApplId                                                       LastPooled         

    0x0780000001560080 33619    [000-33619] 53989      0           Coord    Inst-Active 38535426   qsaadm   db2bp    0          0          NotSet n/a      *LOCAL.db2qsa.130517051226                                       Fri May 17 07:12:24

    0x07800000025360A0 10981    [000-10981] 87067      0           Coord    Inst-Active 22937776   qsaadm   db2bp    2          0          NotSet QSA      *LOCAL.db2qsa.130524085441                                       Fri May 24 10:52:24

    0x07800000017A0080 33467    [000-33467] 79387      0           Coord    Inst-Active 47907266   db2qsa   db2bp    0          0          NotSet QSA      *LOCAL.db2qsa.130716014325                                       Tue Jul 16 03:42:32

    0x07800000022260A0 33981    [000-33981] 58931      0           Coord    Inst-Active 20447350   db2qsa   db2bp    0          0          NotSet n/a      *LOCAL.db2qsa.130716064203                                       Tue Jul 16 08:42:34

    0x07800000027160A0 33467    [000-33467] 80854      0           Coord    Inst-Active 47907266   db2qsa   db2bp    0          0          0      n/a      *LOCAL.db2qsa.130716014325                                       n/a                

    0x07800000024C0080 33467    [000-33467] 81367      0           Coord    Inst-Active 47907266   db2qsa   db2bp    0          0          0      n/a      *LOCAL.db2qsa.130716014325                                       n/a                

    0x07800000024C60A0 33467    [000-33467] 81624      0           Coord    Inst-Active 47907266   db2qsa   db2bp    0          0          0      n/a      *LOCAL.db2qsa.130716014325                                       n/a                

    0x07800000023F0080 33467    [000-33467] 81881      0           Coord    Inst-Active 47907266   db2qsa   db2bp    0          0          0      n/a      *LOCAL.db2qsa.130716014325                                       n/a                

     

     

    可以看到33467这个进程始终存在,因为备份没有结束,但是,以前能够看到的application,却不存在了,这是因为,以前application因为断开ssh客户端而断开了。同时,这一个application,同时有5agents为这个应用服务。

     

    由此,间接证明了备份时,需要使用一个application来为备份使用。

     

    1. 还可以在测试环境,使用如下方法进行验证:

    建立脚本:bak.shlist.sht.sh

    $ cat bak.sh

    db2 backup db sample online

    $ cat list.sh

     

    db2 list applications

    $ cat t.sh

    sh bak.sh &

    sh list.sh >> t.log

    sh list.sh >> t.log

    sh list.sh >> t.log

    sh list.sh >> t.log

    sh list.sh >> t.log

    sh list.sh >> t.log

    sh list.sh >> t.log

    sh list.sh >> t.log

    保证此时数据库没有任何applications连接:

    $ db2 list applications

    SQL1611W  No data was returned by Database System Monitor.

    执行脚本t.sh

    $ sh t.sh

    $

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

     

    执行完毕后,查看t.log

    $ cat t.log

    SQL1611W  No data was returned by Database System Monitor.

    SQL1611W  No data was returned by Database System Monitor.

    SQL1611W  No data was returned by Database System Monitor.

    SQL1611W  No data was returned by Database System Monitor.

    SQL1611W  No data was returned by Database System Monitor.

    SQL1611W  No data was returned by Database System Monitor.

    SQL1611W  No data was returned by Database System Monitor.

     

    Auth Id  Application    Appl.      Application Id                                                 DB       # of

             Name           Handle                                                                    Name    Agents

    -------- -------------- ---------- -------------------------------------------------------------- -------- -----

    DB2TEST  db2bp          11032      *LOCAL.db2test.130716072417                                    SAMPLE   5

     

    可以看到,有一个application因为backup而启动,同时为其服务的有5agents(有可能会抓不到,可以多执行几次)

     

    结论:进行数据库备份的时候,数据库会启动一个application来进行备份工作(响应备份工具的请求)。

     

     

     

           

阅读(2595) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~