查看状态
$ 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 db2testvx:j8517870727· 查看归档[db2inst1@localhost ]$ db2 get db cfg|grep -i logLog retain for recovery status = NOUser exit for logging status = YESLog buffer size (4KB) (LOGBUFSZ) = 256Log file size (4KB) (LOGFILSIZ) = 2000Number of primary log files (LOGPRIMARY) = 20Number of secondary log files (LOGSECOND) = 30Changed 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.LOGBlock log on disk full (BLK_LOG_DSK_FUL) = NOBlock non logged operations (BLOCKNONLOGGED) = NOPercent max primary log space by transaction (MAX_LOG) = 0Num. of active log files for 1 active UOW(NUM_LOG_SPAN) = 0Percent log file reclaimed before soft chckpt (SOFTMAX) = 100Log retain for recovery enabled (LOGRETAIN) = OFFUser exit for logging enabled (USEREXIT) = OFFHADR log write synchronization mode (HADR_SYNCMODE) = NEARSYNCFirst log archive method (LOGARCHMETH1) = DISK:/db2src/TS/backup/Options for logarchmeth1 (LOGARCHOPT1) = Second log archive method (LOGARCHMETH2) = OFFOptions 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 allwin:$ db2 backup database nbutest to c:\db2_loglinux:$ db2 backup database nbutest to /backup1、nbu配置创建db策略AttributesPolicy type: DB2SchedulesName: DBFULLType of Backup:Automatic Full BackupSchedule:Name: Default-Appplication-Backup-DBType of Backup: Application BackupClients: db2服务器主机名Backup Selections:db2_backup_nbu_online.cmd创建db log策略Attributes:Policy type: DB2Schedules:Name: Default-Application-Backup-LOGType of backup: Application BackupSchedule:Name: LOGFuLLType of backup:Automatic Full BackupClients: 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