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 > Rename Instance

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Aug 2011
Posts: 33
Rename Instance

Recently because of an audit we are now required to change our naming standards for instance....I have few questions.

1)Is restoring the instance/database into a completely new instance the only way to rename an instance.If not, is there any other way to do it?

2)What is the max length for a group name in AIX 6.1 and above?

I really appreciate any hints/help on this request.

Thanks,
Ram
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Jan 2003
Posts: 4,105
1) you can use db2relocatedb
2) pSeries and AIX Information Center

Andy
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,722
You can uncatalog the database, and then recatalog the database (using db path) when logged on to server as the new instance owner id, without having to move the database. If you try this, make a note of the current db path with "list db directory" before you uncatalog it.

Obviously, if you have the database directory, or any tablespaces in a path under the home directory path of the old instance, this may be a bit ackward, and backup/restore may be better in that case.
__________________
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
  #4 (permalink)  
Old
Registered User
 
Join Date: Aug 2011
Posts: 33
Andy and Marcus...thankyou for the reply.If we use db2relocate db or if we uncatalog and catalog the database on new insatnce,would the underlying files ownership in the databases resolve to the new instance name?
Reply With Quote
  #5 (permalink)  
Old
Registered User
 
Join Date: Jan 2003
Posts: 4,105
I think in both cases, you will have to manually fix the ownership of the files.

Andy
Reply With Quote
  #6 (permalink)  
Old
Registered User
 
Join Date: Aug 2011
Posts: 33
Isn't that a laborious process.I mean I am talking about 100 instances.Let me know what you think...
Reply With Quote
  #7 (permalink)  
Old
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,649
I don't know if this will work, but a thought ..

If you use the same uids and gids for the new users also, then change of permission is 'automatic' .

ie

the orignal instance :
db2inst1(uid 1000) in group db2grp (gid 1000)

now , you can :

delete the users db2inst1 and db2grp
create new user db2inst2 (uid 1000) and db2grp2 (gid 1000)

HTH
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #8 (permalink)  
Old
Registered User
 
Join Date: Aug 2011
Posts: 33
I think one gid corresponds to one group and all the users in that group will have the same gid and I believe we cannot specify same uid for two different users.
Reply With Quote
  #9 (permalink)  
Old
Registered User
 
Join Date: Jan 2003
Posts: 4,105
I do not know AIX, but maybe you can just change the username?

Andy
Reply With Quote
  #10 (permalink)  
Old
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by Marcus_A View Post
You can uncatalog the database, and then recatalog the database (using db path) when logged on to server as the new instance owner id, without having to move the database.
I don't think this will work. db2 won't find it in the local db directory.
Reply With Quote
  #11 (permalink)  
Old
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,722
Quote:
Originally Posted by db2girl View Post
I don't think this will work. db2 won't find it in the local db directory.
Aside from the file permission issues mentioned above, it does work in my experience. Once you uncatalog the db, it is removed from the local db directory. Then you recatalog it using instance owner id of the new instance so that it goes back into the local db directory of that new instance (you must specifiy the db path when you re-catalog it).
__________________
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
  #12 (permalink)  
Old
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by Marcus_A View Post
Once you uncatalog the db, it is removed from the local db directory.
It will be removed from the system db directory, but it will remain in the local db directory.



Example:

db2inst2@pepperjack:~> db2 create db marcus
DB20000I The CREATE DATABASE command completed successfully.


db2inst2@pepperjack:~> db2 list db directory

System Database Directory

Number of entries in the directory = 3

Database 1 entry:

Database alias = MARCUS
Database name = MARCUS
Local database directory = /home/db2inst2
Database release level = b.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =


db2inst2@pepperjack:~> db2 list db directory on /home/db2inst2

Local Database Directory on /home/db2inst2

Number of entries in the directory = 2

Database 1 entry:

Database alias = MARCUS
Database name = MARCUS
Database directory = SQL00002
Database release level = b.00
Comment =
Directory entry type = Home
Catalog database partition number = 0
Database partition number = 0



db2inst2@pepperjack:~/db2inst2/NODE0000/sqldbdir> pwd
/home/db2inst2/db2inst2/NODE0000/sqldbdir


db2inst2@pepperjack:~/db2inst2/NODE0000/sqldbdir> strings /home/db2inst2/db2inst2/NODE0000/sqldbdir/sqldbdir
DB2 DIRECTORY
MARCUS
MARCUS
2SQL00002
/home/db2inst2/db2inst2



db2inst2@pepperjack:~/db2inst2/NODE0000/sqldbdir> db2 uncatalog db marcus
DB20000I The UNCATALOG DATABASE command completed successfully.
DB21056W Directory changes may not be effective until the directory cache is refreshed.


db2inst2@pepperjack:~/db2inst2/NODE0000/sqldbdir> db2 list db directory on /home/db2inst2

Local Database Directory on /home/db2inst2

Number of entries in the directory = 2

Database 1 entry:

Database alias = MARCUS
Database name = MARCUS
Database directory = SQL00002
Database release level = b.00
Comment =
Directory entry type = Home
Catalog database partition number = 0
Database partition number = 0


db2inst2@pepperjack:~/db2inst2/NODE0000/sqldbdir> strings /home/db2inst2/db2inst2/NODE0000/sqldbdir/sqldbdir
DB2 DIRECTORY
MARCUS
MARCUS
2SQL00002
/home/db2inst2/db2inst2
Reply With Quote
  #13 (permalink)  
Old
Registered User
 
Join Date: Aug 2011
Posts: 33
1)I think its a good idea to uncatalog on old and re-catalog on new instance.As we are going to stop the old instance completely after the move,does it matter if there is an entry in the local db directory?But,changing the file permissions will be a tedious task.

2)Also, how feasible is this process for federated databases.I am sure all cataloging has to be done again on the new instances.But , what else should I consider for federated databases?

3)I am also concerned on the group names AIX 5.3 and above.From the doc, that Andy provided,it says the group length can be 255 char's.But I do frequent grep's on group names in my scripts and what I found yesterday was "ls -al" displays only eight characters.Is there a way to allow ls -al to display the full name instead of truncating it?

I appreciate all your help on this..Hope its staring to be an interesting discussion
Reply With Quote
  #14 (permalink)  
Old
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,649
Quote:
Originally Posted by sysdba1 View Post
I think one gid corresponds to one group and all the users in that group will have the same gid and I believe we cannot specify same uid for two different users.
You are right ..
That's why I have specified "delete the users db2inst1 and db2grp"

Andy's suggestion on renaming sounds easier.

Don't think of doing all 100 instances on one night if they are all production. Do a few a week.
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #15 (permalink)  
Old
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,649
When you uncatalog and recatalog to a new instances, make sure you rename the instance name in the path.

This applies to my suggestion on reusing the same uid/gid with new name also.
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
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