Tuesday, March 16, 2021

Oracle Rac gpnp profile and gpnptool

 

What is GPnP profile and Why it is needed?

In Oracle 11g R2 RAC, we can store OCR and Voting disk in ASM, but clusterware needs OCR and Voting disk to start CRSD and CSSD process but point is, both OCR and Voting disk are stored in ASM, which itself  is a resource for the nodes that means CRSD and CSSD process needs the OCR and Voting file before the ASM startup. So the question arise ” how the clusterware will start?”, we shall find the answer of this question in this same document, just wait..

To resolve this issue Oracle introduced two new node specific files OLR & GPnP, in Oracle 11g R2.

Now If we talk about GPnP profile, This GPnP profile is a new feature included in Oracle 11g R2.The GPnP profile is a small XML file located in

$GRID_HOME/gpnp//profiles/peer with name profile.xml.   

Each node of the cluster maintains a local copy of this profile and is maintained by GPnP daemon along with mdns daemon . GPnP deamon ensures the synchronization of  GPnP profile across all the nodes in the cluster and GPnP profile is used by clusterware to establish the correct global personality of a node. it cannot be stored on ASM as it is required prior to start of ASM. Hence, it is stored locally on each node and is kept synchronized across all the nodes by GPnPd.

Local copy of Gpnp profile is stored under <GRID_HOME/gpnp/<hostname>/profiles/peer as profile.xml


How does GPnP Profile used ?:

When a node of an Oracle Clusterware cluster restarts, OHASD is started by platform-specific means, OHASD has access to the OLR (Oracle Local Registry) stored on the local file system. OLR provides needed data to complete OHASD initialization. OHASD brings up GPnP Daemon and CSS Daemon. CSS Daemon has access to the GPNP Profile stored on the local file system. The information regarding voting disk is on ASM , is read from GPnP profile i.e. 

We can even read voting disk by using kfed utility ,even if ASM is not up.

In next step, the clusterware checks whether all the nodes have the updated GPnP profile and the nodes joins the cluster based on the GPnP configuration . Whenever a node is started or added to the cluster, the clusterware software on the starting node starts a GPnP agent and perform following task.

  1. If the node is already part of the cluster, the GPnP agent reads the existing profile on that node.
  2. If the node is being added to the cluster, GPnP agent locates agent on another existing node using multicast protocol (provided by mDNS) and gets the profile from other node’s GPnP agent.

The Voting Files locations on ASM Disks are accessed by CSSD with well-known pointers in the ASM Disk headers and CSSD is able to complete initialization and start or join an existing cluster.

Now OHASD starts an ASM instance and ASM can now operate with initialized and operating CSSD.

With, an ASM instance running and its Diskgroup mounted, access to Clusterware’s OCR is available to CRSD (CRSD needs to read OCR to startup various resources on the node and hence update it, as status of resources changes )Now OHASD starts CRSD with access to the OCR in an ASM Diskgroup and thus Clusterware completes initialization and brings up other services under its control.

The ASM instance uses special code to locate the contents of the ASM SPFILE , which is stored in a Diskgroup.

Next. Since OCR is also on ASM, location of ASM spfile should be known. The order of searching the ASM SPfile is

  • GPnP profile
  • ORACLE_HOME/dbs/spfile
  • ORACLE_HOME/dbs/init

ASM spfile is stored in ASM. But to start ASM, we’ll need spfile.  Oracle know spfile  location from GPnP profile & it reads spfile flag from underlying disk(s) and then starts the ASM.

Thus with the use of GPnP profile stores several information. GPnP profile information along with the information in the OLR have enough information , that have sufficient to automate several tasks or eased for the administrators and also the dependency on OCR is gradually reduced but not eliminated.


Who and When GPNP PROFILE UPDATES? :

GPnP daemon replicates changes to the profile during

  • installation
  • system boot
  • when system updated using standard cluster tools

Profile is automatically updated Whenever changes are made to a cluster during installation and with configuration tools like

  • oifcfg (Change network),
  • crsctl (change location of voting disk),
  • asmcmd (change ASM_DISKSTRING, spfile location) etc.



What Information GPnP Profile Contains:

GPnP profile defines a node’s metadata about:

  • Cluster Name
  • Network interfaces for public and private interconnect
  • ASM server parameter file Location and ASM Diskstring etc.
  • CSS voting disks Discovery String
  • Digital Signature Information

it contains digital signature information of the provisioning authority because the profile is security sensitive. It might identify the storage to be used as the root partition of a machine. This profile is protected by a wallet against modification. As in my case the WALLET information can be found in : /u01/app/11.2.0/grid/gpnp/paw-racnode1/wallets/peer  “OR” /u01/app/11.2.0/grid/gpnp/wallets/peer .

If you have to manually modify the profile, it must first be unsigned with $GRID_HOME/bin/gpnptool, modified, and then signed again with the same utility, however there is a very slight chance you would ever be required to do so.

Now we can use the gpnptool with get option to dump this xml file into standard output. Below is the formatted output .

[grid@paw-racnode1 peer]$ pwd

/u01/app/11.2.0/grid/gpnp/paw-racnode1/profiles/peer


gpnptool command:
================= 
gpnptool edit -p=/u01/app/12.1.0.2/grid/gpnp/<hostname>profiles/peer/profile.xml -o=/u01/app/12.1.0.2/grid/gpnp/<hostname>profiles/peer/profile.xml -ovr -prf_sq=2 -net1:net_use=public -net1:net_ip=10.232.71.0 -net1:net_ada=ipmp0

if we want to specifically change network adapter alone, then user below command.
gpnptool edit -p=/u01/app/12.1.0.2/grid/gpnp/<hostname>profiles/peer/profile.xml -o=/u01/app/12.1.0.2/grid/gpnp/<hostname>profiles/peer/profile.xml -ovr -prf_sq=2 -net1:net_ada=ipmp0

Sign the profile :
gpnptool sign -p=/u01/app/12.1.0.2/grid/gpnp/<hostname>profiles/peer/profile.xml -o=/u01/app/12.1.0.2/grid/gpnp/<hostname>profiles/peer/profile.xml -ovr -w= -net1:net_ada
=ipmp0

[grid@paw-racnode1 peer]$ gpnptool get

Warning: some command line parameters were defaulted. Resulting command line:

         /u01/app/11.2.0/grid/bin/gpnptool.bin get -o-

<?xml version=”1.0″ encoding=”UTF-8″?><gpnp:GPnP-Profile Version=”1.0″ xmlns=”http://www.grid-pnp.org/2005/11/gpnp-profile” xmlns:gpnp=”http://www.grid-pnp.org/2005/11/gpnp-profile” xmlns:orcl=”http://www.oracle.com/gpnp/2005/11/gpnp-profile” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://www.grid-pnp.org/2005/11/gpnp-profile gpnp-profile.xsd” ProfileSequence=”5″ ClusterUId=”1c12005940a3efa8bf244ccd47060927″ ClusterName=”paw-rac-cluster PALocation=””><gpnp:Network-Profile><gpnp:HostNetwork id=”gen” HostName=”*”><gpnp:Network id=”net1″ IP=”192.168.75.0″ Adapter=”eth0″ Use=”public”/><gpnp:Network id=”net2″ IP=”10.0.0.0″ Adapter=”eth1″ Use=”cluster_interconnect”/></gpnp:HostNetwork></gpnp:Network-Profile><orcl:CSS-Profile id=”css” DiscoveryString=”+asm” LeaseDuration=”400″/><orcl:ASM-Profile id=”asm” DiscoveryString=”/dev/oracleasm/disks” SPFile=”+DATA/paw-rac-cluster/asmparameterfile/registry.253.919259819″/><ds:Signature xmlns:ds=”http://www.w3.org/2000/09/xmldsig#”><ds:SignedInfo><ds:CanonicalizationMethod Algorithm=”http://www.w3.org/2001/10/xml-exc-c14n#”/><ds:SignatureMethod Algorithm=”http://www.w3.org/2000/09/xmldsig#rsa-sha1″/><ds:Reference URI=””><ds:Transforms><ds:Transform Algorithm=”http://www.w3.org/2000/09/xmldsig#enveloped-signature”/><ds:Transform Algorithm=”http://www.w3.org/2001/10/xml-exc-c14n#”> <InclusiveNamespaces xmlns=”http://www.w3.org/2001/10/xml-exc-c14n#” PrefixList=”gpnp orcl xsi”/></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm=”http://www.w3.org/2000/09/xmldsig#sha1″/><ds:DigestValue>HIz8dOjUIFB32YPkmXW2HMVazoY=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>L6GOD0rB03Hp+NoKVcIHb9/Rp3xznBKpUJGfixN/27Qo6IL8/4HkjSnzsbHf1IuK1SQfqV5624tygB0x9HJfVcW+k6E6cQWwAgZOzpPR3ltctD7XeikkXtt5TOWQ6boMvCKJ5mOwzGzuj4S/qDu7lWPBHM9EPzHAEn/8NOlDcDo=</ds:SignatureValue></ds:Signature></gpnp:GPnP-Profile>

