DB2 v10.5 HADR Rapid Deployment Manual

Source: Internet
Author: User
Tags db2 db2 connect db2 connect to custom name quiesce ibm support

First, directory Preparation
Mkdir-p/home/db2inst1/db2_backup
Mkdir-p/home/db2inst1/db2_archive
Mkdir-p/home/db2inst1/db2_log
Chmod-r 775/home/db2inst1/db2_backup
Chmod-r 775/home/db2inst1/db2_archive
Chmod-r 775/home/db2inst1/db2_log
Chown-r Db2inst1:db2inst1/home/db2inst1/db2_backup
Chown-r db2inst1:db2inst1/home/db2inst1/db2_archive
Chown-r Db2inst1:db2inst1/home/db2inst1/db2_log

Second, service and port configuration (note the HADR service port and the instance port to be separated)
Db2_hadr_1 55110/tcp
Db2_hadr_2 55111/tcp

DB2 Get dbm CFG | Grep-i SVCENAME
DB2 update dbm CFG using SVCENAME db2_db2inst1
DB2 Update Database Manager configuration using Svcename db2_hadr_1 (custom name)

Main Library
DB2 update dbm CFG using SVCENAME 55110
Standby Library
DB2 update dbm CFG using SVCENAME 55111

UPDATE ALTERNATE SERVER for DATABASE SAMPLE USING HOSTNAME 192.168.12.107 PORT 50000

UPDATE ALTERNATE SERVER for DATABASE SAMPLE USING HOSTNAME 192.168.12.108 PORT 50000


Third, open the archive mode (both the main library and the standby operation)
First modify the archive parameters, do offline backup, restart the database, manually test the archive

Main Library
DB2 Update DB CFG for sample using Logarchmeth1 disk:/home/db2inst1/db2_archive/

DB2 Update DB CFG for sample using Newlogpath/home/db2inst1/db2_log

DB2 Force applications All

DB2 Backup DB Sample to/home/db2inst1/db2_backup/

Db2stop Force;db2start

DB2 Archive log for DB sample

sql1116n A connection to or activation of database "SAMPLE" failed because
The database is in BACKUP PENDING state. sqlstate=57019

Standby Library:

DB2 Update DB CFG for sample using Logarchmeth1 disk:/home/db2inst1/db2_archive/

DB2 Update DB CFG for sample using Newlogpath/home/db2inst1/db2_log

DB2 Force applications All

DB2 Backup DB Sample to/home/db2inst1/db2_backup/

Db2stop Force;db2start

DB2 Archive log for DB sample


Iv. backing up and restoring from a library
Master Library offline Full backup
1.DB2 BACKUP Database Sample To/home/db1inst1/db2_backup
3.scp/home/db2inst1/db2_backup/sample.0.db2inst1.dbpart000.20171220165404.001 [email protected]:/home/ db2inst1/db2_backup/


Restore data from a backup repository
DB2 RESTORE Database sample from '/home/db2inst1/db2_backup/' taken at 20171220165404 replace the history file

2.sql2523w warning! Restoring to a existing database that's different from

3.the database on the backup image, but has matching names. The target database

4.will is overwritten by the backup version. The Roll-forward recovery logs

5.associated with the target database would be deleted.

6.Do want to continue? (y/n) Y

7.db20000i the RESTORE DATABASE command completed successfully.


Five, the main library parameter configuration

DB2 get DB CFG for sample | Grep-i HADR
[[Email protected] db2_backup]$ DB2 get DB CFG for sample | Grep-i HADR
HADR Database role = Standard
HADR Local Host name (hadr_local_host) =
HADR Local Service name (HADR_LOCAL_SVC) =
HADR Remote Host name (hadr_remote_host) =
HADR Remote Service name (HADR_REMOTE_SVC) =
HADR instance Name of remote server (hadr_remote_inst) =
HADR Timeout value (hadr_timeout) = 120
HADR target list (hadr_target_list) =
HADR Log Write synchronization mode (hadr_syncmode) = Nearsync
HADR Spool log data limit (4KB) (hadr_spool_limit) = AUTOMATIC (0)
HADR Log replay delay (seconds) (hadr_replay_delay) = 0
HADR Peer window Duration (seconds) (Hadr_peer_window) = 0


DB2 Update DB CFG for sample using Hadr_local_host 192.168.12.108

DB2 Update DB CFG for sample using Hadr_local_svc db2_hadr_2

DB2 Update DB CFG for sample using Hadr_remote_host 192.168.12.107

DB2 Update DB CFG for sample using Hadr_remote_svc db2_hadr_1

DB2 Update DB CFG for sample using Hadr_remote_inst Db2inst1

DB2 Update DB CFG for sample using Hadr_syncmode Nearsync

DB2 Update DB CFG for sample using Hadr_timeout 120


Standby parameter Configuration

DB2 get DB CFG for sample | Grep-i HADR

DB2 Update DB CFG for sample using Hadr_local_host 192.168.12.108

DB2 Update DB CFG for sample using Hadr_local_svc db2_hadr_2

DB2 Update DB CFG for sample using Hadr_remote_host 192.168.12.107

DB2 Update DB CFG for sample using Hadr_remote_svc db2_hadr_1

DB2 Update DB CFG for sample using Hadr_remote_inst Db2inst1

DB2 Update DB CFG for sample using Hadr_syncmode Nearsync

DB2 Update DB CFG for sample using Hadr_timeout 120

DB2 get DB CFG for sample | Grep-i HADR

Start Hadr


Start the Standby library first
Standby end of the database through the primary side of the database recovery, after the recovery must be roll forward-pending State,
You cannot use without rolling forward in restore to determine this state before starting the repository
Standby Status Confirmation
DB2 get DB CFG for sample | grep rollforward
Rollforward pending = DATABASE

Compared to the main library:
DB2 get DB CFG for sample | grep rollforward
Rollforward pending = NO


Starting a standby Library
DB2 start HADR on database sample as Standby
[Email protected] ~]$ DB2 start HADR on database sample as Standby
sql1766w the command completed successfully. However, Logindexbuild is not
Enabled before HADR was started.
View HADR Status-There is currently only a standby, state is disconnected


Start the main library
DB2 Deactivate Database sample
DB2 start HADR on database sample as Primary

Now that the main and standby libraries are connected, the HADR lab environment is deployed

DB2 get snapshot for db on sample | Grep-a "HADR Status"

DB2 get snapshot for db on Hadb01 | Grep-a "HADR Status"


sql1768n
Failed to start HADR. Reason code = Reason-code.
Description
The explanations corresponding to the reason codes are:

1 The database is not recoverable because circular logging is being used.
2 The database has unlimited activity logging enabled.
3 The database has datalinks enabled.
4 hadr_local_host configuration parameters do not match the local host name.
5 The HADR_LOCAL_SVC configuration parameter is an invalid service name.
6 The Hadr_remote_svc configuration parameter is an invalid service name.
7 during the HADR time-out interval, the primary database failed to establish a connection to its standby database.
81 or more HADR database configuration parameters do not have any values.
9 The database is configured to use the original log. However, HADR does not support the use of raw I/O (direct disk access) for database log files.
The 10 command was interrupted by Hadr shutdown because of the STOP HADR command, deactivation database, or internal error.
98 a valid HADR license is not installed. The command did not complete successfully.
99 An internal error occurred during HADR startup.


User response:
The user response corresponding to the reason code is:

1 The database must be a recoverable database. Activate the log archive or open Logretain, and then re-issue the command.
2 Disable infinite activity logging and re-issue the command.
3 Set the Database Manager configuration parameter datalinks to NO and re-issue the command.
4 Correct the Hadr_local_host setting to match the local host name.
5 Ensure that the HADR_LOCAL_SVC configuration parameter is a valid service name. For Unix platforms, edit the/etc/services file. For Windows, edit%systemroot%\system32\drivers\etc\services. In addition, you can specify a text port number for this parameter.
6 Ensure that the HADR_REMOTE_SVC configuration parameter is a valid service name. For Unix platforms, edit the/etc/services file. For Windows, edit%systemroot%\system32\drivers\etc\services. In addition, you can specify a text port number for this parameter.
7 Check the remote host and remote service parameters on the standby database. Make sure that the standby database is online and that the network is functioning. If the network speed is too slow, consider increasing the hadr_timeout configuration parameters, or use the By force option to start the primary database.
8 ensure that one or more HADR database configuration parameters have values.
9 reconfigure the database to use only file system storage for log files, rather than using raw I/O (direct disk access) devices. See the DB2 Information Center for a discussion of LogPath and Newlogpath database configuration parameters.
10 identify the cause of the HADR shutdown and, if necessary, re-issue the start HADR command.
98 obtain and install a valid HADR license, and then resubmit the command.
99 If the problem persists, contact your IBM support agency.


Sometimes we would like to have a database under one instance stop providing services to the outside, without affecting the other databases,
At this point, you need to stop a single database.
The methods are summarized as follows:

One way is to:
To stop a single database using Quiense:
If the connected user is not a member of SYSADM, you can connect the database to the instance user and then use
DB2 QUIESCE DB IMMEDIATE Force CONNECTIONS
And then
DB2 Reset or DB2 terminate
And then
Deactivate DB
After the finished, remember to use DB2 UNQUIESCE DB to restore its external connection.

The specific process is as follows:
DB2 Connect to sample
DB2 QUIESCE DB Immediate Force connections
DB2 Terminate

DB2 Deactivate DB sample

DB2 Connect to sample
DB2 UNQUIESCE DB

Attention:
After QUIESCE database, only Sysadm, Sysmaint, Dbadm, or Sysctrl users can access the databases.
Another way:
Stop access:
DB2 Uncatalog Database sample
DB2 Terminate

Start Access:
DB2 Catalog Database sample
DB2 Terminate
DB2 Connect to sample

DB2 v10.5 HADR Rapid Deployment Manual

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.