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 > executing db2 commands as a root !

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-30-09, 01:19
jayawant01 jayawant01 is offline
Registered User
 
Join Date: Jun 2008
Posts: 40
executing db2 commands as a root !

Hi all,

I have installed db2 ese on aix server using root authority ,
but when ever i try to execute any db2 command as a root user it throws me error db2 not found . i have added root user id to my dbadmin group by modifying the /etc/groups file .
Kindly help
Reply With Quote
  #2 (permalink)  
Old 03-30-09, 02:15
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
You have to execute the profile of the instance owner user id. I don't use AIX much anymore (use Linux) so I don't remember the file name, but probably .profile in the home directory of the instance owner.

In a shell script, execute it as:
. /home/db2inst1/.profile

where home directory of of instance owner is /home/db2inst1 and profile file name is .profile. Note the space between the first dot and the first slash.
__________________
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
  #3 (permalink)  
Old 03-30-09, 05:33
nick.ncs nick.ncs is offline
Registered User
 
Join Date: May 2007
Location: somewhere in dbforums
Posts: 221
As said by Marcus.... add the following into the .profile file of root

Quote:
# The following three lines have been added by UDB DB2.
if [ -f /home/db2inst1/sqllib/db2profile ];then
. /home/db2inst1/sqllib/db2profile
fi
this is considering the fact that db2inst1 is an instance available in your system....

The above mentioned script will also be available in the.profile file of your db2 instance which you can directly copy paste into the .profile of root user
__________________
IBM Certified Database Associate, DB2 9 for LUW
Reply With Quote
  #4 (permalink)  
Old 03-30-09, 07:22
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
i would never recommend this because you depend on setting for other user
never use root for db2 and create dedicate user and create db2 user instance with your proper settings;;;;
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #5 (permalink)  
Old 03-30-09, 08:48
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by przytula_guy
i would never recommend this because you depend on setting for other user
never use root for db2 and create dedicate user and create db2 user instance with your proper settings;;;;
If the user in question is the instance owner, I don't see the problem if the command is part of a shell script. This is especially useful if you have a standard in the company as to where the home directory is located for the instance owner.
__________________
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
  #6 (permalink)  
Old 03-30-09, 08:53
jayawant01 jayawant01 is offline
Registered User
 
Join Date: Jun 2008
Posts: 40
Hi All,
i did try to execute the .profile of the instance owner user id but it did not work and at the root i dont find .profile file of the root user .At the root i typed ls -a but i dont find any .profile file . The reason i am trying to execute db2 command with root authority is because i want to drop and create new instance which i guess i can do with only root access
Reply With Quote
  #7 (permalink)  
Old 03-30-09, 09:56
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
If you just want to drop and create instances, you do not need the instance profile loaded to do that. Just run the db2idrop and db2icrt commands as root. You will have to fully qualify the names when executing them. Also run them from the installation directory of DB2 and not the instance directories.

Andy
Reply With Quote
  #8 (permalink)  
Old 03-30-09, 10:25
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
for db2icrt and db2idrop you d not need any db2 settings
just cd /opt/ibm/db2/V9.5/instance or where db2 was installed and execute
./db2icrt ....
another remark : .profile is located in /home/db2inst1 or home directory of db2inst1
you should specify the full path or cd first to the home of db2inst1
as documented, this should do..
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #9 (permalink)  
Old 03-30-09, 10:41
jayawant01 jayawant01 is offline
Registered User
 
Join Date: Jun 2008
Posts: 40
I tried this and got the following result .
/opt/IBM/db2/V9.5/instance
# db2icrt -u db2fenc1 db2inst2
ksh: db2icrt: not found.
Reply With Quote
  #10 (permalink)  
Old 03-30-09, 10:52
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Quote:
Originally Posted by jayawant01
I tried this and got the following result .
/opt/IBM/db2/V9.5/instance
# db2icrt -u db2fenc1 db2inst2
ksh: db2icrt: not found.
If you working directory is /opt/IBM/db2/V9.5/instance then you need to execute:

# ./db2icrt -u db2fenc1 db2inst2

Andy
Reply With Quote
  #11 (permalink)  
Old 03-30-09, 13:16
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Or you can do the following:

/opt/IBM/db2/V9.5/instance/db2icrt -u db2fenc1 db2inst2

however you did not specify a port number, so try this:

/opt/IBM/db2/V9.5/instance/db2icrt -u db2fenc1 -p 50100 db2inst2

Where 50100 is your port number.

Edit: Last time I worked on AIX (DB2 V8), IBM did not install DB2 on /opt directory, so you need to find out where DB2 is installed. Maybe they changed it so all Linux/UNIX is now on /opt but check first.

Edit2: Directory on Linux for 9.5 is (case sensitive): /opt/ibm/db2/V9.5/instance
This could be different if a new fix pack was installed, or if installer chose a different directory.
__________________
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; 03-30-09 at 13:21.
Reply With Quote
  #12 (permalink)  
Old 03-31-09, 00:33
jayawant01 jayawant01 is offline
Registered User
 
Join Date: Jun 2008
Posts: 40
Hi Guys ,
Thanks to all of you !
./db2icrt .... worked
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