Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Db2 v10.5 HADR Rapid deployment Manual

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

I. Catalog 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

2. Service and port configuration (pay attention to the distinction between HADR service port and instance port)

DB2_HADR_1 55110/tcp

DB2_HADR_2 55111/tcp

3. Open the archiving mode (both the main database and backup database are operated)

Modify the archiving parameters, make an offline backup, restart the database, and manually test the archiving.

Main library

Db2 update db cfg for sample using logarchmeth2 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

Prepare the library:

Db2 update db cfg for sample using logarchmeth2 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

Backup and restore slave library

Offline full backup of the main library

1.db2 backup database sample to / home/db2inst1/db2_backup

3.scp / home/db2inst1/db2_backup/SAMPLE.0.db2inst1.DBPART000.20171220165404.001 db2inst1@192.168.12.108:/home/db2inst1/db2_backup/

Prepare the library to restore data

Db2 restore database sample from "/ home/db2inst1/db2_backup/" taken at 20171220165404 replace history file

2.SQL2523W Warning! Restoring to an existing database that is different from

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

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

5.associated with the target database will be deleted.

6.Do you want to continue? (YBO) y

7.DB20000I The RESTORE DATABASE command completed successfully.

V. Parameter configuration of the main library

Db2 get db cfg for sample | grep-I HADR

[db2inst1@107-sqlcheck 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

Reserve database 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 reserve library first

The database on the standby side is recovered from the database on the standby side, and must be in a roll forward-pending state after recovery.

Without rolling forward cannot be used in restore. Determine this status before starting the slave library.

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

Start the standby library

Db2 start hadr on database sample as standby

[db2inst2@kvm111 ~] $db2 start hadr on database sample as standby

SQL1766W The command completed successfully. However, LOGINDEXBUILD was not

Enabled before HADR was started.

Check the HADR status-currently there is only a standby database, and the status is disconnected

Start the main library

Db2 deactivate database sample

Db2 start hadr on database sample as primary

Now the connection between the main library and the standby library has been established, and the deployment of the HADR experimental environment has been completed.

Db2 get snapshot for db on sample | grep-A 15 "HADR Status"

Db2 get snapshot for db on hadb01 | grep-A 15 "HADR Status"

An error is reported from the library connection

SQL1776N The command cannot be issued on an HADR database. Reason code = "1".

Db2set DB2_HADR_ROS=ON

SQL1768N

Failed to start HADR. Reason code = reason-code.

Description:

The explanation corresponding to the reason code is:

1 the database cannot be recovered because circular logging is being used.

2. Unlimited activity logging is enabled in the database.

3 DATALINKS is enabled in the database.

4 HADR_LOCAL_HOST configuration parameters do not match the local hostname.

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 timeout interval, the primary database failed to establish a connection with its standby database.

8 one 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 the original Imax O (direct disk access) for database log files.

10 commands are interrupted by HADR shutdown due to STOP HADR commands, deactivation of the database, or internal errors.

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 recoverable. Activate the log archive or open LOGRETAIN, and then reissue the command.

2 disable unlimited activity logging and reissue the command.

3 set the database manager configuration parameter DATALINKS to NO and reissue 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 the Unix platform, 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 the Unix platform, 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 working. If the network is too slow, consider increasing the HADR_TIMEOUT configuration parameters or using 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 instead of the original Imax O (direct disk access) device. See the discussion of logpath and newlogpath database configuration parameters in the DB2 Information Center.

10 find out the reason for the HADR shutdown and reissue the START HADR command if necessary.

Obtain and install a valid HADR license, and then resubmit the command.

99 if the problem persists, please contact your IBM support organization.

Sometimes we want a database under one instance to stop providing services without affecting other databases.

At this point, you need to stop a single database.

The methods are summarized as follows:

One way is:

Use quiense database to stop a single database:

If the connected user is not a member of sysadm, you can use the instance user to connect to the database and then use the

Db2 quiesce db IMMEDIATE FORCE CONNECTIONS

And then

Db2 reset or db2 terminate

And then

Deactivate db

When you are done, 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

Note:

After QUIESCE DATABASE, only sysadm, sysmaint, dbadm, or sysctrl users can access the database.

Another way:

Stop access:

Db2 uncatalog database sample

Db2 terminate

Initiate access:

Db2 catalog database sample

Db2 terminate

Db2 connect to sample

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report