码迷,mamicode.com
首页 > 数据库 > 详细

NBU备份DB2

时间:2018-12-18 14:37:43      阅读:268      评论:0      收藏:0      [点我收藏+]

标签:localhost   删除数据库   归档   http   directory   database   vendor   技术   enable   

查看状态
$ db2 list database directory
$ db2 get db cfg for BZDB
$ db2 list tablespaces
$ db2 list tables
$ db2 select * from table
· 创建数据库
$db2 create database BZDB
· 连接数据库
$db2 connect to BZDB
· 创建表
$ db2 create table test (name char(8) not null primary key,depid smallint,pay bigint)
· 插入数据
$ db2 insert into test values(‘li‘,1,1)
· 创建实例
DB2_install=/usr/opt/db2_08_01/instance
./db2icrt -u db2test db2test
· 删除数据库
db2 drop db db2test
db2stop
· 删除实例
cd DB2_install
./db2idrop -f db2test # -f参数一定要添加否则删除完了会报错!
· 删除用户
smitty user
选择Remove a User

  • User NAME [db2test] +
    Remove AUTHENTICATION information? yes
    删除用户目录
    rm -rf db2test
    vx:j8517870727
    技术分享图片
    · 查看归档
    [db2inst1@localhost ]$ db2 get db cfg|grep -i log
    Log retain for recovery status = NO
    User exit for logging status = YES
    Log buffer size (4KB) (LOGBUFSZ) = 256
    Log file size (4KB) (LOGFILSIZ) = 2000
    Number of primary log files (LOGPRIMARY) = 20
    Number of secondary log files (LOGSECOND) = 30
    Changed path to log files (NEWLOGPATH) =
    Path to log files = /home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/
    Overflow log path (OVERFLOWLOGPATH) =
    Mirror log path (MIRRORLOGPATH) =
    First active log file = S0000001.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) = 100
    Log retain for recovery enabled (LOGRETAIN) = OFF
    User exit for logging enabled (USEREXIT) = OFF
    HADR log write synchronization mode (HADR_SYNCMODE) = NEARSYNC
    First log archive method (LOGARCHMETH1) = DISK:/db2src/TS/backup/
    Options for logarchmeth1 (LOGARCHOPT1) =
    Second log archive method (LOGARCHMETH2) = OFF
    Options for logarchmeth2 (LOGARCHOPT2) =
    Failover log archive path (FAILARCHPATH)
    ###########################################################################################
    · 关闭第二归档方式
    $ db2 update db cfg for BZDB using LOGARCHMETH2 OFF
    · 将LOGARCHMETH1设为VENDOR
    $ db2 update database configuration for BZDB using LOGARCHMETH1 VENDOR:C:\progra~1\Veritas\NetBackup\bin\nbdb2.dll
    · 修改logretain状态为recovery
    $ db2 update db cfg for BZDB using userexit on
    · 修改userexit状态为on
    $db2 update db cfg for BZDB using logretain on
    · 使数据库能够增量备份
    $ db2 update db cfg for BZDB using trackmod yes
    · 执行离线备份,使归档日志模式生效
    $ db2 force application all
    win:
    $ db2 backup database nbutest to c:\db2_log
    linux:
    $ db2 backup database nbutest to /backup
    1、nbu配置
    创建db策略
    Attributes
    Policy type: DB2
    Schedules
    Name: DBFULL
    Type of Backup:Automatic Full Backup
    Schedule:
    Name: Default-Appplication-Backup-DB
    Type of Backup: Application Backup
    Clients: db2服务器主机名
    Backup Selections:db2_backup_nbu_online.cmd
    创建db log策略
    Attributes:
    Policy type: DB2
    Schedules:
    Name: Default-Application-Backup-LOG
    Type of backup: Application Backup
    Schedule:
    Name: LOGFuLL
    Type of backup:Automatic Full Backup
    Clients: DB2数据库主机
    Backup Selections:注此处为空

2、配置环境变量:db2.conf
从install_path\NetBackup\dbext\db2\samples\db2.conf 复制到 Install_path\NetBackup\dbext\db2\db2.conf

3、修改脚本:db2_backup_db_online.cmd
从install_path\NetBackup\ DbExt\sample\ db2_backup_db_online.cmd 复制到D盘 D:\db2_backup_nbu_online.cmd

4、修改db2uext2.exe
将C:\Program Files\Veritas\NetBackup\DbExt\DB2\db2uext2.exe复制到D:\SQLLIB\BIN

NBU备份DB2

标签:localhost   删除数据库   归档   http   directory   database   vendor   技术   enable   

原文地址:http://blog.51cto.com/718689/2331993

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!