码迷,mamicode.com
首页 > 其他好文 > 详细

HADR

时间:2016-01-18 21:01:25      阅读:794      评论:0      收藏:0      [点我收藏+]

标签:hadr

关闭 HADR 对的建议顺序

警告: 

    尽管可对主数据库和/或备用数据库使用 STOP HADR 命令来停止 HADR,但应谨慎使用。

    如果要停止指定的数据库,但仍然想保留其 HADR 主数据库角色或备用数据库角色,请不要发出 STOP HADR 命令。 

    如果发出 STOP HADR 命令,那么该数据库将变为标准数据库,并且可能需要重新初始化才能继续作为 HADR 数据库运行。请改为发出 DEACTIVATE DATABASE 命令。


如果只想关闭 HADR 操作,那么下面是关闭 HADR 对的建议方法:

  1. 取消激活主数据库

  2. 对主数据库停止 DB2

  3. 取消激活备用数据库

  4. 对备用数据库停止 DB2


启动HADR,则刚好相反:

1、启动备库,备库启动后进入local catchup,remote catchup pending,会一直尝试连接主库。

2、启动主库,等待接收备库的连接,如果在规定的时间(hadr_timeout)不能收到备库的连接,则启动失败,这样是为了防止脑裂 brain split.一旦备库连接上主库,进入remote catchup状态。重放完主库传过来的日志后,进入peer状态。


HADR的索引:

建议:对于 HADR 数据库,将 logindexbuild 数据库配置参数设置为 ON,以确保为索引的创建、重新创建和重组记录完整的信息。虽然,这意味着在主系统上的索引构建可能需要更长时间和更多日志空间,但是在 HADR 日志重放期间,将在备用系统上重建索引,而且当发生故障转移时索引仍可用。否则,由于日志记录没有包含足够信息来填充新索引,因此,重放索引构建或重建事件时,备用系统会将索引标记为无效。如果不记录主系统上的索引构建,而且发生故障转移,那么在故障转移完成之后所剩的任何无效索引都必须重建,然后才能对其进行访问。当重新创建索引时,任何应用程序都无法对表进行访问。访问具有无效索引的表的用户必须等待重建索引

indexrec:

  • RESTART

  • indexrec 的缺省值。将在显式或隐式发出 RESTART DATABASE 命令时重建无效的索引。在前滚或 HADR 日志重放期间将重做任何完全记录的索引构建。当启动了 HADR 且发生 HADR 接管时,会在接管结束时重建任何无效的索引。


创建index的并发(create index不同于重建index):

Concurrent read/write access to the table is permitted while an index is being created, except when the EXTEND USING clause is specified. However, the default index creation behavior differs for indexes on nonpartitioned tables, nonpartitioned indexes, and partitioned indexes:

  • For indexes on nonpartitioned tables, once the index has been built, changes that were made to the table during index creation time are forward-fitted to the new index. Write access to the table is then briefly blocked while index creation completes, after which the new index becomes available.

  • For nonpartitioned indexes, once the index has been built, changes that were made to the table during index creation time are forward-fitted to the new index. Write access to the table is then briefly blocked while index creation completes, after which the new index becomes available.

  • For partitioned indexes, once the index partition has been built, changes that were made to the partition during creation time of that index partition are forward-fitted to the new index partition. Write access to the data partition is then blocked while index creation completes on the remaining data partitions. After the index partition for the last data partition is built and the transaction is committed, all data partitions are available for read and write.

即只有在最后将在index创建期间发生的更改应用到index时,会对表写锁定,then解除锁定。


drop index:

涉及该index的静态包,包高速缓存中的动态SQL,都会标记为无效。应用程序不受影响。


(HADR) 环境进行升级

  • 将主数据库升级到 DB2 V10.5 时,会将数据库角色从主数据库更改为标准数据库。不支持将备用数据库升级到 DB2V10.5,这是因为这些数据库处于前滚暂挂状态。由于存在这些限制,因此将 HADR 环境升级到 DB2 V10.5 时,要求您停止 HADR,对主数据库所在的 DB2 服务器进行升级,然后重新初始化 HADR。大版本不能实现滚动升级。

  • 升级到v10.5,因为sql语句的语法可能发生变化,clp的命令可能发生变化,编目表结构变化,api可能变化,应用程序用到的数据库驱动版本也不一致,所以要升级应用程序的数据库驱动,并且要测试才能上到prd。大版本升级,不仅instance升级(db2iupdt),database也要升级(db2updv10)


小版本升级(应用修订包),database升级是可选的,HADR可以实现滚动升级(先升级备库,takeover,在升级原主库)。

HADR

标签:hadr

原文地址:http://dannyswallow.blog.51cto.com/5062777/1736214

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