Sunday, 30 September 2018

Monitor Oracle PaaS VM machine disk usage shell script


0 * * * *  sh /home/oracle/dbascripts/monitor_disk.sh


#!/bin/bash
echo `date` >> /tmp/cron.txt
LIMIT='90'
#Here we declare variable LIMIT with max of used space

DIR='/u03'
#Here we declare variable DIR with name of directory

MAILTO='M.Allam@tahaluf.ae,n.abuaqoulah@tahaluf.ae,m.almasri@tahaluf.ae'

#Here we declare variable MAILTO with email address
SUBJECT="Backup Mount point $DIR disk usage"

#Here we declare variable SUBJECT with subject of email
MAILX='mailx'

#Here we declare variable MAILX with mailx command that will send email
which $MAILX > /dev/null 2>&1

#Here we check if mailx command exist
if ! [ $? -eq 0 ]
#We check exit status of previous command if exit status not 0 this mean that mailx is not installed on system

then
          echo "Please install $MAILX"
#Here we warn user that mailx not installed
          exit 1
#Here we will exit from script
fi
cd $DIR
#To check real used size, we need to navigate to folder
USED=`df -Pl  | grep $DIR  | grep "^/dev" | awk '{print $5}' | sed "s/%//"`
#This line will get used space of partition where we currently, this will use df command, and get used space in %, and after cut % from value.
if [[ $USED -gt $LIMIT ]]
#If used space is bigger than LIMIT
then
      echo "Current Disk Space utilization is $USED% which needs your attention" | $MAILX -s "$SUBJECT" "$MAILTO"
#This will print space usage by each directory inside directory $DIR, and after MAILX will send email with SUBJECT to MAILTO
fi

Friday, 28 September 2018

DBaaS get current backup configurations

/var/opt/oracle/bkup_api/bkup_api get config --file=mycurrentconfig.cfg --dbname=ORCL 


How to Update the Cloud Tooling(dbaastools) on Database Cloud Service


Connect as the “opc” user to the compute node

login as: opc
Authenticating with public key "imported-openssh-key".

Start a root-user command shell:

[opc@ABC ~]$ sudo -s

Check whether any cloud tooling updates are available:

[root@ABC opc]# dbaascli dbpatchm --run -list_tools
DBAAS CLI version 1.0.0
Executing command dbpatchm --run -list_tools -cli
/var/opt/oracle/patch/dbpatchm -list_tools -cli
Subroutine sync_dg_standby redefined at /var/opt/oracle/patch/dbpatchm line 7383.
Starting DBPATCHM
Logfile is /var/opt/oracle/log/dbpatchm/dbpatchm_2018-06-09_14:46:24.log
Config file is /var/opt/oracle/patch/dbpatchm.cfg

INFO: cdb is set to : yes
INFO: dbversion detected : 18000
INFO: patching type : psu




Patchid : 18.2.3.1.0_180606.0000
dbpatchm Execution completed

Check your current version of cloud tooling:

[root@ABC opc]# rpm -qa|grep -i dbaastools
dbaastools-1.0-1+18.2.3.1.0_180530.0000.x86_64

Download and apply the patch containing the cloud tooling update:

patch-id is the patch ID you located in the previous step
[root@ABC opc]# dbaascli dbpatchm --run -toolsinst -rpmversion=18.2.3.1.0_180606.0000
DBAAS CLI version 1.0.0
Executing command dbpatchm --run -toolsinst -rpmversion=18.2.3.1.0_180606.0000 -cli
/var/opt/oracle/patch/dbpatchm -toolsinst -rpmversion=18.2.3.1.0_180606.0000 -cli
Subroutine sync_dg_standby redefined at /var/opt/oracle/patch/dbpatchm line 7383.
Use of uninitialized value in concatenation (.) or string at /var/opt/oracle/patch/dbpatchm line 5016.
Starting DBPATCHM
Logfile is /var/opt/oracle/log/dbpatchm/dbpatchm_2018-06-09_14:48:28.log
Config file is /var/opt/oracle/patch/dbpatchm.cfg

