How to Create and Compile USER EXIT
A user exit is an executable file that the DBMS calls for archive and retrieval of log files.
Sample
user exit are supplied in $HOME/sqllib/samples/c of the instance owner.
At the beginning of each sample file is a good description on how DB2
uses the specific user exit and which parameters you should set. For
Tivoli Storage Manager, the user exit sample is db2uext2.cadsm. Perform
the following steps to create the user exit executable.
1. Become root, then copy the db2uext2.cadsm to your working directory and
1. Become root, then copy the db2uext2.cadsm to your working directory and
rename
it to db2uext2.c. Change file ownership and permissions so the
instance
owner can modify the code.
2. Read
the comments at the beginning of the source code to understand the
defined
variables. Change the defined variables to suit your environment.
In our
lab, we took the default setting and only change the path of the user
exit
logfiles (AUDIT_ERROR_PATH).
3. As
the instance owner, compile the C program. In our lab, we used the
Visual
Age C Compiler V4.4. Check your compiler for the correct syntax.
The
implementation of the use exit requires a full offline database
backup
in order
to become effective. Ensure that you allocate sufficient time for
doing
this backup.
Note
#define
BUFFER_SIZE 4096 /* transmit or receive the log */
/* file
in 4k portions */
#define
AUDIT_ACTIVE 1 /* enable audit trail logging */
#define
ERROR_ACTIVE 1 /* enable error trail logging */
#define
AUDIT_ERROR_PATH "/home/db2inst2/tsm/" /* path must en
d with a
slash */
#define
AUDIT_ERROR_ATTR "a" /* append to text file */
compilar
32bits:
$
cc -I/opt/tivoli/tsm/client/api/bin/samples -L/usr/lib -lApiDS -o
db2uext2 db2uext2.c
compilar
64bits: (com o ususário root)
/usr/vacpp/bin/cc_r
-o db2uext2 -q64 db2uext2.c
/usr/tivoli/tsm/client/api/bin64/libApiTSM64.a
-I/usr/tivoli/tsm/client/api/bin64/sample
4. Copy
the db2uext2 file into the $HOME/sqllib/adm directory of the
instance
owner. We do not recommend that you copy the file to the
$HOME/sqllib/bin
directory, because this directory is only a link to a
directory
in the /opt/IBMdb2/V7.1/bin directory. Make sure the instance
owner
has execute permission for this file.
No comments:
Post a Comment