Link to home
Start Free TrialLog in
Avatar of MikeDelaney
MikeDelaneyFlag for United States of America

asked on

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
Avatar of sachinwadhwa
sachinwadhwa
Flag of United Kingdom of Great Britain and Northern Ireland image

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


ASKER CERTIFIED SOLUTION
Avatar of sachinwadhwa
sachinwadhwa
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MikeDelaney

ASKER

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?
forgot to add in 1st post...

to create database:

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