Home Database Mysql Tutorial DB2数据库利用备份实现异机还原实例分析

DB2数据库利用备份实现异机还原实例分析

Jun 07, 2016 pm 05:41 PM
Backup implementation

一生产的DB2数据库需要将其数据全部备份,然后还原导入到一测试库中,中间遇到一些问题,最后还是圆满解决了,现将步骤记录下来方便学习和分析。系统环境:AIX5.

   一生产的DB2数据库需要将其数据全部备份,香港虚拟主机,然后还原导入到一测试库中,中间遇到一些问题,最后还是圆满解决了,香港服务器,现将步骤记录下来方便学习和分析。

系统环境:AIX5.3

数据库: DB2 V9.1

两台服务器:  生产服务器 192.168.11.178

                          测试服务器 10.10.11.81

一、备份

分别备份一下生产服务器和测试服务器的数据库(两个服务器上数据库一样)

$  db2 backup db LAW online to /basefsnew/db2bak0111 include logs             #生产

备份成功。此备份映像的时间戳记是:20130111180236

$  db2 backup db LAW online to /basefs/db2bak0111 include logs      #测试

备份成功。此备份映像的时间戳记是:20130111190381

二、将生产库的备份传送到测试服务器

大家可以利用SCP命令或其他文件传输软件来传送备份,香港服务器,这里提醒一下传过来的备份需要改属主和属组还有权限,否则将导致还原时出错

三、具体还原过程和问题解决

$ db2 force applications all   (先停止所有应用连接)
DB20000I  The FORCE APPLICATION command completed successfully.
DB21024I  This command is asynchronous and may not be effective immediately.

在测试服务器上开始还原
$ db2 restore db LAW from /home taken at 20130111180236
SQL2539W  Warning!  Restoring to an existing database that is the same as the backup image database.  The database files will be deleted.
Do you want to continue ? (y/n) y
DB20000I  The RESTORE DATABASE command completed successfully.
还原成功

但随后连接数据库时报错

$ db2 connect to LAW
SQL1117N  A connection to or activation of database "LAW" cannot be made
because of ROLL-FORWARD PENDING.  SQLSTATE=57019

这个提示是说需要前滚期间的日志才能激活数据库

下面执行此句进行前滚

$ db2 rollforward db LAW to end of logs and complete
SQL4970N  Roll-forward recovery on database "LAW" cannot reach the specified
stop point (end-of-log or point-in-time) because of missing log file(s) on
node(s) "0".

提示缺失日志,不能到达结束点

注:比较顺利一次成功时,是这个状态

$db2 rollforward db LAW to end of logs and complete

Rollforward Status

Input database alias = db
Number of nodes have returned status = 1

Node number = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = -
Last committed transaction = 2013-1-11-10.59.23.000000

DB20000I The ROLLFORWARD command completed successfully.
 

下面通过这个命令看一下数据库的状态和提示
$ db2 rollforward db LAW query status

                                 Rollforward Status

 Input database alias                   = LAW
 Number of nodes have returned status   = 1

 Node number                            = 0
 Rollforward status                     = DB  working
 Next log file to be read               = S0003169.LOG
 Log files processed                    =  -
 Last committed transaction             = 2012-08-24-12.02.32.000000
通过这个命令,我们发现提示下一个日志为S0003169.LOG,
需要找到这个文件所在的路径,将生产服务器上从备份时间点后的日志全部同步或拷贝到测试服务器。
找到生产服务器上DB2日志,目录为/home/db2logs/db2inst2/LAW/NODE0000/C0000004
将此目录下从做备份的那个时间点后的日志全部拷贝放到测试服务器的相应目录(可以放到库备份的那个目录)下,同时注意修改日志文件的属主、属组和权限,防止权限不一致问题。

# chown db2inst1:db2iadm1 S0003170.LOG
# chown db2inst1:db2iadm1 S0003171.LOG
# chown db2inst1:db2iadm1 S0003172.LOG
# chown db2inst1:db2iadm1 S0003173.LOG
# chown db2inst1:db2iadm1 S0003174.LOG
# chown db2inst1:db2iadm1 S0003175.LOG
# chown db2inst1:db2iadm1 S0003176.LOG
#chmod 744  S0003170.LOG
#chmod 744  S0003171.LOG
#chmod 744  S0003172.LOG
#chmod 744  S0003173.LOG
#chmod 744  S0003174.LOG
#chmod 744  S0003175.LOG
#chmod 744  S0003176.LOG  

用如下命令来前滚日志并停止日志的溢出,注意"("/home")"格式,指的是日志所在的路径

$ db2 rollforward db LAW to end of logs and stop overflow log path "("/home")"

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the problem of mysql cannot open shared library How to solve the problem of mysql cannot open shared library Mar 04, 2025 pm 04:01 PM

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

Reduce the use of MySQL memory in Docker Reduce the use of MySQL memory in Docker Mar 04, 2025 pm 03:52 PM

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Run MySQl in Linux (with/without podman container with phpmyadmin) Run MySQl in Linux (with/without podman container with phpmyadmin) Mar 04, 2025 pm 03:54 PM

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

What is SQLite? Comprehensive overview What is SQLite? Comprehensive overview Mar 04, 2025 pm 03:55 PM

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Running multiple MySQL versions on MacOS: A step-by-step guide Running multiple MySQL versions on MacOS: A step-by-step guide Mar 04, 2025 pm 03:49 PM

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

See all articles