Success.


[grid@paw-racnode1 peer]$  gpnptool show Mode="remote"


[grid@paw-racnode1 peer]$ gpnptool getpval -asm_spf

Warning: some command line parameters were defaulted. Resulting command line:

         /u01/app/11.2.0/grid/bin/gpnptool.bin getpval -asm_spf -p=profile.xml -o-

+DATA/paw-rac-cluster/asmparameterfile/registry.253.919259819


 [grid@paw-racnode1 peer]$ gpnptool getpval -asm_dis

Warning: some command line parameters were defaulted. Resulting command line:

         /u01/app/11.2.0/grid/bin/gpnptool.bin getpval -asm_dis -p=profile.xml -o-

/dev/oracleasm/disks


[grid@paw-racnode1 peer]$ gpnptool find

 Found 2 instances of service ‘gpnp’.

        mdns:service:gpnp._tcp.local.://paw-racnode2:64098/agent=gpnpd,cname=paw-rac-cluster,host=paw-racnode2,pid=6444/gpnpd h:paw-racnode2 c:paw-rac-cluster

        mdns:service:gpnp._tcp.local.://paw-racnode1:55790/agent=gpnpd,cname=paw-rac-cluster,host=paw-racnode1,pid=6677/gpnpd h:paw-racnode1 c:paw-rac-cluster


[grid@racp1vm1 ~]$ gpnptool get -o- | xmllint --format - | grep SPFile

Success.

  <orcl:ASM-Profile id="asm" DiscoveryString="" SPFile="+CRS_DG/ws-dbi-scan1/ASMPARAMETERFILE/registry.253.905527691" Mode="remote"/>



Fix a wrong entry profile.xml and redistribute the fixed profile with gpnptool put

The GI caches the profile.xml in multiple places in addition to the profile.xml file under ($GRID_HOME/gpnp/$HOSTNAME/profiles/peer/profile.xml) and the OCR. The OLR($GRID_HOME/cdata/$HOSTNAME.olr) is another location

When gpnpd tries to come up, it looks for the “best profile” from these 3 locations (olr,ocr,profile.xml). And my understanding of the “best profile” is the profile with the highest ProfileSequence). And this “best profile” then overwrites the other cached lower versions.

Assume we have a wrong ASM SPFILE entry in our current profile.xml

[grid@grac41 peer]$ cd /u01/app/11204/grid/gpnp/grac41/profiles/peer/
Current status:
profile.xml
ProfileSequence="10"  
SPFile="$GRID_HOME/dbs/spfileCopyASM_nogo" <--- wrong 


Copy the profile to profile.bak and  remove the oracle signature
[grid@grac41 peer]$  cp profile.xml profile.bak 
[grid@grac41 peer]$  gpnptool unsign -p=profile.bak

Warning: some command line parameters were defaulted. Resulting command line: 
         /u01/app/11204/grid/bin/gpnptool.bin unsign -p=profile.bak -o-
