The deployed Capture and Apply component instances are using by
default the credentials of the user who started them. While this may be sufficient
for some topologies, there are two scenarios where alternate credentials have
to be used
- First Scenario - Alternate user credentials: The database administrator
(DBA) wants to be logged on as user user1 but wants the utility to
use user user2 to move data from the source database to the target
database.
- Second Scenario - Distributed environment: The DBA plans to run
the utility on machine1. The source or the target database is maintained
on another machine machine2.
To support those scenarios, you must create password files containing
the user credentials to be used instead of the current user credentials. Because
password files are not automatically created during deployment, you need to
perform the following steps for the two scenarios:
- Prepare a file to store the user id and password information
to be used when connecting to a source database. In a DB2® command-line window, enter the following
command, and substitute any placeholders marked like this: <place_holder_name> with
the appropriate value.
asnpwd INIT encrypt all using <password_file>. The
asnpwd tool creates an empty file: <password_file>.
Example
invocations: asnpwd INIT encrypt all using password.aut
- Save the database access information (user ID, password, and database
name) for each database the replication utility will have to connect to. In
a DB2 command-line
window, enter the following command, and substitute any placeholders marked
like this: <place_holder_name> with the appropriate value.
asnpwd ADD alias <DB_name> ID <user_ID> PASSWORD <Password> using <password_file>.
Repeat this step for each database if necessary. The program encrypts
the information you enter and saves it in the <password_file>.
Example
invocation:
- asnpwd ADD alias STMD7 id MYUSRID password MYPASSWRD using password.aut
- asnpwd ADD alias RTMD7 id MYUSRID2 password MYPASSWRD2 using password.aut
- Update the utilities configuration files by modifying the generated
executable startup scripts (StartCapture and StartApply). You append the password-file
parameter to the command-line invocation of the replication utility. The utility
uses the encrypted user credentials that are stored in the specified file
instead of the default credentials. The password file must be located in the
work directory defined by the CAPTURE_PATH (or APPLY_PATH) parameter.
Example of changes:
- Original file content of Capture start script: db2cmd asncap CAPTURE_SERVER=stmd7
CAPTURE_SCHEMA=CAPTURE_1 CAPTURE_PATH="c:\tmp\state_capture_log"
- Modified file content of Capture start script: db2cmd asncap CAPTURE_SERVER=stmd7
CAPTURE_SCHEMA=CAPTURE_1 CAPTURE_PATH="c:\tmp\state_capture_log" pwdfile="password.aut"
- Original file content of Apply start script: db2cmd asnapply APPLY_QUAL=Apply_1
CONTROL_SERVER=RTMD7 APPLY_PATH="C:\tmp\apply"
- Modified file content of Apply start script: db2cmd asnapply APPLY_QUAL=Apply_1
CONTROL_SERVER=RTMD7 APPLY_PATH="C:\tmp\apply" pwdfile="password.aut"
- Copy the<password_file> that was created in steps 1 and
2 into the appropriate directory. The replication utilities attempt to open
the password file upon startup. An error occurs if the file: <password_file> does
not exist in the work directory identified by the CAPTURE_PATH (or APPLY_PATH)
parameter. If no work-directory parameter is specified, the utilities attempt
to locate the file in the current working directory.
For more information on DB2 utilities, refer to DB2 SQL Replication
Guide and Reference.