Tuesday, May 5, 2020

Change Oracle Group UUID for ORACLE_HOME

** NOTE: This procedure while has been tested on on an Oracle Linux server and has shown to allow the change of the UUID for the HOME
This is meant to help you in a situation where a UUID mismatch has happened and correct without having to reinstall.  Keep in mind while
it has been tested and used and has worked this is not assured to work for you, but may so shown here in case it can help you.

1. copy the permission.pl script found in Appendix A of this document into the root home location on each dbatabase node in the cluster.

scp permission.pl root@nodename


2. Log into each of the database nodes as root

ssh root@nodename


3. On each database node disable crs and shutdown all database and grid infrastructure components as well as any processes being run by oracle

. oraenv
+ASM1
crsctl disable crs
crsctl stop crs


4. On each node in the cluster capture the u01 permissions and ownership prior to change of UUID using permission.pl script process as root execute for the base location for oracle installations in our example we will use /u01
** Note: Your environment may not use /u01 and may have installs in multiple places in those cases run for each location.

perl permission.pl /u01
** See Script in Appendiz A of this document

script will create a script that ends in .cmd
example: restore-perm-Fri-Mar-13-20-27-33-2020.cmd


5. Set permission on this file for execution

Example: chmod 770 restore-perm-Fri-Mar-13-20-27-33-2020.cmd


6. Change the oracle owner and or group UUIDs in /etc/passwd and/or /etc/group


7. Check that the change has taken affect


8. Run the script process create by the permission.pl execution in prior step, this will restore the permissions and ownership for Oracle binaries

Example: ./restore-perm-Fri-Mar-13-20-27-33-2020.cmd


9. Post u01 restore permissons deal with ownership and permissions outside u01
** This uses 18.8.0.0 binaries and bianry locations you will need to adjust for your database and grid home locations.

cd /home
chown -R oracle:oinstall oracle
cd /u01/app/oracle/Oeda/Software/Patches
chown -R oracle:oinstall *
cd /u01/app/oracle/product/18.0.0.0/dbhome_1/.patch_storage
chown -R oracle:oinstall *
cd /u01/app/18.0.0.0/grid/.patch_storage
chown -R oracle:oinstall *
cd /var/tmp
chown -R oracle:oinstall GridSetupActions*
chown -R oracle:oinstall InstallActions*
chown -R oracle:oinstall hsperfdata_oracle
chown -R oracle:oinstall CVU_18.0.0.0.0_resource
chown -R oracle:oinstall CVU_18.0.0.0.0_oracle
cd /etc
chown oracle:oinstall oratab
chgrp oinstall oracle
cd /etc/oracle/scls_scr/agoprdd4dbadm*/oracle/ # Adjust for the node name of each node or wild card for Rack Group
chown oracle cssfatal
cd /etc/oracle/scls_scr/agoprdd4dbadm*/ # Adjust for the node name of each node or wild card for Rack Group
chown oracle oracle
cd /etc/oracle/scls_scr/agoprdd4dbadm0*/root # Adjust for the node name of each node or wild card for Rack Group
chgrp oinstall ohasdrun
chgrp oinstall ohasdstr
cd /etc/oracle/scls_scr/
chgrp oinstall agoprdd4dbadm* # Adjust for the node name of each node or wild card for Rack Group
cd /etc/oracle/
chgrp oinstall scls_scr
chgrp oinstall oprocd
chgrp oinstall olr.loc
chgrp oinstall ocr.loc
chgrp oinstall lastgasp
chgrp oinstall maps
chgrp oinstall setasmgid
cd /etc/oracle/oprocd
chgrp oinstall *
cd /etc/oracle/maps
chown oracle:oinstall *
cd /var/tmp
chgrp oinstall .oracle
cd /var/tmp/.oracle
rm -f *


10. Now that permissions are reset we can restart the cluster and check

. oraenv
+ASM1
crsctl start crs
ps -ef | grep grid
ps -ef | grep smon
crsctl check crs


Appedix A: permissions.pl
** Script was obtain from Oracle.

#!/usr/bin/perl -w
#
# Captures file permissions and the owner of the files
# useage : perm1.pl
#
# MODIFIED
#     uaswatha   12th March 2018  address filename with spaces (request from customer)

use strict;
use warnings;
use File::Find;
use POSIX();

my (@dir) = @ARGV;
my $linecount=0 ;

#print @ARGV, $#ARGV;

if ($#ARGV < 0) {
   print "\n\nOpps....Invalid Syntax !!!!\n" ;
   print "Usage   : ./perm1.pl \n\n" ;
   print "Example : ./perm1.pl /home/oralce\n\n" ;
   exit ;
}
my $logdir=$dir[0] ;
#my ($sec, $min, $hr, $day, $mon, $year) = localtime;
##my ($dow,$mon,$date,$hr,$min,$sec,$year) = POSIX::strftime( '%a %b %d %H %M %S %Y', localtime);
my $date = POSIX::strftime( '%a-%b-%d-%H-%M-%S-%Y', localtime);
my $logfile="permission-".$date;
my $cmdfile="restore-perm-".$date.".cmd" ;

open LOGFILE, "> $logfile" or die $! ;
open CMDFILE, "> $cmdfile" or die $! ;
find(\&process_file,@dir);

print "Following log files are generated\n" ;
print "logfile      : ".$logfile. "\n" ;
print "Command file : ".$cmdfile. "\n" ;
print "Linecount : ".$linecount."\n" ;
close (LOGFILE) ;
close (CMDFILE) ;


sub process_file {
    my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks,$username,$user,$pass,$comment,$home,$shell,
$group);
    my %uiduname = () ;
    my %gidgname = () ;
    my $filename = $File::Find::name;


#### Building uid, username hash

    open (PASSWDFILE, '/etc/passwd') ;

    while ( ) {
       ($user,$pass,$uid,$gid,$comment,$home,$shell)=split (/:/) ;
       $uiduname{$uid}=$user ;
    }
    close (PASSWDFILE) ;


#### Building gid, groupname hash

    open (GRPFILE, '/etc/group') ;

    while ( ) {
       ($group,$pass,$gid)=split (/:/) ;
       $gidgname{$gid}=$group ;
    }
    close (GRPFILE) ;

    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat("$filename");
#    printf  "%o %s %s %s\n", $mode & 07777, $uiduname{$uid}, $gidgname{$gid}, $filename ;
     printf LOGFILE "%o %s %s %s\n", $mode & 07777, $uiduname{$uid}, $gidgname{$gid}, "\"$filename\"" ;
     printf CMDFILE "%s %s%s%s %s\n", "chown ",$uiduname{$uid}, ":", $gidgname{$gid}, "\"$filename\"" ;
     printf CMDFILE "%s %o %s\n", "chmod ",$mode & 07777, "\"$filename\"" ;
        #    printf  "%o %s %s %s\n", $mode & 07777, $uiduname{$uid}, $gidgname{$gid}, \",$filename,\" ;
    $linecount++ ;
}

No comments: