Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Thread: Rename Instance

  1. #1
    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

  2. #2
    Join Date
    Jan 2003
    Posts
    4,146
    1) you can use db2relocatedb
    2) pSeries and AIX Information Center

    Andy

  3. #3
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  4. #4
    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?

  5. #5
    Join Date
    Jan 2003
    Posts
    4,146
    I think in both cases, you will have to manually fix the ownership of the files.

    Andy

  6. #6
    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...

  7. #7
    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.

  8. #8
    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.

  9. #9
    Join Date
    Jan 2003
    Posts
    4,146
    I do not know AIX, but maybe you can just change the username?

    Andy

  10. #10
    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.

  11. #11
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  12. #12
    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

  13. #13
    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

  14. #14
    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.

  15. #15
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •