DB2数据库的建库备份和恢复

Db2环境下建库步骤如下:

1. su  db2inst 【这是进入Linux的DB2用户资源下】

2. db2 进入db2命令行模式;

3. create database pb_db on /home/db2inst using codeset gbk territory zh_CN pagesize 8192   ---建库;

4. connect to pb_db  ---连接;

5. create bufferpool testpool size 2000 pagesize 32k --临时表空间缓冲池;

6. create temporary tablespace temp pagesize 32k managed by database using  (file   '\home\db2inst1\rdl\data' 5000) extentsize 80 bufferpool testpool --临时表空间;

7. create bufferpool pbloop immediate size 1000 pagesize 32k  --用户表空间缓冲池;

8. create regular tablespace pbxt pagesize 32k managed by database using (file '\home\db2inst1\rdl\data\user' 1024M) autoresize no extentsize 32 overhead 10.5 prefetchsize 32 transferrate  0.14 bufferpool pbloop --用户表空间


Db2数据库备份步骤如下:

1. 确保没有用户使用DB2

db2 list applications for db pb_db;

 

2. 停掉数据库并重新启动,以便断掉所有连接:

db2stop force

db2start;

 

3. 执行备份命令:(使用TSM作为备份介质)

db2 backup db pb_db use tsm备份成功,将会返回一个时间戳

db2 backup db pb_db to /home/db2inst1/rdl/data data文件夹下备份数据库生成一个001文件

 

Db2数据库恢复步骤如下:

1. 查看备忘历史记录:

db2 list history backup all for pb_db;

 

2. 恢复某个时间点的数据:

db2 restore database pb_db from /home/db2inst1/rdl/data taken at 20140625141510

 

此时会有警告提示,填写y就会恢复完成

 

 


下面为创建一个用户的完整案例:

linux-hplx:~ # su db2inst
db2inst@linux-hplx:/root> db2
(c) Copyright IBM Corporation 1993,2007
Command Line Processor for DB2 Client 9.7.0

You can issue database manager commands and SQL statements from the command 
prompt. For example:
    db2 => connect to sample
    db2 => bind sample.bnd

For general help, type: ?.
For command help, type: ? command, where command can be
the first few keywords of a database manager command. For example:
 ? CATALOG DATABASE for help on the CATALOG DATABASE command
 ? CATALOG          for help on all of the CATALOG commands.

To exit db2 interactive mode, type QUIT at the command prompt. Outside 
interactive mode, all commands must be prefixed with 'db2'.
To list the current command option settings, type LIST COMMAND OPTIONS.

For more detailed help, refer to the Online Reference Manual.

db2 => create database pb_db_c on /home/db2inst using codeset gbk territory zh_CN pagesize 8192
DB21019E  An error occurred while accessing the directory "/root".
db2 => connect to pb_db_c

   Database Connection Information

 Database server        = DB2/LINUX 9.7.0
 SQL authorization ID   = DB2INST
 Local database alias   = PB_DB_C

db2 => create bufferpool testpool size 2000 pagesize 32k
DB20000I  The SQL command completed successfully.
db2 => create temporary tablespace temp pagesize 32k managed by database using  (file   '\home\db2inst1\rdl\data' 5000) extentsize 80 bufferpool testpool             
DB20000I  The SQL command completed successfully.
db2 => create bufferpool pbloop immediate size 1000 pagesize 32k 
DB20000I  The SQL command completed successfully.
db2 => create regular tablespace pbxt pagesize 32k managed by database using (file '\home\db2inst1\rdl\data\user' 1024M) autoresize no extentsize 32 overhead 10.5 prefetchsize 32 transferrate  0.14 bufferpool pbloop --用

DB20000I  The SQL command completed successfully.
db2 => db2 => 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ItJavawfc

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值