INFO: cdb is set to : yes
INFO: dbversion detected : 18000
INFO: patching type : psu

INFO: existing dbaastools version - dbaastools-1.0-1+18.2.3.1.0_180530.0000.x86_64

INFO: updated dbaastools rpm to - dbaastools-1.0-1+18.2.3.1.0_180606.0000.x86_64
dbpatchm Execution completed

[root@ABC opc]#

Verify the Updated Version

[root@ABC opc]# rpm -qa|grep -i dbaastools
dbaastools-1.0-1+18.2.3.1.0_180606.0000.x86_64

Check Available Updates

[root@ABC opc]# dbaascli dbpatchm --run -list_tools
DBAAS CLI version 1.0.0
Executing command dbpatchm --run -list_tools -cli
/var/opt/oracle/patch/dbpatchm -list_tools -cli
Subroutine sync_dg_standby redefined at /var/opt/oracle/patch/dbpatchm line 7383.
Starting DBPATCHM
Logfile is /var/opt/oracle/log/dbpatchm/dbpatchm_2018-06-09_14:58:16.log
Config file is /var/opt/oracle/patch/dbpatchm.cfg

INFO: cdb is set to : yes
INFO: dbversion detected : 18000
INFO: patching type : psu




No applicable dbaastools rpms found
dbpatchm Execution completed

Reset the backup configuration

[root@ABC opc]# /var/opt/oracle/ocde/assistants/bkup/bkup
Starting BKUP
Logfile is /var/opt/oracle/log/bkup/bkup_2018-06-09_15:00:12.log
Config file is /var/opt/oracle/ocde/assistants/bkup/bkup.cfg
dbname: ORCL
Dataguard configuration
Enabled: 0
Mode: PRIMARY
INFO : No backup strategy enabled.
Looking for previous configuration:
Directory : /home/oracle/bkup/ORCL
 -> obkup
 -> Found: 1 files
 -> Moving previous configuration to /home/oracle/bkup/ORCL_20180609150026
No initial bkup of PFILE needed.
Common RMAN Config
Instantiating obkup
Instantiating dbcfg.spec
Updating Control File Record Keep Time
Enabling block change tracking
Updating RMAN defaults
INFO: Archivelog management enabled.
Adding entry to crontab
Accessing to your Database ID ..
The DBaaS instance database id is: 1505878300
Deleting unencrypted autobackups.
#### Completed Execution.
[root@ABC opc]#
If you are updating cloud tooling on a database deployment hosting a Data Guard
configuration, repeat the preceding steps on the other compute node of the
deployment.

Thursday, 27 September 2018

How to Reset Password for dbaas_monitor User




Execute below Steps to Reset DBAAS_MONITOR User Password while connecting to root user:

Connect to Database Compute Node using ROOT User.

cd /u01/app/oracle/product/ords/
java -jar ords.war user dbaas_monitor "OSAdmin"
chown oracle:oinstall /u01/app/oracle/product/ords/conf/ords/credentials
chmod 644 /u01/app/oracle/product/ords/conf/ords/credentials

Saturday, 15 September 2018

ORA-16139: media recovery required SWITCHOVER_STATUS SWITCHOVER LATENT

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS
--------------------
SWITCHOVER LATENT

SQL> alter database commit to switchover to primary with session shutdown;
alter database commit to switchover to primary with session shutdown
*
ERROR at line 1:
ORA-16139: media recovery required


SQL> RECOVER MANAGED STANDBY DATABASE FINISH;
Media recovery complete.
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

Database altered.

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS
--------------------
NOT ALLOWED

SQL> select db_unique_name,database_role,switchover_status from v$database;

DB_UNIQUE_NAME                 DATABASE_ROLE    SWITCHOVER_STATUS
------------------------------ ---------------- --------------------
MEDDB                          PRIMARY          NOT ALLOWED


SQL> alter database open;

Number of Visitors