Thursday, December 14, 2023

WebADI Create Document Redirects From HTTP To HTTPS Causing Error ERR_SSL_PROTOCOL_ERROR

SYMPTOMS

On Oracle EBS R12.2 the default URL is HTTP:// but when you navigate to Desktop Integrator -> 

Create Document the URL of the webpage redirects to HTTPS://.

STEPS

1) Using the Desktop Integrator responsibility.

2) Navigate to create document.

3) Select the Integrator, Layout and populate needed parameters.

4) Select Creating document and view the URL that is returned to create the document is https and not http.

The following error is seen in the browser window when attempting to create the document:

This site can't provide a secure connection. ERR_SSL_PROTOCOL_ERROR

 Due to this issue, the document is not created.

SOLUTION

1) View the following line in the XML context file: <sslterminator oa_var=

2) If the current value is <sslterminator oa_var=”s_enable_sslterminator”>#</sslterminator>

Please change the following line in the XML context file: 

FROM: <sslterminator oa_var=”s_enable_sslterminator”>#</sslterminator> 

TO: <sslterminator oa_var=”s_enable_sslterminator”/>

3) Run the Autoconfig.

4) Restart the Services and Re-test.

Note: that if the XML context file line value is already

<sslterminator oa_var=”s_enable_sslterminator”/>, 

then modify the line to 

<sslterminator oa_var=”s_enable_sslterminator”>#</sslterminator>

follow the same steps as above and re-test. 

Take backup of $CONTEXT_FILE

cd $CONTEXT_FILE

cd /apps/R12.2.10/fs2/inst/apps/test/appl/admin/test_oracle.xml

Replace sslterminator value in $CONTEXT_FILE

From

<sslterminator oa_var="s_enable_sslterminator"/>

TO

<sslterminator oa_var="s_enable_sslterminator">#</sslterminator>

save it.