<?xml version="1.0" encoding="UTF-8"?><gpnp:GPnP-Profile Version="1.0" xmlns="http://www.grid-pnp.org/2005/11/gpnp-profile" 
 xmlns:gpnp="http://www.grid-pnp.org/2005/11/gpnp-profile" xmlns:orcl="http://www.oracle.com/gpnp/2005/11/gpnp-profile" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.grid-pnp.org/2005/11/gpnp-profile gpnp-profile.xsd" 
 ProfileSequence="10" ClusterUId="09a8e930abf56f66bfbdb0b7c915cfa8" ClusterName="grac4" PALocation=""><gpnp:Network-Profile>
<gpnp:HostNetwork id="gen" HostName="*"><gpnp:Network id="net1" IP="192.168.1.0" Adapter="eth1" Use="public"/>
<gpnp:Network id="net2" IP="192.168.2.0" Adapter="eth2" Use="cluster_interconnect"/></gpnp:HostNetwork></gpnp:Network-Profile>
<orcl:CSS-Profile id="css" DiscoveryString="+asm" LeaseDuration="400"/><orcl:ASM-Profile id="asm" DiscoveryString="/dev/asm*,/dev/oracleasm/disks/*" 
 SPFile="$GRID_HOME/dbs/spfileCopyASM_nogo"/></gpnp:GPnP-Profile>
Success.
--> Current ProfileSequence="10" 



Update SPFILE in profile.bak and increase ProfileSequence to 11 

[grid@grac41 peer]$ gpnptool edit -asm:asm_spf='+OCR/grac4/asmparameterfile/spfileCopyASM.ora'   -p=profile.bak -o=profile.bak -ovr  -prf_sq=11
Resulting profile written to "profile.bak".
Success.



Verify profile.bak and check whether ASM SPFILE location is valid 
ProfileSequence="11"  
SPFile="+OCR/grac4/asmparameterfile/spfileCopyASM.ora"
[grid@grac41 peer]$ asmcmd ls -l  +OCR/grac4/asmparameterfile/spfileCopyASM.ora
Type              Redund  Striped  Time             Sys  Name
                                                    N    spfileCopyASM.ora => +OCR/grac4/asmparameterfile/REGISTRY.253.842605053



Sign profile 
$  gpnptool sign -p=profile.bak -w=file:/u01/app/11204/grid/gpnp/grac41/wallets/peer -o=profile.new
Resulting profile written to "profile.new".
Success.

Redistribute profile.xml 
[grid@grac41 peer]$ gpnptool put  -p=$GRID_HOME/gpnp/grac41/profiles/peer/profile.new
Success.


Verfy GPND profile on  all Nodes ( check for ProfileSequence and  SPFile )
$  gpnptool rget
Warning: some command line parameters were defaulted. Resulting command line: 
         /u01/app/11204/grid/bin/gpnptool.bin rget -o-
Found 3 gpnp service instance(s) to rget profile from.
RGET from tcp://grac41:47588 (mdns:service:gpnp._tcp.local.://grac41:47588/agent=gpnpd,cname=grac4,host=grac41,pid=27693/gpnpd h:grac41 c:grac4):
<?xml version="1.0" encoding="UTF-8"?><gpnp:GPnP-Profile Version="1.0" xmlns="http://www.grid-pnp.org/2005/11/gpnp-profile" 
   xmlns:gpnp="http://www.grid-pnp.org/2005/11/gpnp-profile" xmlns:orcl="http://www.oracle.com/gpnp/2005/11/gpnp-profile" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.grid-pnp.org/2005/11/gpnp-profile gpnp-profile.xsd" 
   ProfileSequence="11" ClusterUId="09a8e930abf56f66bfbdb0b7c915cfa8" ClusterName="grac4" PALocation="">
  <gpnp:Network-Profile><gpnp:HostNetwork id="gen" HostName="*"><gpnp:Network id="net1" IP="192.168.1.0" Adapter="eth1" Use="public"/>
  <gpnp:Network id="net2" IP="192.168.2.0" Adapter="eth2" Use="cluster_interconnect"/></gpnp:HostNetwork></gpnp:Network-Profile>
   <orcl:CSS-Profile id="css" DiscoveryString="+asm" LeaseDuration="400"/><orcl:ASM-Profile id="asm" DiscoveryString="/dev/asm*,/dev/oracleasm/disks/*" 
   SPFile="+OCR/grac4/asmparameterfile/spfileCopyASM.ora"/><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
  <ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><ds:Reference URI=""><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"> <InclusiveNamespaces xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="gpnp orcl xsi"/></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>ALIJdwPKQGRB8BKcoiUsxzXw1xw=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>aV1ueSkHquo2P0MN1HnOLKRXTyQljz8MMlAo+WhRVMlrDQev2DketkJ+H00aTFUXyX9A05VVyNWD9ZsglDQqk/13joh1Qz5LjtvQ3Ei5V9FhGnUUofY4MKduT89Cbic5kql0xvUlvsapez7utaq+5ecYJDLBCrH15c/WBnsOtm8=</ds:SignatureValue></ds:Signature></gpnp:GPnP-Profile>
