db2_all "<<+0< db2 \"update db cfg for dbname USING DYN_QUERY_MGMT ENABLE\""
db2_all "mkdir /lvol3/DAS-Library/data16k";
为对分区数据库的所有分区进行备份操作,我们可利用 db2_all 的作用。在语句前加上 db2_all,并将语句引用在 "" 中,可令该语句在一个实例中的每个分区上被执行,而无需分别对每个分区重复发出相同的命令。BACKUP 便可通过这种方式实现对分区数据库的操作,但是对于编目分区例外。由于 DB2 在备份或恢复时要求独占编目分区,因此在对其它分区进行备份操作之前,首先必须先完成该分区的备份操作。
另外,在 db2_all 之后的 "" 语句中,我们还可以以下述方式作开头,以指定命令所作用的分区:
<<+分区号< :表示后续命令作用于该分区。
<<-分区号< :表示后续命令作用于除该分区之外的其它分区。
||<<-分区号< 或 <<-分区号; :表示后续命令作用于除该分区之外的其它分区,
并且是以并行方式进行的。
综上所述,对于分区数据库的数据进行备份操作的命令为(以编目分区号为 0 举例):
1. 无需并行操作的方式:
当备份操作不需要使用并行方式时,则不存在先对编目分区进行操作的问题,此时可通过一条命令实现备份操作。
db2_all "db2 BACKUP DATABASE <数据库别名> TO <路径/设备名>"
2. 使用并行操作的方式:
db2_all "<<+0< db2 BACKUP DATABASE <数据库别名> TO <路径/设备名>" (windows下)
db2_all "||<<-0< db2 BACKUP DATABASE <数据库别名> TO <路径/设备名>"
或
db2_all "<<-0<; db2 BACKUP DATABASE <数据库别名> TO <路径/设备名>"
即首先对编目分区 - 0 号分区进行备份操作,然后再对除编目分区之外的其它分区同时并行操作,以缩短操作的时间,这一点体现了分区数据库的优越性。
db2 force applications all
db2_all "<<+0db2_all "<<-0
If you are using DB2 DPF then you know that the db2start command will start up DB2 on all database partitions (across all servers) automatically. The way it does this internally is that it runs a remote shell on the remote partition and issues the start database manager code. As well, there is a command called db2_all which lets you run any command you want on all database partitions. For example, if you want to see how much space is available in a given path you could run
db2_all df path_name
which will return the output of the df command from all database partitions. This is quite handy when you have dozens of partitions.
The downside is that it has always used remote shell (rsh) which many security administrators do not like. As of 8.2.2 you can use secure shell (ssh) or any other remote shell program you want simply by setting the DB2RSHCMD registry variable. For example you could set it as follows:
db2set DB2RSHCMD=/usr/bin/ssh
Remember that this is only for DPF and only for starting the instance and running db2_all. But this new registry variable can make your security administrator much happier (and in turn make you happier because it is so easy to setup).
ssh server2 time
ssh server2 df -h
db2_all df -h
这里db2_all的命令其实是带有ssh servername command这样的格式,所以它能够返回命令在所有节点上的执行结果。
阅读(1322) | 评论(0) | 转发(0) |