If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > db2batch - instance attach fails

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-06-03, 10:46
c149187 c149187 is offline
Registered User
 
Join Date: Jul 2003
Posts: 50
db2batch - instance attach fails

Hi

I perform db2batch from my Windows-NT-db2-command-window (db2batch -d ADUSTONE -f sort.sql -a c149187/xxxxxx -r out.txt)
on a remote Unix database and get the following: (udb 7.2)

----------------------------------------------------------------------------

--#SET PERF_DETAIL 3 ROWS_OUT 5

Statement number: 1

select count(*) from sysibm.systables

1
--------------
264


Number of rows retrieved is: 1
Number of rows sent to output is: 1

SQL1428N The application is already attached to "DB2" while the command issued requires an attachment to "DINTADU" for successful execution.


Elapsed Time is: 0.150 seconds


Summary of Results
==================
Elapsed Agent CPU Rows Rows
Statement # Time (s) Time (s) Fetched Printed
1 0.150 Not Collected 1 1

Arith. mean 0.150
Geom. mean 0.150

----------------------------------------------------------------------------

-> The sql can be executed, but the instance attachment fails:
SQL1428N The application is already attached to "DB2" while the command issued requires an attachment to "DINTADU" for successful execution.

I tried to attach from my db2 window to DINTADU before executing db2batch, but it doesn't help. db2batch doesn't seem to know that the db ADUSTONE is on the instance DINTADU and not on DB2

If I execute db2batch on a db on my PC, the everythinh works.

-> Can db2batch not executed on a remote db ?

Marc
Reply With Quote
  #2 (permalink)  
Old 11-06-03, 11:00
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Try CATALOG TCP/IP NODE using the "REMOTE_INSTANCE instance-name" parm to associate the node with a particular instance. This assumes your protocol is TCP/IP. If not, use the other CATALOG commands for your protocol.

Then you can ATTACH TO nodename.
Reply With Quote
  #3 (permalink)  
Old 11-06-03, 11:50
c149187 c149187 is offline
Registered User
 
Join Date: Jul 2003
Posts: 50
The IBM Client Configuration Assistant says:
I have as instance node name DINTADU and its remote instance name is DINTADU also. The ATTACH TO from a db2 window is no problem, but it seems that db2batch attaches always to the local instance DB2 ???
Reply With Quote
  #4 (permalink)  
Old 11-06-03, 12:01
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
I believe that with the catalog command that I mentioned you can create an alias (using a different name) to differentiate between the local and remote instance. I think you can do the same with CCA.
Reply With Quote
  #5 (permalink)  
Old 11-11-03, 06:48
c149187 c149187 is offline
Registered User
 
Join Date: Jul 2003
Posts: 50
Hi

Can db2batch only be used for a local database, or can it be used also for remote database (I ask it because db2batch always does an implicit attach to the local db2instance)
?

Marc
Reply With Quote
  #6 (permalink)  
Old 11-11-03, 07:18
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
I think the database has to be catalogued locally as a remote database.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #7 (permalink)  
Old 11-11-03, 08:19
c149187 c149187 is offline
Registered User
 
Join Date: Jul 2003
Posts: 50
The database is catalogued locally as a remote database. The SQL in the db2batch file (select count(*) from sysibm.systables) is exceuted correctly on the remote Unix database, so I think that the configuration is correctly.

I start db2batch with -d adutest, the connect to the database adutest works, the sql result is correct.

But when snapshot info's should be gathered as a second part of the db2batch-output, that requires an attach on the remote instance, db2batch doesn't know that the database adutest is in the remote instance adu, db2batch tries the local instance db2.

I can't see that I have forgot something in the configuration !?

Marc
Reply With Quote
  #8 (permalink)  
Old 11-11-03, 09:57
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
OK, I see what the problem is:

Setting the current instance Procedure:

When you run commands to start or stop an instance’s database manager, DB2 applies the command to the current instance. DB2 determines the current instance as follows:

- If the DB2INSTANCE environment variable is set for the current session, its value is the current instance. To set the DB2INSTANCE environment variable, enter:

set db2instance=<new_instance_name>

- If the DB2INSTANCE environment variable is not set for the current session, DB2 uses the setting for the DB2INSTANCE environment variable from the system environment variables. On Windows NT, system environment variables are set in System Environment. On Windows 9x, they are set in the autoexec.bat file.

- If the DB2INSTANCE environment variable is not set at all, DB2 uses the registry variable, DB2INSTDEF. To set the DB2INSTDEF registry variable at the global level of the registry, enter:

db2set db2instdef=<new_instance_name> -g

To determine which instance applies to the current session, enter:

db2 get instance
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390

Last edited by Marcus_A; 11-11-03 at 10:00.
Reply With Quote
  #9 (permalink)  
Old 11-11-03, 10:07
c149187 c149187 is offline
Registered User
 
Join Date: Jul 2003
Posts: 50
My computer has:
Remote instance = dintadu/ADUDEV (on server C007473)
Local instance = DB2 (on local computer C020517)
-> See the jpeg-attachment on this reply.

The problem is that I can't say explicitly to db2batch to attach to ADUDEV. I get a SQL1428N, see below:


---------------------------------------------
--#SET PERF_DETAIL 3 ROWS_OUT 5

Statement number: 1

select count(*) from sysibm.systables

1
--------------
290


Number of rows retrieved is: 1
Number of rows sent to output is: 1

SQL1428N The application is already attached to "DB2" while the command issued
requires an attachment to "ADUDEV" for successful execution.


Elapsed Time is: 0.140 seconds


Summary of Results
==================
Elapsed Agent CPU Rows Rows
Statement # Time (s) Time (s) Fetched Printed
1 0.140 Not Collected 1 1

Arith. mean 0.140
Geom. mean 0.140
Attached Images
File Type: jpg db2batch.jpg (28.6 KB, 235 views)
Reply With Quote
  #10 (permalink)  
Old 07-06-07, 16:31
wesclark wesclark is offline
Registered User
 
Join Date: Nov 2004
Posts: 2
Solution

I had exactly the same problem, which is why I found this page. Include the attach command in the batch. In my case, the batch was two commands

CONNECT TO ccqa USER db2inst1 USING db2inst1
GET SNAPSHOT FOR DATABASE ON ccqa

and I got the same error message. Then I added

attach to db2qa11 user db2inst1 using db2inst11

to the start, and the error message was gone.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On