[applmgr@oracle~#]cd $ADMIN_SCRIPTS_HOME

./adautocfg.sh

Start appslication service

[applmgr@oracle~#]cd $ADMIN_SCRIPTS_HOME

./adstrtal.sh apps/*****

Retest issue.

Friday, November 24, 2023

Relink Oracle Grid Infrastructure RAC/Cluster Installation

After installing Oracle Grid Infrastructure for a cluster (Oracle Clusterware and Oracle ASM configured for a cluster), if you need to modify the binaries, then use the following procedure, where Grid_home is the Oracle Grid Infrastructure for a cluster home. Relink the Oracle Grid Infrastrucutre, Oracle Restart and Oracle ASM binaries every time you apply an operating system patch or after an operating system upgrade.

Caution:Before relinking executables, you must shut down all executables that run in the Oracle home directory that you are relinking. In addition, shut down applications linked with Oracle shared libraries. If present, unmount all Oracle Automatic Storage Management Cluster File System (Oracle ACFS) filesystems.

You must relink the Oracle Clusterware and Oracle ASM binaries every time you apply an operating system patch or after you perform an operating system upgrade that does not replace the root file system. For an operating system upgrade that results in a new root file system, you must remove the node from the cluster and add it back into the cluster.

For upgrades from previous releases, if you want to deinstall the prior release Grid home, then you must first unlock the prior release Grid home. Unlock the previous release Grid home by running the command rootcrs.sh -unlock from the previous release home. After the script has completed, you can run the deinstall command.

 1. As root user first stop CRS

# crsctl stop crs

2. As root user, unlock the Grid Infrastructure Oracle Home (on every node) as follows:

# cd < Grid Infrastructure Oracle Home >/crs/install

# perl rootcrs.pl -unlock

Note: On 12.1/12.2/19c releases, rootcrs.sh can be used instead of rootcrs.pl. Command as 

rootcrs.sh -unlock

Note: On 12c/21c <GI_HOME>/crs/install/rootcrs.sh -prepatch can be used to stop and unlock the GI home -- clusterware must be up and running to use this option

3. As the Oracle Grid Infrastructure owner (on every node) relink the Grid Infrastructure Oracle Home as follows:

$ export ORACLE_HOME=< Grid Infrastructure Oracle Home >

$ < Grid Infrastructure Oracle Home>/bin/relink all

4. As root OS user again, please execute the next commands (on every node):

# cd < Grid Infrastructure Oracle Home >/rdbms/install/

# ./rootadd_rdbms.sh

# cd < Grid Infrastructure Oracle Home >/crs/install

# perl rootcrs.pl -patch

Note: On 12.1, use "rootcrs.sh -patch".

Note: On 12.2/21c, use "rootcrs.sh -lock" then "crsctl start crs"

Note: On 12/21c <GI_HOME>/crs/install/rootcrs.sh -postpatch can be used to start and lock the GI home

Note: CRS services (CRS, CSS ASM instances, diskgroups, listeners, DB instances, etc.) will automatically start.

5. Review relink.log file located at the following directory (to confirm or discard any error):

$ < Grid Infrastructure Oracle Home>/install/relink.log











Tuesday, October 24, 2023

Convert Oracle DR Physical Standby DB To Snapshot Standby (Read Write Mode)

 An Oracle Snapshot Standby Database allows to perform read-write operation on the standby database i.e., converting the physical standby to snapshot standby database. On the snapshot standby database we can do all types of testing or it can be used as a development database. Once testing is over we can convert the snapshot standby database back to physical standby database and any changes done to the snapshot standby will be reverted. A snapshot standby database receives and archives redo data but it does not apply the redo data from the primary database. FRA (Fast Recovery Area) using parameters db_recovery_file_dest and db_recovery_file_dest_size must be configured in physical standby database but it is not necessary to have flashback enabled.

Snapshot Standby Database Architecture


1. Make sure flashback is on on standby database.

SQL> show parameter db_recovery
db_recovery_file_dest = +FRA
db_recovery_file_dest_size=222G

SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
NO

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ ONLY WITH APPLY

SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-01153: an incompatible media recovery is active

SQL> recover managed standby database cancel;
Media recovery complete.

SQL> alter database flashback on;
Database altered.

SQL>  select flashback_on from v$database;

FLASHBACK_ON
------------------
YES

SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.

2. Check the configuration:
Check the configuration, if any issues are there, then fix it before proceeding further.

DGMGRL>  show configuration
DGMGRL> validate database MYDBDR
DGMGRL> show configuration

Configuration - dg_config_mydb
  Protection Mode: MaxPerformance
  Members:
  MYDB      - Primary database
    MYDBDR    - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS   (status updated 6 seconds ago)

3. Convert physical to snapshot standby.

DGMGRL> convert database MYDBDR to snapshot standby;
Converting database "MYDBDR" to a Snapshot Standby database, please wait...
Database "MYDBDR" converted successfully

DGMGRL> show configuration

Configuration - dg_config_mydb
  Protection Mode: MaxPerformance
  Members:
  MYDB      - Primary database
    MYDBDR    - Snapshot standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS   (status updated 52 seconds ago)

SQL> select open_mode,database_role from v$database;

OPEN_MODE            DATABASE_ROLE
READ WRITE           SNAPSHOT STANDBY

Now the database is open in read write mode. So you can do any changes or testing on the database.
Once your activity is done, you can revert it back to physical standby using below command.

4. Convert snapshot standby back to physical standby



DGMGRL> convert database MYDBDR to physical standby;
Converting database "MYDBDR" to a Physical Standby database, please wait...
Operation requires a connection to database "ne"
Connecting ...
Connected to "MYDB"
Connected as SYSDBA.
Oracle Clusterware is restarting database "MYDBDR" ...
Connected to "MYDBDR"
Connected to "MYDBDR"
Continuing to convert database "MYDBDR" ...
Database "MYDBDR" converted successfully

DGMGRL> show configuration;

Configuration - dg_config_mydb
  Protection Mode: MaxPerformance
  Members:
  MYDB      - Primary database
   MYDBDR    - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS   (status updated 4 seconds ago)

Thursday, September 14, 2023

Symmetric & Asymmetric Encryption

Symmetric encryption involves using a single key to encrypt and decrypt data, while asymmetric encryption uses two keys - one public and one private - to encrypt and decrypt data. Each type of encryption has its own strengths and weaknesses, and the choice between the two depends on the specific needs of the user. As I have recently configured HTTPS TLS for EBS 12.2 environment we have to use asymmetric encryption method with RSA algorithm to encryt the data on Transport Layer where TLS termination was set at OHS Oracle HTTP Server Level. Check this post Blog for DBA Consultants: August 2023 (samiora.blogspot.com) for high level steps to configure TLS for EBS 12.2 environment.  

When it comes to encryption, the latest schemes may necessarily the best fit. You should always use the encryption algorithm that is right for the task at hand. In fact, as cryptography takes a new shift, new algorithms are being developed in a bid to catch up with the eavesdroppers and secure information to enhance confidentiality. Hackers are bound to make it tough for experts in the coming years, thus expect more from the cryptographic community!


Example of SYMMETRIC Encryption on a Linux Server using gpg utility

[root@myLinuxVM ~]# pwd

/root

[root@myLinuxVM ~]# mkdir Desktop


[root@myLinuxVM ~]# cd Desktop/


[root@myLinuxVM Desktop]# touch MyEncryptfile.txt


[root@myLinuxVM Desktop]# echo "Hello World This is a test" > MyEncryptfile.txt


[root@myLinuxVM Desktop]# cat MyEncryptfile.txt

Hello World This is a test


[root@myLinuxVM Desktop]# gpg -c MyEncryptfile.txt

 

                          lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk

                          x Enter passphrase                                    x

                          x                                                     x

                          x                                                     x

                          x Passphrase *********_______________________________ x

                          x                                                     x

                          x       <OK>                             <Cancel>     x

                          mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

 

 

                          lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk

                          x Please re-enter this passphrase                     x

                          x                                                     x

                          x Passphrase *********_______________________________ x

                          x                                                     x

                          x       <OK>                             <Cancel>     x

                          mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

 

[root@myLinuxVM Desktop]# gpg -c MyEncryptfile.txt

gpg: directory `/root/.gnupg' created

gpg: new configuration file `/root/.gnupg/gpg.conf' created

gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run

gpg: keyring `/root/.gnupg/pubring.gpg' created

 

[root@myLinuxVM Desktop]# ls -ltr

-rw-r--r--. 1 root root 27 Aug 30 13:12 MyEncryptfile.txt

-rw-r--r--. 1 root root 82 Aug 30 13:24 MyEncryptfile.txt.gpg

 

[root@myLinuxVM Desktop]# more MyEncryptfile.txt.gpg

t▒▒QDE▒▒Ads}R▒\▒q▒▒"s▒▒▒v]&;̘(▒;Lp▒▒▒)(▒d7▒G6`xN▒d▒▒P▒▒

 

[root@myLinuxVM Desktop]# gpg -o MyEncryptfile.txt MyEncryptfile.txt.gpg

gpg: keyring `/root/.gnupg/secring.gpg' created

gpg: CAST5 encrypted data

gpg: encrypted with 1 passphrase

File `MyEncryptfile.txt' exists. Overwrite? (y/N) y

gpg: WARNING: message was not integrity protected

 

[root@myLinuxVM Desktop]# ls -ltr

total 8

-rw-r--r--. 1 root root 82 Aug 30 13:24 MyEncryptfile.txt.gpg

-rw-r--r--. 1 root root 27 Aug 30 13:36 MyEncryptfile.txt

 

[root@myLinuxVM Desktop]# more MyEncryptfile.txt.gpg

t▒▒QDE▒▒Ads}R▒\▒q▒▒"s▒▒▒v]&;̘(▒;Lp▒▒▒)(▒d7▒G6`xN▒d▒▒P▒▒

 

[root@myLinuxVM Desktop]# more MyEncryptfile.txt

Hello World This is a test

 

[root@myLinuxVM Desktop]# gpg -o MyEncryptfile_DECRYPTED.txt MyEncryptfile.txt.gpg

gpg: CAST5 encrypted data

gpg: encrypted with 1 passphrase

gpg: WARNING: message was not integrity protected

 

[root@myLinuxVM Desktop]# ls -ltr

total 12

-rw-r--r--. 1 root root 82 Aug 30 13:24 MyEncryptfile.txt.gpg

-rw-r--r--. 1 root root 27 Aug 30 13:36 MyEncryptfile.txt

-rw-r--r--. 1 root root 27 Aug 30 13:37 MyEncryptfile_DECRYPTED.txt

 

[root@myLinuxVM Desktop]# more MyEncryptfile_DECRYPTED.txt

Hello World This is a test




Example of an Asymmetric Encryption using private and public keys on a linux server using openssl utility,

[root@myLinuxVM Desktop]# mkdir ASSYMETTRIC


[root@myLinuxVM Desktop]# cd ASSYMETTRIC/


[root@myLinuxVM ASSYMETTRIC]# openssl genrsa -out test_private_key.pem 1024

Generating RSA private key, 1024 bit long modulus

............................++++++

..++++++

e is 65537 (0x10001)


[root@myLinuxVM ASSYMETTRIC]# ls -ltr

-rw-r--r--. 1 root root 887 Aug 30 13:56 test_private_key.pem


[root@myLinuxVM ASSYMETTRIC]# openssl rsa -in test_private_key.pem -out test_public_key.pem -outform PEM -pubout

writing RSA key


[root@myLinuxVM ASSYMETTRIC]# ls -ltr

-rw-r--r--. 1 root root 887 Aug 30 13:56 test_private_key.pem

-rw-r--r--. 1 root root 272 Aug 30 13:57 test_public_key.pem


[root@myLinuxVM ASSYMETTRIC]# echo "Hello world This is ASSYMETTRIC ENCYPTION TEST BY SAMI MALIK" > MyEncryptFile.txt


[root@myLinuxVM ASSYMETTRIC]# ls -ltr

-rw-r--r--. 1 root root 887 Aug 30 13:56 test_private_key.pem

-rw-r--r--. 1 root root 272 Aug 30 13:57 test_public_key.pem

-rw-r--r--. 1 root root  61 Aug 30 14:00 MyEncryptFile.txt


[root@myLinuxVM ASSYMETTRIC]# more MyEncryptFile.txt

Hello world This is ASSYMETTRIC ENCYPTION TEST BY SAMI MALIK


[root@myLinuxVM ASSYMETTRIC]# openssl rsautl -encrypt -inkey test_public_key.pem -pubin -in MyEncryptFile.txt -out asymmetric_encrypt.dat


[root@myLinuxVM ASSYMETTRIC]# ls -ltr

-rw-r--r--. 1 root root 887 Aug 30 13:56 test_private_key.pem

-rw-r--r--. 1 root root 272 Aug 30 13:57 test_public_key.pem

-rw-r--r--. 1 root root  61 Aug 30 14:00 MyEncryptFile.txt

-rw-r--r--. 1 root root 128 Aug 30 14:01 asymmetric_encrypt.dat


[root@myLinuxVM ASSYMETTRIC]# more asymmetric_encrypt.dat

▒▒v▒▒▒ |▒.▒L▒▒▒-9▒P▒▒8Z▒▒▒IX▒s▒^L▒      ▒i▒▒▒]▒ Ê▒▒M7R▒▒A!▒▒▒q^j▒▒&Q▒_!6▒▒i▒Ê¡)[qi▒▒l▒ee▒▒c▒▒▒R▒"▒@▒%O▒(fH▒Ke7


[root@myLinuxVM ASSYMETTRIC]# openssl rsautl -decrypt -inkey test_private_key.pem -in asymmetric_encrypt.dat -out asymmetric_decrypt.txt


[root@myLinuxVM ASSYMETTRIC]# ls -ltr

-rw-r--r--. 1 root root 887 Aug 30 13:56 test_private_key.pem

-rw-r--r--. 1 root root 272 Aug 30 13:57 test_public_key.pem

-rw-r--r--. 1 root root  61 Aug 30 14:00 MyEncryptFile.txt

-rw-r--r--. 1 root root 128 Aug 30 14:01 asymmetric_encrypt.dat

-rw-r--r--. 1 root root  61 Aug 30 14:02 asymmetric_decrypt.txt


[root@myLinuxVM ASSYMETTRIC]# more asymmetric_decrypt.txt

Hello world This is ASSYMETTRIC ENCYPTION TEST BY SAMI MALIK

Common Asymmetric Encryption Algorithms
Common asymmetric encryption algorithms are essential in secure communication and data transmission. Examples of these algorithms include RSA, Diffie-Hellman, and Elliptic Curve Cryptography (ECC). Below list these asymmetric encryption algorithms and their features, 


Monday, August 21, 2023

Enable TLS 1.2 for EBS 12.2

  Below are the high-level technical steps on how to enable TLS for EBS 12.2:

  1. Create a wallet for the Oracle HTTP Server.
  2. Import the certificate into the wallet.
  3. Configure the Oracle HTTP Server to use TLS.
  4. Restart the Oracle HTTP Server.

Create a wallet for the Oracle HTTP Server

  1. Log in to the Oracle HTTP Server as the root user.
  2. Navigate to the <FMW_HOME>/webtier/config/OHS/ssl directory.
  3. Create a new file called server.jks.
  4. Run the following command to generate a keystore password:
keytool -genkey -alias server -keystore server.jks -storepass password
  1. Enter a password for the keystore.
  2. Click Enter.
  3. Enter the distinguished name for the server.
  4. Click Enter.
  5. Click Enter to accept the default values for the other fields.

Import the certificate into the wallet

  1. Copy the certificate file to the <FMW_HOME>/webtier/config/OHS/ssl directory.
  2. Run the following command to import the certificate into the wallet:
keytool -import -alias server -file certificate.crt -keystore server.jks -storepass password

Replace certificate.crt with the name of the certificate file.

Configure the Oracle HTTP Server to use TLS

  1. Edit the <FMW_HOME>/webtier/config/OHS/httpd.conf file.
  2. Add the following lines to the file:
SSLEngine on
SSLCertificateFile server.jks
SSLCertificateKeyFile server.jks
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:!RC4
  1. Save the file.

Restart the Oracle HTTP Server

  1. Stop the Oracle HTTP Server.
  2. Start the Oracle HTTP Server.

Once you have completed these steps, TLS will be enabled for Oracle EBS 12.2.

Here are some additional things to keep in mind:

  • You need to have a valid certificate in order to enable TLS. You can obtain a certificate from a certificate authority (CA).
  • You need to configure the Oracle HTTP Server to use the correct cipher suites. Cipher suites are used to encrypt the data that is transferred between the client and the server.
  • You need to restart the Oracle HTTP Server after you have made changes to the configuration.

Monday, July 10, 2023

ADRCI, TFACTL, ASMCMD, SRVCTL, CRSCTL, DGMGRL Commands

 I have consolidated these useful commands under each of these Oracle utilities,

ADRCI Commands

ADRCI is the command line interface for diagnostic utility used for viewing diagnostics data like listener log , alert log ,incident and cor dump etc and creating incident packages. Below are the the list of useful commands.

1. Get current base location:( Also known as ADR_BASE)

adrci> show base

ADR base is "/u01/app/oracle/"

2. Set new ORACLE_BASE(ADR_BASE)

adrci> set base /u01/app/grid

3. List current ORACLE_HOME

adrci> show home

4. Set new ORACLE_HOME

adrci> set homepath /u02/app/oracle

5. View alert log

adrci> show alert

adrci> show alert -tail 100

6. Purge alerts and trace files

-- This will purge data older than 600 minutes.

adrci> purge -age 600 -type ALERT

adrci> purge -age 600 -type TRACE

adrci> purge -age 600 -type incident

adrci> purge -age 10080 -type cdump

7. Set control policy for auto purge of files

There are two types of policies,

LONGP_POLICY is used to purge below data . Default value is 365 days.

• ALERT • INCIDENT • SWEEP • STAGE • HM

SHORTP_POLICY is used to purge for below data Default value is 30 days.

• TRACE • CDUMP • UTSCDMP • IPS

— Get existing control policy

adrci> show control

Change default value of control policy details.

-- Set in hours.

adrci> set control (SHORTP_POLICY = 240)

adrci> set control (LONGP_POLICY = 600)

8 . Create incident package:

adrci> show incident

adrci>IPS CREATE PACKAGE INCIDENT

(or)

adrci> ips pack incident in /tmp

Generated package 9 in file /tmp/ORA1578_20230602113045_COM_1.zip, mode complete

We can create empty package and add required incident or problem or alert log files.

-- Create empty package

adrci>IPS CREATE PACKAGE

-- add the necessary incident files. ( package_number will be displayed in the above command)

adrci>IPS ADD INCIDENT incident_number PACKAGE 2

adrci>IPS ADD FILE /u01/app/oracle/alert_db.log PACKAGE 2

-- Now generate the package file.

adrci>IPS GENERATE PACKAGE 2 IN /home/dbaclass/housekeeping

9. Unpack a ips file

adrci> ips unpack file ORA_98928.zip into /tmp/housekeeping

10. Pack all incident files within a particular time frame

--Generates the package with the incidents occurred between the times '2023-05-01 12:00:00.00' and '2023-05-02 23:00:00.00'

ips pack time '2023-05-01 12:00:00.00' to '2023-05-02 23:00:00.00'

11. View package information

adrci> ips show package

adrci> ips show package 12 detail

12. Remove/delete package information:

-- Delete the complete package:

adrci> ips delete package 2

-- Remove incidents from the packages

adrci > ips remove incident 2 package 7

-- Remove the problem keys from packages

adrci > ips remove problem 4 package 8

TFACTL commands

1. Check tfactl status with version:

tfactl status

2. Check tfactl tool status:

tfactl toolstatus

3. Get config details:

tfactl print config

4. List of user having access to tfactl:

tfactl access lsusers

6. changing property of a user:

tfactl access promote -user oracle

5.Adding or removing users from access list of tfactl:

tfactl access add -user rpdtro

tfactl access remove -user rdptro

6. change port number for tfactl:

tfactl set port=5001

NOTE – make sure to restart the tfactl after port change.

7. Stop/ start tfactl:

tfactl stop

tfactl start

8. Enable /disable autostart of tfactl upon reboot:

tfactl disable

tfactl enable

9. Find tfactl version with simple command:

tfactl version

AHF VERSION: 20.2.0

10. Collect diagnostic report pass the time of incident in YYYY-MM-DD HH24:MI:SS)

tfactl diagcollect -all

11. Get notificationaddress email:

tfactl get notificationAddress

12. Change notification address email:

tfactl set notificationAddress=oracle:admin@dbaclass.com

11. Generate summary report :

tfactl summary

-- Genearate complete summary overview in html

tfactl summary -html

-- Generate patching summary:

tfactl summary -patch -html

-- Generate asm summary

tfactl summary -asm -html

12.view smtp details :

tfactl print smtp

13. Manage logs using tfactl managelogs:

tfactl managelogs -show usage

14. Purge old logs:

-- This is just a dry run:

tfactl managelogs -purge -older 5d -dryrun

-- This will actually delete the logs older than 5 days

tfactl managelogs -purge -older 5d

-- Delete only GI logs:

tfactl managelogs -purge -gi 5d

tfactl run managelogs -purge -older 5d -gi

-- Delete only database logs:

tfactl run managelogs -purge -older -5d -database

15. Get repository location and usage:

tfactl print repository

16. Get component details:

tfactl print components

17. Find diag collection details of tfactl:

tfactl print collections

18. Verify email/smtp configuration.

tfactl sendmail support@samiora.itgo.com

ASMCMD commands

This article contains the list of useful asmcmd commands which will come handy in your day to day operations.

1. List all diskgroups:

ASMCMD> lsdg

-- Include dismounted diskgroups:

ASMCMD> lsdg --discovery

-- List diskgroups across all nodes of cluster:

ASMCMD> lsdg -g --discovery

2. List asm disks:

-- List all asm disks

ASMCMD> lsdsk -k

-- List disks of a diskgroup(CDATA) with free and total MB

ASMCMD> lsdsk -k -G CDATA

-- List disks of a diskgroup(CDATA) with group and disk number

ASMCMD> lsdsk -p -G CDATA

-- List disks with disk creation date

ASMCMD> lsdsk -t -G CDATA

-- List candidiate disks only

ASMCMD> lsdsk --candidate -k

-- List member disks only

ASMCMD> lsdsk --candidate -p

3. Get attributes of ASM diskgroups:

-- List attribute of all diskgroups:

ASMCMD> lsattr -lm

-- List attribute of specific diskgroup(DMARCH)

ASMCMD> lsattr -lm -G DMARCH

Group_Name Name Value RO Sys

DMARCH access_control.enabled FALSE N Y

DMARCH access_control.umask 066 N Y

DMARCH au_size 1048576 Y Y

DMARCH cell.smart_scan_capable FALSE N N

-- List attributes with specific pattern

ASMCMD> lsattr -lm %au_size%

Group_Name Name Value RO Sys

CDATA au_size 1048576 Y Y

BDM au_size 1048576 Y Y

CRMG au_size 1048576 Y Y

PMARCH au_size 1048576 Y Y

BCMS au_size 1048576 Y Y

4. unmount diskgroup:

unmount command works only on the local node. So if you want to unmount the diskgroup from all nodes of cluster, then run this command from all the nodes.

-- unmount all diskgroups

ASMCMD> umount -a

--- unmount specific diskgroup(ARCH)

ASMCMD> umount ARCH

4. Mount diskgroup:

Mount command works only on the local node. So if you want to Mount the diskgroup from all nodes of cluster, then run this command from all the nodes.

-- mount all diskgroups on local node

ASMCMD> mount -a

--- mount a specific diskgroup on local node

ASMCMD> mount ARCH

5. Rebalance a diskgroup:

-- here asm_power_limit is 8 and diskgroup is ARCH

ASMCMD> rebal --power 8 ARCH

Rebal on progress.

-- Monitor progress

ASMCMD> lsop

Group_Name Pass State Power EST_WORK EST_RATE EST_TIME

ARCH COMPACT RUN 8 0 16831 0

ARCH REBALANCE DONE 8 0 0 0

6. Get password file of database

ASMCMD> pwget --dbuniquename DBACLASS

+CDATA/DBACLASS/PASSWORD/pwddbaclass.256.899912377

8 .Get password file of asm :

ASMCMD> pwget --asm

+MGMT/orapwASM

9. Get asm template info of a diskgroup:

ASMCMD> lstmpl -l -G ARCH

Group_Name Group_Num Name Stripe Sys Redund PriReg MirrReg

ARCH 1 ARCHIVELOG COARSE Y UNPROT COLD COLD

ARCH 1 ASMPARAMETERFILE COARSE Y UNPROT COLD COLD

ARCH 1 AUDIT_SPILLFILES COARSE Y UNPROT COLD COLD

ARCH 1 AUTOBACKUP COARSE Y UNPROT COLD COLD

ARCH 1 AUTOLOGIN_KEY_STORE COARSE Y UNPROT COLD COLD

ARCH 1 BACKUPSET COARSE Y UNPROT COLD COLD

10. Check whether flex asm is enabled or not

ASMCMD> showclustermode

ASM cluster : Flex mode disabled

11.Check cluster state:

ASMCMD> showclusterstate

Normal

12. View asm version:

ASMCMD> showversion

ASM version : 12.1.0.2.0

13. Get asm spfile location:

ASMCMD> spget

+MGMT/DBACLASS-cluster/ASMPARAMETERFILE/registry.253.899644763

14. Take backup of asm spfile:

-- copy backup of spfile to a specific location

ASMCMD> spbackup +MGMT/DBACLASS-cluster/ASMPARAMETERFILE/registry.253.899644763 /home/oracle/asmspfile.ora

15. Find clients connected to a diskgroup:

ASMCMD> lsct DMARCH

DB_Name Status Software_Version Compatible_version Instance_Name Disk_Group

DBACLASS CONNECTED 12.1.0.2.0 12.1.0.2.0 DBACLASS1 DMARCH

16. Get asm diskstring

ASMCMD> dsget

parameter:ORCL:*

profile:ORCL:*

17. List asm users with password:

ASMCMD> lspwusr

Username sysdba sysoper sysasm

SYS TRUE TRUE TRUE

ASMSNMP TRUE FALSE FALSE

18. List open files of a diskgroup:

— Open files of a diskgroup ( ARCH)

ASMCMD>lsof -G ARCH

19 . List open files related to a database

-- Open files of a database( DBACLASS)

ASMCMD>lsof --dbname DBACLASS

20. Check filter driver is enabled or not:

ASMCMD> afd_state

ASMCMD-9526: The AFD state is 'NOT INSTALLED' and filtering is 'DEFAULT' on host 'b20e4bay01'

filter driver disks:

21. List filter driver disks(if enabled)

ASMCMD> afd_lsdsk

22. Get filter driver asm diskstring

ASMCMD> afd_dsget

AFD discovery string:

srvctl commands

SRVCTL is known as server control utility, which is used to add, remove,relocate and manage different crs services or components in RAC database.

1. STOP DATABASE :

SYNTAX – srvctl stop database -d db_name [-o stop_options] where stop_options is normal/immediate(default)/transactional/abort

e.g

srvctl stop database -d PRODB -o normal

srvctl stop database -d PRODB -o immediate

srvctl stop database -d PRODB -o transactional

srvctl stop database -d PRODB -o abort

2. START DATABASE SYNTAX – srvctl start database -d db_name [-o start_options] where start_option is nomount/mount/open(default)

e.g

srvctl start database -d PRODB -o nomount

srvctl start database -d PRODB -o mount

srvctl start database -d PRODB -o open

3. STOP AN INSTANCE

SYNTAX – srvctl stop instance -d db_unique_name [-i “instance_name_list”]} [-o stop_options] [-f] e.g

srvctl stop instance -d PRODB -i PRODB1

4. START AN INSTANCE

SYNTAX – srvctl start instance -d db_unique_name [-i “instance_name_list”} [-o start_options] e.g

srvctl start instance -d PRODB -i PRODB1

5. REMOVING DB FROM CRS: SYNTAX – srvctl remove database -d db_unique_name [-f] [-y] [-v] e.g

srvctl remove database -d PRODB -f -y

6. ADDING DB IN CRS : SYNTAX – srvctl add database -d db_unique_name -o ORACLE_HOME [-p spfile] e.g

srvctl add database -d PRODB -o /u01/app/oracle/product/12.1.0.2/dbhome_1 -p +DATA/PRODDB/parameterfile/spfilePRODB.ora

7. REMOVING AN INSTANCE FROM CRS: SYNTAX – srvctl remove instance -d DB_UNIQUE_NAME -i INSTANCE_NAME e.g

srvctl remove instance -d PRODB - I PRODB1

8.ADDING AN INSTANCE TO CRS: SYNTAX – srvctl add instance –d db_unique_name –i inst_name -n node_name e.g

srvctl add instance -d PRODB - i PRODB1 -n rachost1

9. Enable/disable auto restart of the instance

srvctl enable instance -d DB_UNIQUE_NAME-i INSTANCE_NAME

srvctl disable instance -d DB_UNIQUE_NAME-i INSTANCE_NAME

10. Enable/disable auto restart of the database

srvctl enable database -d DB_UNIQUE_NAME

srvctl disable database -d DB_UNIQUE_NAME

11. ADDING A SERVICE:

SYNTAX – srvctl add servicec -d {DB_NAME} -s {SERVICE_NAME} -r {“preferred_list”} -a {“available_list”} [-P {BASIC | NONE | PRECONNECT}]

e.g

srvctl add service -d PREDB -s PRDB_SRV -r "PREDB1,PREDB2" -a "PREDB2" -P BASIC

12.REMOVING A SERVICE:

SYNTAX – srvctl remove service -d {DB_NAME} -s {SERVICE_NAME} e.g

srvctl remove service -d PREDB -s PRDB_SRV

13. START A SERVICE SYNTAX– srvctl start servicec -d {DB_NAME} -s {SERVICE_NAME} e.g

srvctl start service -d PREDB -s PRDB_SRV

14. STOP A SERVICE

SYNTAX– srvctl stop servicec -d {DB_NAME} -s {SERVICE_NAME} e.g

srvctl stop service -d PREDB -s PRDB_SRV

15. RELOCATE A SERVICE

SYNTAX – srvctl relocate service -d {database_name} -s {service_name} -i {old_inst_name} -r {new_inst_name}

EXAMPLE: (Relocating service PRDB_SRV from PREDB2 to PREDB1)

srvctl relocate service -d PREDB -s PRDB_SVC -i PREDB2 -t PREDB1

16. Check the status of service SYNTAX – srvctl status service -d {database_name} -s {service_name}

srvctl status service -d PREDB -s PRDB_SVC

17. Check the configuration of service SYNTAX – srvctl config service -d {database_name} -s {service_name}

srvctl config service -d PREDB -s PRDB_SVC

18. Check scan listener configuration

srvctl config scan_listener

SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1522

Registration invited nodes:

Registration invited subnets:

SCAN Listener is enabled.

SCAN Listener is individually enabled on nodes:

SCAN Listener is individually disabled on nodes:

SCAN Listener LISTENER_SCAN2 exists. Port: TCP:1522

Registration invited nodes:

Registration invited subnets:

SCAN Listener is enabled.

SCAN Listener is individually enabled on nodes:

SCAN Listener is individually disabled on nodes:

SCAN Listener LISTENER_SCAN3 exists. Port: TCP:1522

Registration invited nodes:

Registration invited subnets:

SCAN Listener is enabled.

SCAN Listener is individually enabled on nodes:

SCAN Listener is individually disabled on nodes:

19. Modify scan_listener port:

srvctl modify scan_listener -p {new-SCAN-port}

srvctl modify scan_listener -p 1523

$GRID_HOME/bin/srvctl stop scan_listener

$GRID_HOME/bin/srvctl start scan_listener

Alter system set remote_listener='orcl-scan.stc.com.sa:1523' scope=both sid='*';

20. Manage MGMTDB in oracle 12c:

srvctl status mgmtdb

Database is enabled

Instance -MGMTDB is running on node node12-1

-- stop and start MGMT db.

srvctl stop mgmtdb

srvctl start mgmtdb

21. Enable trace for srvctl commands:

-- set this to enable trace at os

SRVM_TRACE=true

export SRVM_TRACE

-- run any srvctl command

srvctl status database -d ORACL

22. Set environment variables through srvctl.

-- setenv to set env variables.(ORCL is the db_unique_name)

srvctl setenv database -db ORCL -env "ORACLE_HOME=/oracle/app/oracle/product/12.1.0.2/dbhome_1"

srvctl setenv database -db ORCL -env "TNS_ADMIN=/oracle/app/oracle/product/12.1.0.2/dbhome_1/network/admin"

--getenv to view the env setting:

srvctl getenv database -db ORCL

ORCL:

ORACLE_HOME=/oracle/app/oracle/product/12.1.0.2/dbhome_1

TNS_ADMIN=/oracle/app/oracle/product/12.1.0.2/dbhome_1/network/admin

23. Check status and config of ASM instance:

srvctl config asm

ASM home:

Password file: +MGMT/orapwASM

ASM listener: LISTENER

srvctl status asm

ASM is running on ses11-4,ses11-5

24. Stop and start services running from ORACLE_HOME

srvctl stop home -oraclehome /oracle/product/12.1.0.2/dbhome_1 -statefile /home/oracle/state.txt -node dbhost-1

srvctl start home -oraclehome /oracle/product/12.1.0.2/dbhome_1 -statefile /home/oracle/state.txt -node dbhost-1

25. Create a TAF policy

srvctl add service -db ORCLDB -service TAF_ORCL -preferred ORCLDB1 -available ORCLDB2 -tafpolicy BASIC -failovertype SELECT srvctl start service -db

CRSCTL commands

CRSCTL Utility is used to managed oracle clusterware resources and components.

1. STOP & START CRS: ( run from root user)

$GRID_HOME/bin/crsctl stop crs

$GRID_HOME/bin/crsctl start crs

2. Enable/Disable auto restart of CRS.

$GRID_HOME/bin/crsctl disable crs

$GRID_HOME/bin/crsctl enable crs

3. Find the cluster name

$GRID_HOME/bin/cemutlo -n

or

$GRID_HOME/bin/olsnodes -c

4. Find grid version:

SYNATX – $GRID_HOME/bin/crsctl query crs softwareversion <hostname)

$GRID_HOME/bin/crsctl query crs softwareversion host-dbaclass1

5. check cluster component status

$GRID_HOME/bin/crsctl stat res -t

$GRID_HOME/bin/crsctl check crs

$GRID_HOME/bin/crsctl check cssd

$GRID_HOME/bin/crsctl check crsd

$GRID_HOME/bin/crsctl check evmd

6. Find voting disk location

$GRID_HOME/bin/crsctl query css votedisk

7. Find OCR location:

$GRID_HOME/bin/ocrcheck

8. Find cluster interconnect details

$GRID_HOME/bin/oifcfg getif

app-ipmp0 172.21.39.128 global public

loypredbib0 172.16.3.192 global cluster_interconnect

loypredbib1 172.16.4.0 global cluster_interconnect

select NAME,IP_ADDRESS from v$cluster_interconnects;

NAME IP_ADDRESS

--------------- ----------------

loypredbib0 172.16.3.193

loypredbib1 172.16.4.1

9. Check CRS status of local node

crsctl check crs

CRS-4638: Oracle High Availability Services is online

CRS-4537: Cluster Ready Services is online

CRS-4529: Cluster Synchronization Services is online

CRS-4533: Event Manager is online

10. Check status of all crs resourcs

$GRID_HOME/bin/crsctl stat res -t

$GRID_HOME/bin/crsctl stat res -t -init

10. Check active version of cluster

crsctl query crs activeversion

Oracle Clusterware active version on the cluster is [12.1.0.2.0]

11. Stop and start high availability service ( HAS)

crsctl stop has

crsctl start has

12. Check CRS status of remote nodes

crsctl check cluster

crsctl check cluster -all

13. Disk timeout from node to voting disk(disktimeout)

crsctl get css disktimeout

CRS-4678: Successful get disktimeout 200 for Cluster Synchronization Services.

14. Network latency in the node interconnect (Misscount)

crsctl get css misscount

CRS-4678: Successful get misscount 30 for Cluster Synchronization Services.

15. Move voting disk to another diskgroup:

crsctl replace votedisk +OCRVD

Successful addition of voting disk 2e4ded6cee504fc8bf078b080fb7be6f.

Successful addition of voting disk 8e87826024e24fffbf5add65c011fc66.

Successful addition of voting disk e1ba56dedff84fa8bf5605e0302fc81e.

Successful deletion of voting disk 2b7ce864c44d4fecbf60885a188290af.

Successfully replaced voting disk group with +OCRVD.

CRS-4266: Voting file(s) successfully replaced

16. Add another voting disk:

crsctl add css votedisk

17. Delete voting disk:

crsctl delete css votedisk

18 . Get ocr disk backup details

ocrconfig -showbackup

19 . Check whether standard or flex ASM

crsctl get cluster mode status

Cluster is running in "standard" mode

20 . Check CRS configuation

crsctl config crs

21 . Find cluster configuration information:

$ crsctl get cluster configuration

Name : dbaclass-cluster

Configuration : Cluster

Class : Standalone Cluster

Type : flex

The cluster is not extended.

--------------------------------------------------------------------------------

MEMBER CLUSTER INFORMATION

Name Version GUID Deployed Deconfigured

,

21 . Find node roles in cluster

crsctl get node role status -all

Node 'dbhost1' active role is 'hub'

Node 'dbhost1' active role is 'hub'

22. crsctl has commands for standalone grid infrastrcuture

crsctl check has

crsctl config has

crsctl disable has

crsctl enable has

crsctl query has releaseversion

crsctl query has softwareversion

crsctl start has

crsctl stop has

DGMGRL commands in oracle dataguard

This topic contains useful dgmgrl commands to manage the dataguard environments.

1. Setup DG broker in the standby setup.(Run on both primary and standby)

- For standalone db :

ALTER SYSTEM SET dg_broker_config_file1 = '\U01\oradata\dr1node.dat' scope=both sid='*';

ALTER SYSTEM SET dg_broker_config_file2 = '\U01\oradata\dr2node.dat' scope=both sid='*';

-- For oracle RAC/ASM file system;

ALTER SYSTEM SET dg_broker_config_file1 = '+DATA/broker/dr1node.dat' scope=both sid='*';

ALTER SYSTEM SET dg_broker_config_file2 = '+DATA/broker/dr2node.dat' scope=both sid='*';

ALTER SYSTEM SET DG_BROKER_START=TRUE scope=both sid='*';

2. Create configuration in dgbroker:

-- on primary

$dgmgl

DGMGRL> CONNECT sys/;

Connected.

-- create configuration with primary db_unique_name and its service name .

DGMGRL> CREATE CONFIGURATION 'PROD_DG' AS PRIMARY DATABASE IS 'PRIMDB' CONNECT IDENTIFIER IS PRIMDB;

Configuration "PRIMDB" created with primary database "PRIMDB"

--- Add standby in the configuration:

DGMGRL> ADD DATABASE 'STYDB' AS CONNECT IDENTIFIER IS STYDB MAINTAINED AS PHYSICAL;

Database "STYDB" added

3. Enable the configuration

DGMGRL> ENABLE CONFIGURATION;

Enabled.

At this stage our dg broker setup is completed.

4. View configuration of dgbroker:

DGMGRL> show configuration

DGMGRL> show configuration verbose

5. view database informations:

-- Here PRIMDB and STYDB are db_unique_name of primary and standby db

DGMGRL> show database 'PRIMDB'

DGMGRL > show database 'STYDB'

DGMGRL> show database verbose 'PRIMDB'

6. View statusreport of databases

-- Here PRIMDB and STYDB are db_unique_name of primary and standby db

show database PRIMDB statusreport

7. View database inconsistent properties

-- Here PRIMDB and STYDB are db_unique_name of primary and standby db

show database PRIMDB InconsistentProperties

show database PRIMDB InconsistentLogXptProps

show database STYDB InconsistentProperties

show database STYDB InconsistentLogXptProps

8. Check whether all logfiles are archived or not( on primary)

show database PRIMDB sendQentries

PRIMARY_SEND_QUEUE

STANDBY_NAME STATUS RESETLOGS_ID THREAD LOG_SEQ TIME_GENERATED TIME_COMPLETED FIRST_CHANGE# NEXT_CHANGE# SIZE (KBs)

CURRENT 1022762318 1 294 10/30/2019 11:09:26 12298130044308 274219

9. Check information of received log sequence(not applied) ( Run for standby)

DGMGRL>show database STYDB recvqentries

STANDBY_RECEIVE_QUEUE

STATUS RESETLOGS_ID THREAD LOG_SEQ TIME_GENERATED TIME_COMPLETED FIRST_CHANGE# NEXT_CHANGE# SIZE (KBs)

NOT_APPLIED 1022762318 1 293 10/30/2019 10:03:06 10/30/2019 11:09:26 12298109948824 12298130044308 3487164

10. Check database wait events:

DGMGRL>show database PRIMDB topwaitevents

11.Validate database information:

dgmgrl> validate database verbose 'PRIMDB'

dgmgrl> validate database 'PRIMDB'

dgmgrl> validate database 'STYDB'

12. Enable tracing for troubleshooting:

-- For standalone:

DGMGRL> edit configuration set property tracelevel=support;

DGMGRL> edit database PRIMDB set property LogArchiveTrace=8191;

DGMGRL> edit database STYDB set property LogArchiveTrace=8191;

-- For RAC:

DGMGRL> EDIT INSTANCE * ON DATABASE 'PRIMDB' SET PROPERTY LogArchiveTrace=8191;

13. Disable tracing:

DGMGRL> edit configuration reset property tracelevel ;

DGMGRL> edit database PRIMDB reset property logarchivetrace;

DGMGRL> edit database STYDB reset property logarchivetrace;

14. Switchover using dgmgrl:

DGMGRL> connect sys/oracle

Password:

Connected as sys.

DGMGRL> switchover to STYDB

Performing switchover NOW, please wait...

Operation requires a connection to instance "STYDB1" on database "STYDB"

Connecting to instance "STYDB1"...

Connected as SYSDBA.

New primary database "STYDB" is opening...

Oracle Clusterware is restarting database "PRIMDB" ...

Switchover succeeded, new primary is "STYDB"

15. Convert physical standby to snapshot standby

DGMGRL> convert database 'STYDB' to snapshot standby;

16. Convert snapshot to physical standby db

DGMGRL> CONVERT DATABASE 'STYDB' to PHYSICAL STANDBY;

Flashback related commands

Below are the collection of useful flashback related commands.

1. How to check whether flashback is enabled or not:

select flashback_on from v$database;

2. Enable flashback in database:

--- make sure database is in archivelog mode:

alter system set db_recovery_file_dest_size=10G scope=both;

alter system set db_recovery_file_dest='/dumparea/FRA/B2PMT3' scope=both;

alter database flashback on;

3. Disable flashback in database:

alter database flashback off;

4. Create flashback restore point :

create restore point FLASHBACK_PREP guarantee flashback database;

5. Find the list of restore points:

-- From SQL prompt:

SQL>Select * from v$restore_points:

-- From RMAN prompt:

RMAN>LIST RESTORE POINT ALL;

6. Drop restore point:

drop restore point FLASHBACK_PREP;

7. Flashback database to restore point:

--- Below are the steps for flashback database to a guaranteed restore point;

1. Get the restore point name:

SQL> select NAME,time from v$restore_point;

NAME TIME

-------------------------------- -----------------------------------------------

FLASHBACK_PREP 21-MAR-17 03.41.33.000000000 PM

2. Shutdown database and start db in Mount stage:

shutdown immediate;

startup mount;

3. flashback db to restore point:

flashback database to restore point FLASHBACK_PREP;

4. Open with resetlog:

alter database open resetlogs;

8. Flashback query as of timestamp:

SELECT * FROM DBACLASS.EMP AS OF TIMESTAMP

TO_TIMESTAMP('2017-01-07 10:00:00', 'YYYY-MM-DD HH:MI:SS');

SELECT * FROM DBACLASS.EMP AS OF TIMESTAMP SYSDATE -1/24;

9. Flashback database to particular SCN or timestamp:

shutdown immediate;

startup mount;

--FLASHBACK DATABASE TO SCN 202381; -- Use this for particular scn

--FLASHBACK DATABASE TO TIMESTAMP (SYSDATE-1/24); - Use for flashback to last one hour

--FLASHBACK DATABASE TO TIMESTAMP to_timestamp('2018-03-11 16:00:00', 'YYYY-MM-DD HH24:MI:SS');- to specific timestamp:

alter database open resetlogs;

10. Flashback a table from recyclebin:

-- First get whether the table name exists in recyclebin or not:

SELECT object_name, original_name, createtime FROM recyclebin where original_name='EMP';

-- restore the table as same name:

FLASHBACK TABLE int_admin_emp TO BEFORE DROP;

-- Restore that table to a new name:

FLASHBACK TABLE int_admin_emp TO BEFORE DROP

RENAME TO int2_admin_emp;

11. Get flashback are usage info:

SELECT * FROM V$FLASH_RECOVERY_AREA_USAGE;

12. How far can we flashback:

--How Far Back Can We Flashback To (Time)

select to_char(oldest_flashback_time,’dd-mon-yyyy hh24:mi:ss’) “Oldest Flashback Time”

from v$flashback_database_log;

--How Far Back Can We Flashback To (SCN)

col oldest_flashback_scn format 99999999999999999999999999

select oldest_flashback_scn from v$flashback_database_log;