Oracle DBA FAQ

Oracle RAC interview questions, Oracle Dataguard, ASM, CRS, Oracle wait events, Performance Tuning


    Step to migrate Oracle RAC CRS resources to new server.

    Share

    Pat
    Guest

    Step to migrate Oracle RAC CRS resources to new server.

    Post  Pat on Mon Jul 04, 2011 6:18 am

    Below script generate svrctl add script for database, instance, service and 11G listeners from OCR from current RAC.

    Save the result of the script and run it at new RAC.

    Code:

    for DBNAME in $(srvctl config database)
    do

    #      Generate DB resource

            srvctl config database -d $DBNAME -a | awk -v dbname="$DBNAME" \
            'BEGIN { FS=":" }
            $1~/Oracle home/ || $1~/ORACLE_HOME/ {dbhome = "-o" $2}
            $1~/Spfile/ || $1~/SPFILE/ {spfile = "-p" $2}
            $1~/Disk Groups/ {dg = "-a" $2}
            END { if (avail == "-a ") {avail = ""}; printf "%s %s %s %s %s\n", "srvctl add database -d ", dbname, dbhome, spfile, dg }'

    #      Generate Instance resource

            srvctl status database -d $DBNAME | awk -v dbname="$DBNAME" \
            '$4~/running/ { printf "%s %s %s %s %s %s\n", "srvctl add instance -d ",dbname, " -i ", $2 ," -n ", $7 }
            $5~/running/ { printf "%s %s %s %s %s %s \n", "srvctl add instance -d ",dbname, " -i ", $2 ," -n ", $8 }'

    #   Modify instance for 10G - ASM dependency

       if [ $(echo $ORACLE_HOME | grep "1020" | wc -l ) -eq 1 ]
       then
         srvctl status database -d $DBNAME | awk -v dbname="$DBNAME" \
         '$2~/1$/ { printf "%s %s %s %s %s \n", "srvctl modify instance -d ",dbname, " -i ", $2 ," -s +ASM1" }
         $2~/2$/ { printf "%s %s %s %s %s \n", "srvctl modify instance -d ",dbname, " -i ", $2 ," -s +ASM2" }
         $2~/3$/ { printf "%s %s %s %s %s \n", "srvctl modify instance -d ",dbname, " -i ", $2 ," -s +ASM3" }
         $2~/4$/ { printf "%s %s %s %s %s \n", "srvctl modify instance -d ",dbname, " -i ", $2 ," -s +ASM4" }'
       fi

       echo "srvctl start database -d $DBNAME"

    #      Generate Service resource

            snamelist=$(srvctl status service -d $DBNAME | awk '{print $2}')

            for sname in $snamelist
            do
              srvctl config service -d $DBNAME -s $sname| awk -v dbname="$DBNAME" -v sname=$sname \
              'BEGIN { FS=":"}
              $1~/Preferred instances/ {pref = "-r" $2}
              $1~/PREF/ {pref = "-r" $2; sub(/AVAIL/, "",  pref) }
              $1~/Available instances/ {avail = "-a" $2}
              $2~/AVAIL/ {avail = "-a" $3}
              $1~/Failover type/ {ft = "-e" $2}
              $1~/Failover method/ {fm = "-m" $2}
              $1~/Runtime Load Balancing Goal/ {g = "-B" $2}
              END { if (avail == "-a ") {avail = ""}; printf "%s %s %s %s %s %s %s %s %s %s\n", "srvctl add service -d ",dbname, "-s ", sname, pref, avail ,ft, fm,g, "-P BASIC"}'
       echo "srvctl start service -d $DBNAME -s $sname"
            done
    done

    #   Listener at 11G Home. 10G listener can't ba added with srvctl.


       srvctl config listener | awk \
         'BEGIN { FS=":"; state = 0; }
         $1~/Name/ {lname = "-l" $2; state=1};
         $1~/Home/ && state == 1 {ohome = "-o" $2; state=2;}
         $1~/End points/ && state == 2 {lport = "-p " $3; state=3;}
         state == 3 {if (ohome != "-o <CRS home>") {printf "%s %s %s %s\n", "srvctl add listener ", lname, ohome, lport;} state=0;}'


      Current date/time is Fri Jul 21, 2017 4:33 am