DB2学习路线和DB2升级到V10版本.doc_第1页
DB2学习路线和DB2升级到V10版本.doc_第2页
DB2学习路线和DB2升级到V10版本.doc_第3页
DB2学习路线和DB2升级到V10版本.doc_第4页
DB2学习路线和DB2升级到V10版本.doc_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

DB2学习路线和DB2升级到V10版本作用: 本文章只供学习DB2参考和学习;内部培训使用。版本: 1.0版本时间: 2012.5月作者: *实验环境:开发库1.DB2 学习路线2.升级DB2到V10版本2.1 DB2 V10.1 升级概述IBM DB2 V10.1 for Linux, Unix, and Windows,简称 DB2 V10.1,是 IBM 在 Linux,Unix 和 Windows 平台上的企业级数据库产品 DB2 for LUW 的最新版本,它已于 2012 年 4 月正式发布。DB2 V10.1 提供了很多新的功能特性以及对一些老的 DB2 特性做了加强,关于 DB2 V10.1 的新特性,可以从三方面来介绍一些新功能: 低成本:在存储成本上,V10.1 引入了自适应压缩功能,对 9.7 中表压缩再次增强,在原有表压缩的基础上将数据再压缩 40% - 50%。在管理成本上,V10.1 增强了索引管理功能,并引入多温区存储特性,针对不同的数据使用热度将数据放置在不同级别的存储中,便于优化管理。在运营成本上,V10.1 加入了很多性能增强功能,如实时数据仓库和快速查询响应等。 高可靠性:在工作负载管理增强功能方面,引入数据标签,增强调度。在安全性增强功能方面加入了行列数据访问权限控制,并支持多备用节点的 HADR 部署。V10.1 支持 pureScale 特性,它包括集群集成管理器和集群缓存设备,提供了强大的处理能力和透明的应用扩展,且其服务是连续可用的。 高可用性:V10.1 的 SQL 性能得到全面提升,具有更好的 SQL 兼容能力。V10.1 集成了 IBM Data Studio 客户端工具和 Optim 工具,以取代 DB2 控制中心和其它停用工具的核心客户端工具。V10.1 支持基于时间变化的数据管理,支持 INGEST 数据连续导入工具,增加了 RDF 图表存储特性。很多用户由于业务系统的需要,希望将 DB2 从老版本升级到 V10.1。如果要让 DB2 环境组件在 DB2 V10.1 上顺利运行,那么你可能需要对这些环境组件进行升级。DB2 环境包含几个组件,例如,DB2 服务器、DB2 客户机、数据库应用程序和例程。对这些组件进行升级时,你需要了解 DB2 数据库产品及其升级概念。本文主要以 DB2 V9.7 到 DB2 V10.1 的升级为例来讲解具体的升级过程。 2.2升级前准备升级之前,客户需要考虑升级条件是否具备,然后制定升级计划。检查升级条件主要从两方面来检查是否支持 DB2 升级到 V10.1 版本。在 DB2 版本方面,只支持直接从 DB 9.5 之后(含)的版本升级,如果是更低的版本如 DB2 9.1,需要先升级到 9.5 或 9.7,然后再升级到 V10.1。在操作系统方面,DB2 V10.1 在软件、通信、磁盘和内存方面对不同操作系统有不同的最低要求,因此应当确保所选操作系统满足这些要求。本文不详细介绍不同操作系统安装 V10.1 的所有要求。DB2 安装软件中提供了一个很好的工具 db2prereqcheck 来检查系统是否满足安装先决条件,而不必直接开始安装特定的 DB2 版本。此命令检查先决条件,例如,操作系统级别、客户机或特定于 DB2 pureScale 特性的要求等等。清单 1. Windowns 系统上 db2prereqcheck 命令输出 D: database db2prereqcheck.exe = Checking DB2 prerequisites for DB2 database version 10.1.0.0 on operating system WindowsRequired minimum version : Windows 2008 Server SP 2 Actual version detected: Windows 2008 Server SP 1 OS is Windows Server ERROR: Requirement not matched. Requirement not matched for DB2 database server . Version: 10.1.0.0. Requirement not matched for DB2 database server . Version: 10.1.0.0. Requirement not matched for DB2 database server . Version: 10.1.0.0. Summary of prerequisites that are not met on the current system: Required minimum version : Windows 2008 Server SP 2 Actual version detected: Windows 2008 Server SP 1 DB2 version 9.8.0.4 is not supported on the current platform. DB2 version 9.8.0.3 is not supported on the current platform. DB2 version 9.8.0.2 is not supported on the current platform. 如果 db2prereqcheck 执行成功,说明此系统满足所有的安装条件。如果发现条件不符合,那么将会返回如清单 1 所示的错误信息,列出所有安装的先决条件。客户就需要根据错误信息,逐一满足,直至运行此工具不再出现错误信息为止。实际上,如果运行不带任何参数的 db2prereqcheck 命令,那么该命令将检查系统是否满足所有 DB2 发行版和修订包的先决条件。要检查系统是否满足特定 DB2 版本的先决条件,要运行带有 -v 参数的 db2prereqcheck 命令。对于 DB2 pureScale 特性安装,需使用 -p 选项。对于客户机安装,需使用 -c 选项。清单 2. Aix 系统上 db2prereqcheck 命令输出 # ./db2prereqcheck -p -v 10.1.0.0 = Checking DB2 prerequisites for DB2 database version 10.1.0.0 on operating system AIXValidating kernel level . Required minimum operating system kernel level : 6.1. Actual operating system kernel level: 6.1. Requirement matched. Validating AIX technology level and service pack . Required minimum technology level: 6 Service pack: 5 Actual technology level: 6 Service pack: 5 Requirement matched. Validating XL C/C+ Runtime . Required minimum XL C/C+ Runtime level: 11.1.0.1 Actual version: 11.1.0.1 Requirement matched. Validating uDAPL . Required minimum uDAPL level: 6.1.6.15 Actual version: 6.1.6.0 ERROR: Requirement not matched. Requirement not matched for DB2 database server with DB2 pureCluster feature. Version: 10.1.0.0. Summary of prerequisites that are not met on the current system: Required minimum uDAPL level: 6.1.6.15 Actual version: 6.1.6.0 需要注意的是:db2prereqcheck 可以检查 DB2 安装的大部分升级条件,但是并不会检测 DB2 服务器升级的磁盘空间要求。在 Linux 和 UNIX 操作系统上,建议在 /tmp 目录中有 2 GB 的可用空间。此外,你需要了解系统环境中具有几个组件,如 DB2 服务器、DB2 客户机、数据库应用程序、脚本、例程和工具,在规划升级时需要彻底了解每个组件的迁移过程。 2.3制定升级计划一般升级 DB2 需要花费很长的时间,而且具有一定的风险,一份周详的升级计划会有助于降低升级的风险。首先,制定一项关于如何处理环境升级的策略。你必须确定每个组件的升级顺序。环境的特征和升级基本要求中的信息可以帮助你确定策略。下面是一个很好的升级策略示例,在此示例中,你将测试数据库应用程序和例程并确定它们在 DB2 V10.1 中是否成功运行:1. 查看 DB2 V10.1 以及您要升级的发行版与 DB2 V10.1 之间的任何发行版的新功能、不推荐使用的功能和已停止使用的功能。2. 计划如何修改数据库应用程序和例程。确保它们在 DB2 V10.1 中成功运行。3. 设置 DB2 V10.1 服务器并创建测试数据库。4. 在 DB2 V10.1 测试数据库上测试数据库应用程序和例程,以确定它们是否成功运行。如果应用程序需要客户机,请使用 DB2 V10.1 客户机。5. 在测试环境中对 DB2 服务器和客户机进行升级。确定存在的问题及其解决方案。使用此信息来调整升级计划。6. 在生产环境中将 DB2 服务器升级到 DB2 V10.1。确保它们按预期操作。7. 在生产环境中将客户机升级到 DB2 V10.1。确保客户机按预期操作。8. 在升级后的 DB2 V10.1 环境中测试数据库应用程序和例程,以确定它们是否按预期运行。9. 使已升级的环境可供用户使用。之后,你就可以为环境中的每个组件定义升级计划详细信息。升级计划应该包括每个组件的下列信息:升级先决条件,升级前任务,升级任务和升级后任务。如果你先前已制定了升级计划,查看它们并将它们与 DB2 V10.1 的升级计划进行比较。最后,在升级计划中取消使用不推荐使用的功能并合并 DB2 V10.1 中的新功能。尽管你只需要取消使用已停止使用的功能,但还是应该计划在升级之后取消使用不推荐使用的功能,因为在未来的发行版中将不支持这些功能。此外,还应该利用新功能为你的数据库产品、应用程序和例程增强功能和提高性能。升级是一个高风险的过程,一定要做好充分的准备和测试。 2.4升级安装 DB2 V10.1自从 DB2 V9 开始,DB2 支持在操作系统上安装多个副本。升级数据库有两种安装 DB2 的选择,一种是安装新的数据库副本到新的位置,另外一种是直接升级老版本数据库副本到新的版本。这个具体要看用户的环境规划。我们推荐安装新的副本到新的位置,这样可以不影响老的副本,如果升级过程中出现问题,客户可以恢复到老的版本直接运行。 我们以 DB2 V9.7 到 DB2 V10.1 的升级为例来讲解具体的升级过程。系统中已安装了 DB2 V9.7 的一个副本。我们下载 DB2 V10.1 版本,对于 Windows 操作系统,执行其中的 setup.exe, 图 1. DB2 V10.1 的安装文件此时弹出如下界面: 图 2. DB2 V10.1 安装界面在弹出界面中点击 Install New,表示安装一个新的 DB2 V10.1 副本 图 3. 选择一:安装一个新的副本若点击 Work with Existing,则表示直接升级老版本数据库副本到新的版本: 图 4. 选择二:直接升级老版本数据库副本到新版本对于 Linux 和 Unix 操作系统来说,V10.1 在软件安装文件目录下有 db2_install 和 db2_setup 两种安装命令,如 清单 3所示: 清单 3. V10.1 提供两种安装软件命令 bash-3.00# ls db2 db2_install db2ls db2setup db2_deinstall db2ckupgrade db2prereqcheck installFixPack 首先我们使用 db2_install 来安装 DB2 副本,如 清单 4所示: 清单 4. 选择一:使用 db2_install 安装新副本 # ./db2_install DBI1324W Support of the db2_install command is deprecated. For more information, see the DB2 Information Center. Default directory for installation of products - /opt/IBM/db2/V10.1 * Install into default directory (/opt/IBM/db2/V10.1) ? yes/no 在清单 4 中,我们看到输入 db2_install 后有提示:“Support of the db2_install command is deprecated”,这意味着 V10.1 以后版本将不再提供该命令,因此我们采用与 Windows 平台下相同的 db2setup 命令安装软件,如 清单 5中所示: 清单 5. 选择二:使用 db2setup 安装新副本(Linux/Unix) # ./db2setup DBI1190I db2setup is preparing the DB2 Setup wizard which will guide you through the program setup process. Please wait. 之后我们将看到亲切的图形界面,如 图 2、图 3所示,接下来按照向导将帮助您完成操作,如 图 5所示: 图 5. 使用 db2setup 安装新副本界面(Linux/Unix)接受安装协议,如 图 6所示: 图 6. 安装协议界面下一步,在第五步接受默认路径或者输入自定义安装路径,在第六步配置 DAS 用户,如 图 7所示: 图 7. DAS 配置界面此步 可能导致的问题:如果之前的 DB2 已经配置 DAS,需要在安装 V10.1 之前以含有 root 权限用户使用 dasdrop 命令出去 DAS,否则可能会导致安装失败,如 清单 6所示: 清单 6. 除去已有 DAS bash-3.00# cd /db2/db2lr1/db2_software/instance bash-3.00# ./dasdrop d 接下来,进行实例设置,在这里我们 不创建实例,如 图 8所示: 图 8. 不创建实例最后查看 Summary,确认无误后执行安装,如 图 9所示: 图 9. Summary直至安装成功,如 图 10所示: 图 10. 安装成功2.5升级实例实例升级时,调用 db2iupgrade 命令。使用 db2iupgrade 命令时,将显式调用实例升级;在 Windows 上安装 DB2 V10.1 并选择使用现有产品选项,然后选择版本低于 V10.1 的副本以及升级操作时,将隐式调用实例升级,在这两种情况下,该命令将执行下列操作 : 调用 db2ckupgrade 命令。这个工具作检查,不会对现有的实例和数据库有任何影响,我们建议在调用 db2iupgrade 之前执行该命令检查实例是否具备升级条件。语法如 清单 7所示: 清单 7. db2ckupgrade 语法 -db2ckupgrade-+-database-+- -l-filename-+-+- - -e- - -not1- -+-+-db2iupgrade-+-+-+-+- - -d- - -k- -+-+- - -j-TEXT_SEARCH-+-+-+-+- -,servicename- -,portnumber- -+-+-+-+-InstName-db2iupgrade-InstName-/u:-username,password- -+-+-+-+-+-+- -/p:-instance-profile-path- -/q- -/a:-authType- -+-+- -/j-TEXT_SEARCH-+-+-+-+- -,servicename- -,portnumber- -+-+- -/?-2.5.1下面我们将分别介绍 Non-DPF 和 DFP 数据库实例的升级:Non-DPF 数据库实例升级在 Linux/Unix 系统下用带有 root 权限的用户调用 db2iupgrade 升级实例,如 清单 9所示:清单 9. Non-DPF 数据库调用 db2iupgrade 升级实例(Linux/Unix) bash-3.00# ./db2iupgrade -a SERVER_ENCRYPT db2lr1 DBI1446I The db2iupgrade command is running, please wait. DB2 installation is being initialized. Total number of tasks to be performed: 4 Total estimated time for all tasks to be performed: 309 second(s) Task #1 start Description: Setting default global profile registry variables Estimated time 1 second(s) Task #1 end Task #2 start Description: Initializing instance list Estimated time 5 second(s) Task #2 end Task #3 start Description: Configuring DB2 instances Estimated time 300 second(s) Task #3 end Task #4 start Description: Updating global profile registry Estimated time 3 second(s) Task #4 end The execution completed successfully. For more information see the DB2 installation log at /tmp/db2iupgrade.log.8651. DBI1070I Program db2iupgrade completed successfully. 实例升级完毕后,以实例拥有者用户运行 db2level 进行验证:清单 10. 运行 db2level 验证升级结果 bash-3.00$ db2level DB21085I Instance db2lr1 uses 64 bits and DB2 code release SQL10010 with level identifier 0201010E. Informational tokens are DB2 v10.1.0.0, s120403, SUN64101, and Fix Pack 0. Product is installed at /db2/V10.1. 从 清单 10中可以看到当前实例已经升级到 v10.1.0.0。DPF 数据库实例升级DPF 数据库实例升级与 Non-DPF 数据库实例升级略有不同,在运行 db2ckupgrade 前应当对数据库所有分区执行完全脱机备份,而且要使用带有 ON ALL DBPARTITIONNUMS 参数进行备份,否则执行 db2ckupgrade 时会提示数据库备份处于 pending 状态。1. 使用数据库用户对所有数据库分区执行完全脱机备份。 使用带有 ON ALL DBPARTITIONNUMS 参数的 BACKUP DATABASE 命令来备份所有分区。 清单 11. Linux/Unix 下使用带有 ON ALL DBPARTITIONNUMS 参数备份数据库 bash-3.00$ db2 backup database LR1 ON ALL DBPARTITIONNUMS to compress Part Result - - 0000 DB20000I The BACKUP DATABASE command completed successfully. 0001 DB20000I The BACKUP DATABASE command completed successfully. Backup successful. The timestamp for this backup image is : 20120511003515 2. 在 Linux 和 UNIX 操作系统上,作为带有 root 权限用户登录;而在 Windows 操作系统上,作为具有本地管理员权限的用户登录。运行 db2ckupgrade 检查是否满足升级实例的先决条件,如 清单 12所示: 清单 12. Linux/Unix 下运行 db2ckupgrade bash-3.00$ db2ckupgrade LR1 -l db2ckupgrade.log DBT5508I The db2ckupgrade utility completed successfully. The database or databases can be upgraded. bash-3.00$ cat db2ckupgrade.log Version of DB2CKUPGRADE being run: VERSION 10.1 Database: LR1 DBT5508I The db2ckupgrade utility completed successfully. The database or databases can be upgraded. 清单所用命令中 db2ckupgrade 后的 LR1 为实验中的数据库名称。 3. 运行 db2iupgrade 升级实例: 清单 13. 升级 DPF 数据库实例 bash-3.00# ./db2iupgrade -a SERVER_ENCRYPT db2lr1 DBI1446I The db2iupgrade command is running, please wait. DB2 installation is being initialized. Total number of tasks to be performed: 4 Total estimated time for all tasks to be performed: 309 second(s) Task #1 start Description: Setting default global profile registry variables Estimated time 1 second(s) Task #1 end Task #2 start Description: Initializing instance list Estimated time 5 second(s) Task #2 end Task #3 start Description: Configuring DB2 instances Estimated time 300 second(s) Task #3 end Task #4 start Description: Updating global profile registry Estimated time 3 second(s) Task #4 end The execution completed successfully. For more information see the DB2 installation log at /tmp/db2iupgrade.log.23597. DBI1070I Program db2iupgrade completed successfully. 4. 验证升级结果: 清单 14. 运行 db2level 验证升级结果 bash-3.00$ db2level DB21085I Instance db2lr1 uses 64 bits and DB2 code release SQL10010 with level identifier 0201010E. Informational tokens are DB2 v10.1.0.0, s120403, SUNAMD64101, and Fix Pack 0. Product is installed at /db2/V10.1_01. 2.6升级数据库使用 UPGRADE DATABASE 命令显式地调用数据库升级时,在数据库升级期间可能会转换下列数据库实体: 数据库配置文件 日志文件标题 所有表的表根页 所有表的索引根页 目录表 缓冲池文件 历史记录文件 对于可恢复的数据库,UPGRADE DATABASE 命令将使用扩展名 .MIG 对活动日志路径中的所有日志文件进行重命名。在成功地升级数据库之后,可以删除所有 S*.MIG 文件。下面我们仍然分别对 Non-DPF 数据库和 DPF 数据库进行数据库升级:Non-DPF 数据库升级数据库首先,使用数据库用户运行 db2 upgrade database :清单 15. 升级 Non-DPF 数据库 bash-3.00$ id uid=23947(db2lr1) gid=22223(dblr1adm) bash-3.00$ db2start 05/11/2012 05:28:54 0 0 SQL1063N DB2START processing was successful. SQL1063N DB2START processing was successful. bash-3.00$ db2 UPGRADE DATABASE LR1 DB20000I The UPGRADE DATABASE command completed successfully. 然后,连接数据库进行验证:清单 16. 连接数据库验证数据库是否正常 bash-3.00$ db2 connect to lr1 Database Connection Information Database server = DB2/SUN64 10.1.0 SQL authorization ID = DB2LR1 Local database alias = LR1 bash-3.00$ db2 select GRANTOR, GRANTORTYPE, GRANTEE from syscat.dbauth GRANTOR GRANTORTYPE GRANTEE - - - SYSIBM S DB2LR1 DB2LR1 U SAPLR1 DB2LR1 U LR1ADM 3 record(s) selected. DPF 数据库升级数据库与 Non-DPF 略有不同,在升级数据库前需要对数据库进行编目,否则升级时会提示尚未对数据库进行编目。1. 首先对数据库进行编目 , 从清单中我们可以看到编目前后的不同。 清单 17. 对数据库进行编目 bash-3.00$ db2 list database directory System Database Directory Number of entries in the directory = 1 Database 1 entry: Database alias = LR1 Database name = LR1 Local database directory = /db2/LR1 Database release level = d.00 Comment = SAP database LR1 Directory entry type = Indirect Catalog database partition number = 0 Alternate server hostname = Alternate server port number = bash-3.00$ db2 catalog db lr1 as lr1_10 DB20000I The CATALOG DATABASE command completed successfully. bash-3.00$ db2 list database directory System Database Directory Number of entries in the directory = 2 Database 1 entry: Database alias = LR1 Database name = LR1 Local database directory = /db2/LR1 Database release level = d.00 Comment = SAP database LR1 Directory entry type = Indirect Catalog database partition number = 0 Alternate server hostname = Alternate server port number = Database 2 entry: Database alias = LR1_10 Database name = LR1 Local database directory = /db2/LR1 Database release level = f.00 Comment = Directory entry type = Indirect Catalog database partition number = 0 Alternate server hostname = Alternate server port number = 2. 然后升级数据库, 清单 18. 升级 DPF 数据库 bash-3.00$ db2 UPGRADE DATABASE LR1_10 DB20000I The UPGRADE DATABASE command completed successfully. 3. 最后连接数据库验证 清单 19. 连接数据库验证升级后数据库是否正常 清单 19. 连接数据库进行验证 bash-3.00$ db2 connect to lr1 Database Connection Information Database server = DB2/SUNX8664 10.1.0 SQL authorization ID = DB2LR1 Local database alias = LR1 bash-3.00$ db2 select GRANTOR, GRANTORTYPE, GRANTEE from syscat.dbauth GRANTOR GRANTORTYPE GRANTEE - - - SYSIBM S DB2LR1 DB2LR1 U SAPLR1 DB2LR1 U LR1ADM 3 record(s) selected. 2.7如何升级到 V10.1 pureScaleIBM 从 DB2 V9.8 推出 DB2 pureScale 特性,提供强大处理能力,透明的应用扩展以及服务的连续可用性。

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论