jeffbeck
作者jeffbeck·2013-07-05 16:30
数据库管理员·某银行

db2_all,rah的区别使用及测试

字数 35661阅读 6548评论 4赞 0
关于命令db2_all,rah的区别使用

summary如下:

rah: to send to all physical servers
db2_all: to send to all database partitions:
db2_all '<<+1< command':send command to only database partition 1:
db2_all '<<-1< command':send command to all database partition except 1:
db2_all '||command':to execute command simultaneously across all database partitions:


下面是具体的操作测试:

db2_all "db2 "select count(*) from  scheam.test""
   这个命令相当于在每个节点上执行一次
   
   hostnameA:/db2home/db2inst1#db2_all "db2 "select count(*) from  scheam.test""
    
   
   1          
   -----------
     616526521
   
     1 record(s) selected.
   
   hostnameA_svc: db2 "select count(*) ... completed ok
    
   
   1          
   -----------
     616526521
   
     1 record(s) selected.
   
   hostnameA_svc: db2 "select count(*) ... completed ok
   剩余节点输出类似
   

hostnameA:/db2home/db2inst1#db2_all "<<+1< db2 "select count(*) from  scheam.test ""     
                                                                                                            
                                                                                                            
    1                                                                                                           
    -----------                                                                                                 
      616526521                                                                                                 
                                                                                                 
      1 record(s) selected.                                                                      
                                                                                                 
    hostnameA_svc: db2 "select count(*) ... completed ok        
    
hostnameA:/db2home/db2inst1#db2_all "<<+1< db2 "select count(*) from  scheam.test where  dbpartitionnum(user_id)=current dbpartitionnum""  
                                                                                                                                  
                                                                                                                                  
    1                                                                                                                                                               
    -----------                                                                                                                       
       19268363                                                                                                                       
                                                                                                                                      
      1 record(s) selected.                                                                                                           
                                                                                                                                      
    hostnameA_svc: db2 "select count(*) ... completed ok        
    
hostnameA:/db2home/db2inst1#db2_all "<<-1< db2 "select count(*) from  scheam.test where  dbpartitionnum(user_id)=current dbpartitionnum""                                                                       
                                                                                                                                  
                                                                                                                                  
    1                                                                                                                                 
    -----------                                                                                                                       
              0                                                                                                                       
                                                                                                                                      
      1 record(s) selected.                                                                                                           
                                                                                                                                      
    hostnameA_svc: db2 "select count(*) ... completed ok                                                                               
    rah: omitting logical node 1                                                                                                      
                                                                                                                                      
                                                                                                                                      
    1                                                                                                                                 
    -----------                                                                                                                       
       19265711                                                                                                                       
                                                                                                                                      
      1 record(s) selected.                                                                                                           
                                                                                                                                      
    hostnameA_svc: db2 "select count(*) ... completed ok                                                                               
                                                                                                                                      
                                                                                                                                      
    1                                                                                                                                 
    -----------                                                                                                                       
       19272458                                                                                                                       
                                                                                                                                      
      1 record(s) selected.     
     剩余节点输出类似
      
db2_all "|| db2 "select count(*) from  scheam.test where  dbpartitionnum(user_id)=current dbpartitionnum""    

db2_all '|| db2 "select count(*) from  scheam.test where  dbpartitionnum(user_id)=current dbpartitionnum"'
并行处理每个节点的查询      

hostnameA:/db2home/db2inst1#db2_all '|| db2 "select count(*) from  scheam.test "'                                                                                                                                           
                                                                                                                                  
   rah: primary monitoring process for db2 is 10092770                                                                               
   rah: primary monitoring process for db2 is 6555460
   ...

hostnameA:/db2home/db2inst1#rah  '|| db2 "select count(*) from  scheam.test "'|more    

   rah: primary monitoring process for db2 is 7536742
   
   
   hostnameA_svc:
   hostnameA_svc: 1
   hostnameA_svc: -----------
   hostnameA_svc: 616526521
   hostnameA_svc:
   hostnameA_svc: 1 record(s) selected.
   hostnameA_svc:
   hostnameA_svc: db2 "select count(*) ... completed ok
   
   hostnameB:
   hostnameB: 1
   hostnameB: -----------
   hostnameB: 616526521
   hostnameB:
   hostnameB: 1 record(s) selected.
   hostnameB:
   hostnameB: db2 "select count(*) ... completed ok 

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

0

添加新评论4 条评论

atpeace331atpeace331数据库管理员银行
2014-08-19 22:05
jeffbeck: 恩,这个加一个环境变量就可以:
   db2set DB2DBDFT=dbname
DB2DBDFT 环境变量,挺好的,头一次使用
jeffbeckjeffbeck数据库管理员某银行
2014-06-24 22:02
wangyax: db2_all "db2 "select count(*) from  scheam.test""
能够直接执行吗?

怎么在我的环境中只能先连库再执行?而且()必须转义
db2_all "d
恩,这个加一个环境变量就可以:
   db2set DB2DBDFT=dbname
wangyaxwangyax软件开发工程师金融机构
2014-06-24 15:27
db2_all "db2 "select count(*) from  scheam.test""
能够直接执行吗?

怎么在我的环境中只能先连库再执行?而且()必须转义
db2_all "db2 connect to dbname;db2 select count(*) from  scheam.test"
lyq0619lyq0619数据库管理员北京速通科技有限公司
2014-06-13 15:43
rah的没看明白
Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广