Success.
RGET from tcp://grac43:55100 (mdns:service:gpnp._tcp.local.://grac43:55100/agent=gpnpd,cname=grac4,host=grac43,pid=5193/gpnpd h:grac43 c:grac4):
<?xml version="1.0" encoding="UTF-8"?><gpnp:GPnP-Profile Version="1.0" ...
 ProfileSequence="11" 
 .. 
 SPFile="+OCR/grac4/asmparameterfile/spfileCopyASM.ora"/>
...
RGET from tcp://grac42:37261 (mdns:service:gpnp._tcp.local.://grac42:37261/agent=gpnpd,cname=grac4,host=grac42,pid=4974/gpnpd h:grac42 c:grac4):
<?xml version="1.0" encoding="UTF-8"?><gpnp:GPnP-Profile Version="1.0" ...
 ProfileSequence="11" 
 .. 
 SPFile="+OCR/grac4/asmparameterfile/spfileCopyASM.ora"/> ...


Thursday, March 4, 2021

Oracle Awr data dump -- Very important while migration


















Most of time after migration  of database to new server we observe performance degradation . Usually we dont have historical performance data before migration which land us is big mess.

To overcome this , its very important to  take awr dump from existing database before migration . 


Extract AWR data

For Extract the AWR data from source database run the awrextr.sql script which extracts AWR data for a range of snapshots from the database into a Data Pump export file.
 
1. Run the following script for extract AWR:
@?/rdbms/admin/awrextr.sql;


2. Script ask for select DBID
Enter value for dbid:

3. Enter the number of days backup export:
Enter value for num_days: 2

4. It will list the 2 days snapshot in AWR. Choose the begin and end snapshot for export:
Enter value for begin_snap: 76
Begin Snapshot Id specified: 76
Enter value for end_snap: 86
End Snapshot Id specified: 86

5. List the Directory present in Database, Choose the directory location and dump file name:
Enter value for directory_name: ORACLE_HOME
.....
.....

Enter value for file_name:
awrdat_76_86.dmp

6. Now dump is generated.
The AWR extract dump file will be located
| in the following directory/file:
| /usr/tmp/
| awrdat_76_86.dmp



Load the AWR data to target

For loading the extracted AWR data with awrload.sql script. It will first create a staging schema where the snapshot data is transferred
from the Data Pump file into the database

1. Run the AWRload.sql script for start loading data.

@?/rdbms/admin/awrload.sql

2. Specify the directory name where export file exists.

Enter value for directory_name:

3. Put the prefix of name of dump file:

Enter value for file_name:

4. Specify the name of staging schema where data loaded i.e AWRSTAGE

Enter value for schema_name:

5. Specify the default or temporary tablespace.

Enter value for default_tablespace: SYSAUX
-----------
Enter value for temporary_tablespace: TEMP

6. Loading of data is successful.

*** AWR Load Started ...

|
| This operation will take a few moments. The
| progress of the AWR load operation can be
| monitored in the following directory/file:
| /usr/tmp/
| AWRDAT_76_86.log



The process will then prompt for the staging schema name, the default is AWR_STAGE. If you accept the default, the script will create the AWR_STAGE user after asking you for default tablespaces. Once it has completed the awr load process, the script will drop the AWR_STAGE user.

After the process completes, the AWR tables now have new data in them! You can query DBA_HIST_SNAPSHOT or any of the other DBA_HIST views (including DBA_HIST_ACTIVE_SESS_HISTORY).