免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 7835 | 回复: 7
打印 上一主题 下一主题

请教 db2 restore 问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-03-03 16:11 |只看该作者 |倒序浏览
最近在AIX上restore 另一AIX backup 出的数据库 失败!

如果 restore database xxdb
则提示
SQL0970N  The system attempted to write to a read-only file.  SQLSTATE=55009
恢复失败


如果 restore database xxdb redirect
则提示
SQL1277N  Restore has detected that one or more table space containers are
inaccessible, or has set their state to 'storage must be defined'.
DB20000I  The RESTORE DATABASE command completed successfully.

恢复成功, 但

connect to xxdb
提示
SQL0752N  Connecting to a database is not permitted within a logical unit of
work when the CONNECT type 1 setting is in use.
无法连接

请教高手,谢谢!

论坛徽章:
0
2 [报告]
发表于 2008-03-04 09:09 |只看该作者
表空间用的设备权限不够。

论坛徽章:
0
3 [报告]
发表于 2008-03-04 12:45 |只看该作者
restore database xxdb redirect只表示马上要进行一次redirect restore,实际的restore并没有开始。这后面需要重新set tablespace containers,然后restore continue。这样才算完成了整个redirect restore

论坛徽章:
0
4 [报告]
发表于 2008-03-04 14:41 |只看该作者
原帖由 coolalibaba 于 2008-3-4 12:45 发表
restore database xxdb redirect只表示马上要进行一次redirect restore,实际的restore并没有开始。这后面需要重新set tablespace containers,然后restore continue。这样才算完成了整个redirect restore


昨天查书发现是这样的, 对于每个tablespace n 要

set tablespace containers for n using ( path 'xxxx')

我先 list tablespaces, 一共57条,因此输57遍太麻烦了,所以准备 写个restore.db2脚本,如下

restore database olddb
        into newdb
        redirect
        without rolling forward@
begin atomic
        declare nr int default 0;
        while nr <= 56 do
                set tablespace containers for nr
                        using (path 'redir/tscon' || CHAR(nr)  );
                set nr = nr + 1;
        end while;
end@
restore database olddb continue@
@

然后执行 db2 -td@ -f restore.db2 -z restore.log

但有个问题, 我想为每个table space container 分配路径是加上个数字,但是不知如何把两个字符串组合起来, 我现在的

是错误的, 请问该怎么写,谢谢!

论坛徽章:
0
5 [报告]
发表于 2008-03-04 14:42 |只看该作者
原帖由 coolalibaba 于 2008-3-4 12:45 发表
restore database xxdb redirect只表示马上要进行一次redirect restore,实际的restore并没有开始。这后面需要重新set tablespace containers,然后restore continue。这样才算完成了整个redirect restore


昨天查书发现是这样的, 对于每个tablespace n 要

set tablespace containers for n using ( path 'xxxx')

我先 list tablespaces, 一共57条,因此输57遍太麻烦了,所以准备 写个restore.db2脚本,如下

restore database olddb
        into newdb
        redirect
        without rolling forward@
begin atomic
        declare nr int default 0;
        while nr <= 56 do
                set tablespace containers for nr
                        using (path 'redir/tscon' || CHAR(nr)  );
                set nr = nr + 1;
        end while;
end@
restore database olddb continue@
@

然后执行 db2 -td@ -f restore.db2 -z restore.log

但有个问题, 我想为每个table space container 分配路径是加上个数字,但是不知如何把两个字符串组合起来, 我现在的

是错误的, 请问该怎么写,谢谢!

论坛徽章:
0
6 [报告]
发表于 2008-03-04 17:04 |只看该作者
不是很熟悉db2脚本,但这个set containers不是SQL,所以||CHAR(...)应该不能用的。你嫌麻烦就自己用shell或bat文件生成一个set container的脚本,类似下面的,然后执行以下就行了
set tablespace containers for 1 using ( path 'redir/tscon1')
set tablespace containers for 2 using ( path 'redir/tscon2')
.....

论坛徽章:
0
7 [报告]
发表于 2008-03-10 23:46 |只看该作者

回复 #1 lotoren 的帖子

使用:
db2 restore db dbname from ... redirect generate script filename.ddl
可以生成重定向的脚本,再在脚本中修改container设置,运行脚本就行了。

论坛徽章:
0
8 [报告]
发表于 2008-03-19 13:52 |只看该作者
这个问题不知道楼主解决了没有,在数据库恢复或创建新的数据库时,会用到系统的/tmp目录,我看你的提示是写到只读文件,你给/tmp目录加上权限基本可以解决。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP