12
返回列表 发新帖
楼主: sunny_zhao0127

估算 restore 一个db 至少需要多大的内存

[复制链接]
论坛徽章:
5
奥运会纪念徽章:蹦床
日期:2012-08-24 16:50:342013年新春福章
日期:2013-02-25 14:51:24鲜花蛋
日期:2013-06-08 15:24:31ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:422014年世界杯参赛球队: 意大利
日期:2014-06-25 12:38:19
11#
 楼主| 发表于 2013-8-21 09:19 | 只看该作者
db2diag -rc  0x8B0F0014

Input ZRC string '0x8B0F0014' parsed as 0x8B0F0014 (-1961951212).

ZRC value to map: 0x8B0F0014 (-1961951212)

ZRC class :
        Codes for Heap and Pool Errors (Class Index: 11)
Component:
        SQLO ; oper system services (Component Index: 15)
Reason Code:
        20 (0x0014)

Identifer:
        SQLO_NOMEM_APPSHRH
Identifer (without component):
        SQLZ_RC_NOMEM_APPSHRH

Description:
        No memory available in 'Applications Shared Heap'

Associated information:
        Sqlcode -973
SQL0973N  Not enough storage is available in the "" heap or stack to process
the statement.

        Number of sqlca tokens : 1
        Diaglog message number: 8300

使用道具 举报

回复
论坛徽章:
5
奥运会纪念徽章:蹦床
日期:2012-08-24 16:50:342013年新春福章
日期:2013-02-25 14:51:24鲜花蛋
日期:2013-06-08 15:24:31ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:422014年世界杯参赛球队: 意大利
日期:2014-06-25 12:38:19
12#
 楼主| 发表于 2013-8-21 10:14 | 只看该作者
db2 "? sql10003c"


SQL10003C  There are not enough system resources to process the request.
      The request cannot be processed.

Explanation:

The database manager could not process the request due to insufficient
system resources. The resources that can cause this error include:
*  The amount of memory in the system
*  The number of message queue identifiers available in the system.

User response:

Stop the application. Possible solutions include:
*  Remove background processes.
*  Terminate other applications using the above resources.
*  If you are using Remote Data Services, increase the Remote Data
   Services heap size (rsheapsz) in the server and client configuration
   because at least one block is used per application.

   NOTE: This is applicable only for releases of DB2 prior toVersion 2 .

*  Decrease the values of the configuration parameters that define
   allocation of memory, including ASLHEAPSZ if UDFs are involved in the
   failing statement.
*  Avoid accessing large files or use non-buffered I/O. To use
   non-buffered I/O, set the DB2 registry variable DB2NTNOCACHE to YES.

sqlcode: -10003

sqlstate: 57011

使用道具 举报

回复
论坛徽章:
5
奥运会纪念徽章:蹦床
日期:2012-08-24 16:50:342013年新春福章
日期:2013-02-25 14:51:24鲜花蛋
日期:2013-06-08 15:24:31ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:422014年世界杯参赛球队: 意大利
日期:2014-06-25 12:38:19
13#
 楼主| 发表于 2013-8-21 10:30 | 只看该作者

使用道具 举报

回复
论坛徽章:
5
奥运会纪念徽章:蹦床
日期:2012-08-24 16:50:342013年新春福章
日期:2013-02-25 14:51:24鲜花蛋
日期:2013-06-08 15:24:31ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:422014年世界杯参赛球队: 意大利
日期:2014-06-25 12:38:19
14#
 楼主| 发表于 2013-8-21 15:39 | 只看该作者
本帖最后由 sunny_zhao0127 于 2013-8-23 09:30 编辑

重新创建用户及目录文件 与生产环境路径保持一致:

groupadd -g 997 dasadm1
useradd  -u 1002 -m -g db2iadm1 -d /home/dwpinst1  -s /bin/bash  dwpinst1

useradd  -u 1003 -m -g db2fadm1 -d /home/dwpfenc1  -s /bin/bash dwpfenc1

useradd  -u 1001   -g dasadm1  -d /home/dasusr1 -s /bin/bash  dasusr1

useradd -u 1004 -g  db2iadm1   -d /home/db2inst1 -s /bin/bash db2inst1

重装db2 数据库

db2ls

Install Path                       Level   Fix Pack   Special Install Number   Install Date                  Installer UID
---------------------------------------------------------------------------------------------------------------------
/opt/IBM/ISWarehouse/db2/V9.7     9.7.0.3        3                       1    Wed Dec 15 08:43:03 2010 CST             0

使用道具 举报

回复
论坛徽章:
5
奥运会纪念徽章:蹦床
日期:2012-08-24 16:50:342013年新春福章
日期:2013-02-25 14:51:24鲜花蛋
日期:2013-06-08 15:24:31ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:422014年世界杯参赛球队: 意大利
日期:2014-06-25 12:38:19
15#
 楼主| 发表于 2013-8-22 11:45 | 只看该作者
LIST HISTORY Command
Lists entries in the history file. The history file contains a record of recovery and administrative events. Recovery events include full database and table space level backup, incremental backup, restore, and rollforward operations. Additional logged events include create, alter, drop, or rename table space, reorganize table, drop table, and load.

Authorization
None

Required connection
Instance. You must attach to any remote database in order to run this command against it. For a local database, an explicit attachment is not required.

Command syntax
>>-LIST HISTORY--+-------------------+-------------------------->
                 +-BACKUP------------+
                 +-ROLLFORWARD-------+
                 +-DROPPED TABLE-----+
                 +-LOAD--------------+
                 +-CREATE TABLESPACE-+
                 +-ALTER TABLESPACE--+
                 +-RENAME TABLESPACE-+
                 +-REORG-------------+
                 '-ARCHIVE LOG-------'

>--+-ALL--------------------------------+----------------------->
   +-SINCE--timestamp-------------------+
   '-CONTAINING--+-schema.object_name-+-'
                 '-object_name--------'

>--FOR--+----------+--database-alias---------------------------><
        +-DATABASE-+
        '-DB-------'

Command parameters
HISTORY
Lists all events that are currently logged in the history file.
BACKUP
Lists backup and restore operations.
ROLLFORWARD
Lists rollforward operations.
1 1
DROPPED TABLE
1
Lists dropped table records. A dropped table record is created only when the 1 table is dropped and the table space containing it has the DROPPED TABLE RECOVERY 1 option enabled. 1
LOAD
Lists load operations.
CREATE TABLESPACE
Lists table space create and drop operations.
RENAME TABLESPACE
Lists table space renaming operations.
REORG
Lists reorganization operations.
ALTER TABLESPACE
Lists alter table space operations.
ARCHIVE LOG
Lists archive log operations and the archived logs.
ALL
Lists all entries of the specified type in the history file.
SINCE timestamp
A complete time stamp (format yyyymmddhhmmss), or an initial prefix (minimum yyyy) can be specified. All entries with time stamps equal to or greater than the time stamp provided are listed.
CONTAINING schema.object_name
This qualified name uniquely identifies a table.
CONTAINING object_name
This unqualified name uniquely identifies a table space.
FOR DATABASE database-alias
Used to identify the database whose recovery history file is to be listed.
Examples
   db2 list history since 19980201 for sample
   db2 list history backup containing userspace1 for sample
   db2 list history dropped table all for db sample
Usage notes
The report generated by this command contains the following symbols:

Operation

   A - Create table space
   B - Backup
   C - Load copy
   D - Dropped table
   F - Roll forward
   G - Reorganize table
   L - Load
   N - Rename table space
   O - Drop table space
   Q - Quiesce
   R - Restore
   T - Alter table space
   U - Unload
   X - Archive log

Type

Archive Log types:
   P - Primary log path
   M - Secondary (mirror) log path
   F - Failover archive path
   1 - Primary log archive method
   2 - Secondary log archive method

Backup types:

   F - Offline
   N - Online
   I - Incremental offline
   O - Incremental online
   D - Delta offline
   E - Delta online

Rollforward types:

   E - End of logs
   P - Point in time

Load types:

   I - Insert
   R - Replace

Alter table space types:

   C - Add containers
   R - Rebalance

Quiesce types:

   S - Quiesce share
   U - Quiesce update
   X - Quiesce exclusive
   Z - Quiesce reset

使用道具 举报

回复
论坛徽章:
512
2012新春纪念徽章
日期:2012-01-04 11:53:54ITPUB十周年纪念徽章
日期:2011-11-01 16:23:26股神
日期:2012-01-05 10:29:02天枰座
日期:2015-09-16 09:05:30指数菠菜纪念章
日期:2015-07-01 16:40:43喜羊羊
日期:2015-06-30 09:06:18指数菠菜纪念章
日期:2015-04-02 09:22:462015年新春福章
日期:2015-03-06 11:58:18懒羊羊
日期:2015-03-04 14:52:11指数菠菜纪念章
日期:2015-01-04 11:09:18
16#
发表于 2013-8-22 12:20 | 只看该作者
这个问题可能和操作系统有关,如果是AIX的,要检查用户几个默认的设置,好像是最大线程数、最大文件句柄、最大的内存空间,具体我不是很记得,一般新安装的AIX都需要改一下默认值,否则DB2的实例运行会遇到很多奇怪的问题。最好能联系原厂或者代理商的DB2支持人员看下。

使用道具 举报

回复
论坛徽章:
5
奥运会纪念徽章:蹦床
日期:2012-08-24 16:50:342013年新春福章
日期:2013-02-25 14:51:24鲜花蛋
日期:2013-06-08 15:24:31ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:422014年世界杯参赛球队: 意大利
日期:2014-06-25 12:38:19
17#
 楼主| 发表于 2013-9-11 09:49 | 只看该作者
1) DB2 v8

当需要对数据行进行顺序读取(order)时,比如order by\group by\distinct等,如果没有索引满足要求,或者优化器认为索引的代价更高时,就需要扫描数据表并进行排序。DB2里,存在两种类型的排序:私有排序(private sort)和共享排序(shared sort)。我们知道,DB2的内存模型包括:实例级共享内存、数据库级共享内存、应用共享内存和代理内存。其中,私有排序就发生在代理内存(agent private memory);而共享排序发生在数据库共享内存。

对于私有排序,实例配置参数sheapthres指定了某个给定时间可为所有私有排序分配的软内存限制(soft limit)。当为私有排序分配的内存达到了此限制,新请求的私有排序的内存大小分配将会减少。同时,在db2diag.log日志里会给出提示:

"Not enough memory available for a (private) sort heap of size size of sortheap. Trying smaller size..."

当出现此类错误的时候,需要检查是否分配了太大的sortheap,sortheap指定了为每个私有排序分配的最大内存,这是个数据库配置参数,缺省值是256个4k页,即1M大小。对于大部分OLTP应用来说,缺省值就可满足要求。如果设的太大,会很容易超出sheapthres限制。对于OLAP应用,往往需要处理大量数据,对排序的要求也会增加,可适当增加sortheap和sheapthres的值。


当设置了intra-partition分区内并行或者connection contentrator(连接集中器,当MAX_CONNECTIONS>MAX_COORDAGENTS时)时,DB2可能选择会共享排序。如果执行共享排序,那么排序发生在数据库共享内存,可供分配的共享排序大小由sheapthres_shr数据库参数来控制,这个值是硬限制(hard limit)。当达到此限制后,请求排序的新的应用会收到SQL0955(reason code 2)错误,只有当消耗的共享排序值低于此限制后才允许新应用请求共享排序。对于共享排序,当数据库激活或第一次连接时就会分配sheapthres_shr参数指定的数据库共享内存。

当发现排序次数太多或者有排序溢出的时候,需要检查是否在表上建立了合适的索引。通常大的表扫描会导致的大量的排序,严重影响性能。

intra-partition parallelism:指的是在一个单分区数据库中把一个操作分成多个部分,然后同时执行。比较典型的有index creation,complex sql query,load等,通过enable intra-partition,可以充分利用SMP的多处理器的处理能力。

2)DB2 v9.1的变化

在DB2 v9.1中,sheapthres_shr参数是一个软限制。需要时,排序内存堆可使用其他未使用的数据库共享内存。当实例级参数sheapthres设置为0时,仅适用数据库共享内存进行共享排序,排序内存分配受sheapthres_shr配置参数值的约束。

而且,仅当数据库管理器配置参数 sheapthres 设置为 0 时,才允许自动调整 sheapthres_shr和sortheap。在DB2 V8 中,无论如何设置 sheapthres 参数值,只有 SMP 环境中(intra_partition=yes)的排序或运行可由多个代理程序访问的集中器的排序才会消耗共享内存。在 DB2 V9.1 中,如果将sheapthres数据库管理器配置参数设置为 0,则所有排序都将使用共享内存。如果将 sheapthres 数据库管理器配置参数设置为大于 0 的值,则只有 SMP 环境中的排序或运行可由多个代理程序访问的集中器的排序将会消耗共享内存,其余进行私有排序。

3)使用建议

- 通过get snapshot for sorts on <db> 进行监控锁的使用 (需先打开开关 update monitor switches using sort on)

- sheapthres的值依赖于sortheap的大小和应用的并发执行数,应用的并发执行数可以通过get snapshot for database来监控。考虑到单个应用需要多次排序,sheapthres可设为:sortheap*并发数*2

- 减少排序次数,建立合适的索引

- 需要对大表进行排序时,适当增大sortheap和sheapthres参数值

- 对于v9.1,建议用缺省值。(dbm cfg: sheapthres=0 ; db cfg: sheapthres_shr=automatic, sortheap=automatic

使用道具 举报

回复
论坛徽章:
5
奥运会纪念徽章:蹦床
日期:2012-08-24 16:50:342013年新春福章
日期:2013-02-25 14:51:24鲜花蛋
日期:2013-06-08 15:24:31ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:422014年世界杯参赛球队: 意大利
日期:2014-06-25 12:38:19
18#
 楼主| 发表于 2013-9-11 09:49 | 只看该作者
1) DB2 v8

当需要对数据行进行顺序读取(order)时,比如order by\group by\distinct等,如果没有索引满足要求,或者优化器认为索引的代价更高时,就需要扫描数据表并进行排序。DB2里,存在两种类型的排序:私有排序(private sort)和共享排序(shared sort)。我们知道,DB2的内存模型包括:实例级共享内存、数据库级共享内存、应用共享内存和代理内存。其中,私有排序就发生在代理内存(agent private memory);而共享排序发生在数据库共享内存。

对于私有排序,实例配置参数sheapthres指定了某个给定时间可为所有私有排序分配的软内存限制(soft limit)。当为私有排序分配的内存达到了此限制,新请求的私有排序的内存大小分配将会减少。同时,在db2diag.log日志里会给出提示:

"Not enough memory available for a (private) sort heap of size size of sortheap. Trying smaller size..."

当出现此类错误的时候,需要检查是否分配了太大的sortheap,sortheap指定了为每个私有排序分配的最大内存,这是个数据库配置参数,缺省值是256个4k页,即1M大小。对于大部分OLTP应用来说,缺省值就可满足要求。如果设的太大,会很容易超出sheapthres限制。对于OLAP应用,往往需要处理大量数据,对排序的要求也会增加,可适当增加sortheap和sheapthres的值。


当设置了intra-partition分区内并行或者connection contentrator(连接集中器,当MAX_CONNECTIONS>MAX_COORDAGENTS时)时,DB2可能选择会共享排序。如果执行共享排序,那么排序发生在数据库共享内存,可供分配的共享排序大小由sheapthres_shr数据库参数来控制,这个值是硬限制(hard limit)。当达到此限制后,请求排序的新的应用会收到SQL0955(reason code 2)错误,只有当消耗的共享排序值低于此限制后才允许新应用请求共享排序。对于共享排序,当数据库激活或第一次连接时就会分配sheapthres_shr参数指定的数据库共享内存。

当发现排序次数太多或者有排序溢出的时候,需要检查是否在表上建立了合适的索引。通常大的表扫描会导致的大量的排序,严重影响性能。

intra-partition parallelism:指的是在一个单分区数据库中把一个操作分成多个部分,然后同时执行。比较典型的有index creation,complex sql query,load等,通过enable intra-partition,可以充分利用SMP的多处理器的处理能力。

2)DB2 v9.1的变化

在DB2 v9.1中,sheapthres_shr参数是一个软限制。需要时,排序内存堆可使用其他未使用的数据库共享内存。当实例级参数sheapthres设置为0时,仅适用数据库共享内存进行共享排序,排序内存分配受sheapthres_shr配置参数值的约束。

而且,仅当数据库管理器配置参数 sheapthres 设置为 0 时,才允许自动调整 sheapthres_shr和sortheap。在DB2 V8 中,无论如何设置 sheapthres 参数值,只有 SMP 环境中(intra_partition=yes)的排序或运行可由多个代理程序访问的集中器的排序才会消耗共享内存。在 DB2 V9.1 中,如果将sheapthres数据库管理器配置参数设置为 0,则所有排序都将使用共享内存。如果将 sheapthres 数据库管理器配置参数设置为大于 0 的值,则只有 SMP 环境中的排序或运行可由多个代理程序访问的集中器的排序将会消耗共享内存,其余进行私有排序。

3)使用建议

- 通过get snapshot for sorts on <db> 进行监控锁的使用 (需先打开开关 update monitor switches using sort on)

- sheapthres的值依赖于sortheap的大小和应用的并发执行数,应用的并发执行数可以通过get snapshot for database来监控。考虑到单个应用需要多次排序,sheapthres可设为:sortheap*并发数*2

- 减少排序次数,建立合适的索引

- 需要对大表进行排序时,适当增大sortheap和sheapthres参数值

- 对于v9.1,建议用缺省值。(dbm cfg: sheapthres=0 ; db cfg: sheapthres_shr=automatic, sortheap=automatic

使用道具 举报

回复
论坛徽章:
1
技术图书徽章
日期:2014-01-24 10:18:55
19#
发表于 2013-10-1 23:55 | 只看该作者
有意思,我觉得需要多少内存是根据需要的,当然越大越好。
具体的估算,让自己内心有个靠谱的值可以看看下面这些命令:

db2 "select db_heap_top from table(snapshot_database('SAMPLE', -1)) as database"
db2mtrk -i -p -m

下面这篇很好的文章也许更有用,也许能帮上吧。

http://www.ibm.com/developerworks/data/library/techarticle/dm-0406qi/

呵呵呵~~~

使用道具 举报

回复
论坛徽章:
6
ITPUB9周年纪念徽章
日期:2010-10-08 09:31:222011新春纪念徽章
日期:2011-02-18 11:43:36鲜花蛋
日期:2012-04-09 19:32:54itpub13周年纪念徽章
日期:2014-10-08 15:16:50itpub13周年纪念徽章
日期:2014-10-08 15:16:50itpub13周年纪念徽章
日期:2014-10-08 15:16:50
20#
发表于 2013-10-4 15:39 | 只看该作者
看下instance_memory和database_memory的值,还有系统内存资源的使用情况
把os version和db2 verions贴上来看看

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表