• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1842
  • Last Modified:

DB2 Create a database on a server from the client using script

Hi experts, I'm trying to set up a script that can do my initial setup from one machine.  But I'm stuck on the syntax because up to now, I've just hopped over to the server and set up the database locally on the server first, then back to the client box for the rest of teh setup.  However, I'd like to automate this. so....

given that I have 2 machines: dbServer and dbClient.  I can run
C:\dbClient>db2 catalog tcpip node TESTNODE remote dbServer server 50000
<<  I need the command to create the remote database  >>
C:\dbClient>db2 catalog database MYDATABASE at TESTNODE
C:\dbClient>db2 connect to MYDATABASE

I'm setting the points high here as time is of the essence.

Thanks, Mike
0
MikeDelaney
Asked:
MikeDelaney
  • 3
1 Solution
 
sachinwadhwaCommented:
db2 catalog tcpip node <nodename> remote <HostName> server 50000 REMOTE_INSTANCE <instanceName> OSTYPE <Win/Linux/AIX>
db2 catalog database <dbname> at node <nodename>
db2 connect to <dbname>


E.g.
db2 catalog tcpip node SAMPnode remote DB2serv.acme.com server 50000 REMOTE_INSTANCE db2 OSTYPE WIN
db2 catalog database sample at node SAMPnode
db2 connect to sample

Notes:

If you don't know your instance name, default iInstance name is DB2 in Windows and db2inst1 in Linux


0
 
sachinwadhwaCommented:
oh... command to create remote database.

to create database:

db2 attach to <NodeName> user <username> using <password>
db2 create database <dbname> ........
0
 
MikeDelaneyAuthor Commented:
Okay, but the returned response is:

c:\work>db2 catalog tcpip SAMPnode test remote db2Server server 50000 REMOTE_I
NSTANCE db2 OSTYPE WIN
DB20000I  The CATALOG TCPIP NODE command completed successfully.
DB21056W  Directory changes may not be effective until the directory cache is
refreshed.

c:\work>db2 catalog database sample at node SAMPnode
DB20000I  The CATALOG DATABASE command completed successfully.
DB21056W  Directory changes may not be effective until the directory cache is
refreshed.

c:\work>db2 connect to sample
SQL1031N  The database directory cannot be found on the indicated file system.
SQLSTATE=58031

So, How do I create the database?
0
 
sachinwadhwaCommented:
forgot to add in 1st post...

to create database:

db2 attach to <NodeName> user <username> using <password>
db2 create database <dbname> ........
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now