Monday, August 7, 2023

Useful Oracle 19c RAC Commands

Oracle oracle 19c rac commands, oracle 19c rac crsctl commands, oracle 19c rac srvctl commands, oracle 19c rac start sequence, oracle 19c rac stop sequence, oracle 19c rac stop/start one node

WHAT IS THE DIFFERENCE BETWEEN SRVCTL AND CRSCTL?

SERVER CONTROL UTILITY (SRVCTL)

Server Control Utility (SRVCTL): It is used to administer Oracle Real Application Clusters (Oracle RAC) databases and instances.

Use SRVCTL to manage Oracle supplied resources such as:

  • Database
  • Listener
  • Instances
  • Disk groups
  • Networks

If resource name begins with ora then use SRVCTL. Oracle suggest DBAs to use srvctl command to stop/start the databases.

We can use the SRVCTL to manage configuration information.  Use SRVCTL commands to add, remove, start, stop, modify, enable, and disable a number of entities, such as Databases, instances, listeners, SCAN listeners, services, grid naming Service (GNS), and Oracle ASM.

CLUSTERWARE CONTROL UTILITY (CRSCTL)

Clusterware Control Utility (CRSCTL): It is used to managed oracle clusterware resources and components.

Use CRSCTL for managing Oracle Clusterware and its resources. CRSCTL command is used to manage the elements of the clusterware like crs, css, evm.

CRSCTL manages Oracle Clusterware related operations like:

  • Starting and stopping Oracle Clusterware
  • Enabling and disabling Oracle Clusterware daemons
  • Checking the health of the cluster
  • Registering cluster resources

SERVER CONTROL UTILITY (SRVCTL) – DATABASE RELATED COMMANDS

srvctl -help >>> List All Commands With Syntax

srvctl status listener -n node1 >>> Check Listener Status Of Specific Node
srvctl status listener >>> Check Listener Status Of All Nodes

srvctl start listener -n node1 >>> Start Listener On Specific Node
srvctl start listener >>> Start Listener On All Nodes

srvctl stop listener -n node1 >>> Stop Listener On Specific Node
srvctl stop listener >>> Stop Listener On All Nodes

srvctl status instance -d TEST -i TEST1 >>> Check Status Of Specific Instance
srvctl status database -d TEST >>> Check Status Of All Instances

srvctl start instance -d TEST -i TEST1 >>> Starts Specific Instance
srvctl start database -d TEST >>> Starts All Instances (+Open Database)

srvctl start database -d TEST -o nomount >>> Starts Service As Nomount
srvctl start database -d TEST -o mount >>> Starts Service As Mount
srvctl start database -d TEST -o open >>> Starts Service As Open

srvctl stop instance -d TEST -i TEST1 >>> Stops Specific Instance
srvctl stop database -d TEST >>> Stops All Instances (+Shutdown Database)

srvctl stop database -d TEST -o normal >>> Stops Service As Normal
srvctl stop database -d TEST -o immediate >>> Stops Service As Immediate
srvctl stop database -d TEST -o transactional >>> Stops Service As Transactional
srvctl stop database -d TEST -o abort >>> Stops Service As Abort

srvctl config database >>> Check Registered Databases In The Repository
srvctl config database -d TEST >>> Check Specific Database Configuration

CLUSTERWARE CONTROL UTILITY (CRSCTL) – CLUSTER RELATED COMMANDS

crsctl config has >>> Check Oracle HAS (High Availabilty Services) Config
crsctl disable has >>> Disable Automatic Startup Of The Oracle High Availability Services
crsctl enable has >>> Enable Automatic Startup Of The Oracle High Availability Services

crsctl check crs >>> Check Oracle High Availability Services On The Local Server.
crsctl stop crs >>> Stop Oracle High Availability Services On The Local Server.
crsctl start crs >>> Start Oracle High Availability Services On The Local Server.

crsctl query crs softwareversion >>> Check Oracle Clusterware Software Version
crsctl query crs activeversion >>> Check Oracle Clusterware Acitve Version
crsctl query crs releaseversion >>> Check Oracle Clusterware Release Version

OTHER USEFUL COMMANDS

show parameter CLUSTER_DATABASE; >>> Check Database Running As Cluster Or Not.

 

select instance_name, host_name, archiver, thread#, status from gv$instance; >>> Check RAC Status.

SHUTDOWN SEQUENCE OF ONLY ONE NODE IN A CLUSTER

Check Database And ASM Instance
[root@node1 ~]# ps -ef | grep pmon | grep -v grep
grid 9901 1 0 Sept10 ? 00:00:04 asm_pmon_+ASM1
oracle 16761 1 0 03:00 ? 00:00:00 ora_pmon_TEST1
[root@node1 ~]#

Check And Stop Instance
[root@node1 ~]# srvctl status instance -d TEST -i TEST1
[root@node1 ~]# srvctl stop instance -d TEST -i TEST1
[root@node1 ~]# srvctl status instance -d TEST -i TEST1

Check And Stop Oracle High Availability Services On The Local Server
[root@node1 ~]# crsctl check crs
[root@node1 ~]# crsctl stop crs
[root@node1 ~]# crsctl check crs

Check Database And ASM Instance
[root@node1 ~]# ps -ef | grep pmon | grep -v grep
[root@node1 ~]#

STARTUP SEQUENCE OF ONLY ONE NODE IN A CLUSTER

Check And Scan ASM Discs
[root@node1 ~]# ll /dev/oracleasm/disks/
[root@node1 ~]# oracleasm scandisks
[root@node1 ~]# ll /dev/oracleasm/disks/

Check And Start Oracle High Availability Services On The Local Server
[root@node1 ~]# crsctl check crs
[root@node1 ~]# crsctl start crs
[root@node1 ~]# crsctl check crs

Check And Start Instance
[root@node1 ~]# srvctl status instance -d TEST -i TEST1
[root@node1 ~]# srvctl start instance -d TEST -i TEST1
[root@node1 ~]# srvctl status instance -d TEST -i TEST1

Check Database And ASM Instance
[root@node1 ~]# ps -ef | grep pmon | grep -v grep
grid 9522 1 0 Aug 10 ? 00:00:03 asm_pmon_+ASM1
oracle 12756 1 0 08:00 ? 00:00:00 ora_pmon_TEST1

[root@node1 ~]# 

Tuesday, July 25, 2023

STEP BY STEP MANUAL DATABASE CREATION IN LINUX ORACLE 11G

 

STEP BY STEP MANUAL DATABASE CREATION IN LINUX ORACLE 11G

Create the database manually, using CREATE DATABASE statement. Sometimes as a DBA we are not able to use GUI to create a database in this case, we should know syntax of database creation from SQL*Plus.

Step By Step process to create database manually:

Step 1:- Specify an Instance

export ORACLE_SID=test
export ORACLE_HOME=u01/app/oracle/product/11.2.0/dbhome_1/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib

Step 2:-  Create required directories as per your location (I have created Database Directory : /u01/app/oracle/oradata/test)

-pfile

-data

-control

-log

-back

-user

-trace

-archive

-flash_recovery_area (Fast_Recovery_Area)
Step 3:- Create parameter file and modify it by setting minimum required parameters: Save the file (/u01/app/oracle/oradata/test/pfile/inittest.ora)
db_name=’test’

memory_target=500m

processes = 150

audit_file_dest=’/u01/app/oracle/oradata/test/back’audit_trail=’db’

db_block_size=8192

db_domain=”’

db_recovery_file_dest=’/u01/app/oracle/oradata/test/flash_recovery_area’

db_recovery_file_dest_size=2G

diagnostic_dest=’/u01/app/oracle/oradata/test/trace’

dispatchers='(PROTOCOL=TCP) (SERVICE=test)’

open_cursors=300

remote_login_passwordfile=’EXCLUSIVE’

undo_tablespace=’UNDOTBS1′

# You may want to ensure that control files are created on separate physical# devices

control_files = (/u01/app/oracle/oradata/test/control/control1.ctl, /u01/app/oracle/oradata/test/control/control2.ctl)

compatible =’11.2.0′
Step 4:- Create the Password file
$ orapwd file=$ORACLE_HOME/dbs/orapwtest password=test entries=10
Step 5:- Create Server parameter file (SPFILE) using this parameter file and STARTUP the instance in NOMOUNT mode.

$ sqlplus /nolog

SQL> CONNECT SYS AS SYSDBA

SQL> startup nomount pfile=’/u01/app/oracle/oradata/test/pfile/initTEST.ora’;
OR (Use default location to start database with help of pfile. Depend where you have created pfile. If path is not given it will look on DBS location (Default))

SQL> startup nomount pfile=’/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initTEST.ora’;

SQL> CREATE SPFILE FROM PFILE=’/u01/app/oracle/oradata/test/pfile/initTEST.ora’;

Now our instance started, SGA allocated and background processes started
Step 6: CREATE DATABASE (My Directory Locatin:/u01/app/oracle/oradata/test/data)

CREATE DATABASE test
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 1
LOGFILE
GROUP 1 ‘/u01/app/oracle/oradata/test/log/redo1.log’ SIZE 10M,
GROUP 2 ‘/u01/app/oracle/oradata/test/log/redo2.log’ SIZE 10M,
GROUP 3 ‘/u01/app/oracle/oradata/test/log/redo3.log’ SIZE 10M
DATAFILE
‘/u01/app/oracle/oradata/test/data/system.dbf’ size 100M REUSE
sysaux datafile ‘/u01/app/oracle/oradata/test/data/sysaux.dbf’ size 100m
undo tablespace UNDOTBS1
datafile ‘/u01/app/oracle/oradata/test/data/undo1.dbf’ size 100m
DEFAULT TEMPORARY TABLESPACE temp1
TEMPFILE ‘/u01/app/oracle/oradata/test/data/temp01.dbf’
SIZE 100M REUSE
CHARACTER SET AL32UTF8
;

Step 7:- Run Scripts to Build Data Dictionary Views

Run the scripts necessary to build data dictionary views, synonyms, and PL/SQL packages, and to support proper functioning of SQL*Plus:
@?/rdbms/admin/catalog.sql

@?/rdbms/admin/catproc.sql

@?/sqlplus/admin/pupbld.sql

SQL> EXIT

Congratulation your database is created successfully.

Interview Question.
What is the use of CATALOG.SQL scripts ?

CATALOG.SQL: Creates the views of the data dictionary tables, the dynamic performance views, and public synonyms for many of the views. Grants PUBLIC access to the synonyms.

What is the use of CATPROC.SQL ?

CATPROC.SQL: Runs all scripts required for or used with PL/SQL.

What is the use of PUPBLD.SQL ?

PUPBLD.SQL Required for SQL*Plus. Enables SQL*Plus to disable commands by user.

SQL> show parameter spfile;

NAME TYPE VALUE
———————————— ———– —————————————————————————————-
spfile string /u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfiletest.ora

SQL> select name from v$database;

NAME
————–
TEST

SQL> select name from v$controlfile;

NAME
——————————————————————————–
/u01/app/oracle/oradata/test/control/control1.ctl
/u01/app/oracle/oradata/test/control/control2.ctl

SQL> select name from v$datafile;

NAME
——————————————————————————–
/u01/app/oracle/oradata/test/data/system.dbf
/u01/app/oracle/oradata/test/data/sysaux.dbf
/u01/app/oracle/oradata/test/data/undo1.dbf

SQL> select name from v$tempfile;

NAME
——————————————————————————–
/u01/app/oracle/oradata/test/data/temp01.dbf

SQL> select member from v$logfile;

MEMBER
——————————————————————————–
/u01/app/oracle/oradata/test/log/redo1.log
/u01/app/oracle/oradata/test/log/redo2.log
/u01/app/oracle/oradata/test/log/redo3.log

 

Thursday, July 13, 2023

Database full recovery and restore right upto the last online redolog transaction:

 

Database full recovery and restore right upto the last online redolog transaction:

Verify which backup you have:

Rman target /

List backup;

Inr 0




Incr 1

               
    












Spool remove_database_files.sh

/



Spool off

Exit




Vi remove_database_files.sh

:wq

Sh ./remove_database_files.sh

At this point the database data files got completely deleted from os level

How to restore and recover full database at this point:






List backup:

RMAN>restore database;

Here it will restore from incr 0




 

As you see it will restore from _c2kxcltc_bkp

Which has incr 0 backup



2.

RMAN>recover database;

Note: here recover database will recover from incr 1



See it includes incr 1




Finally

RMAN>Alter database open;




Exit

Sqlplus / as sysdba







Exit

To check trace log

Cd /home/oracle/diag/rdbms/orcl/trace

Vi ale*.log

You can see

Recovery of online redo log



 


 

 

 

 

Wednesday, July 5, 2023

How To Connect With RMAN in Oracle Database by Oracle OCE Mr.Ahmad

 Learn different ways to connect with Recovery Manager (RMAN) in Oracle Database by Oracle OCE Mr.Ahmad.

------------------------------------------------------------------------ ►►►LINKS◄◄◄ website: https://afgdba.blogspot.com/ Previous Tutorial :    • RMAN command to B...   ENTOPDBA YouTube:    / @ucjnmklhj8p2b0qs...   @entopdba501




RMAN command to Backup Oracle database and recovery | Oracle DBA Tutorial

Oracle DBA Tutorial
RMAN command to Backup Oracle database and recovery




Watch more Videos at:    / @entopdba501   Lecture By: Mr. Ahmad Ali, entopdba USA limited.


Monday, February 6, 2023

SQL Function | single row and multi row functions in sql Lesson 11 | Part 02

 In this Video we will learn SQL Functions: SQL functions are built into Oracle Database and are available for use in various appropriate SQL statements. Do not confuse SQL functions with user-defined functions written in PL/SQL.




Monday, January 30, 2023

SQL Function | single row and multi row functions in sql Lesson 10

 SQL Function single row and multiple row function.

Lesson 10 uploaded in YouTube.





👋 Additional resources - Download & install Oracle 19C database : https://www.oracle.com/database/techn... - Download & install SQL Developer 12C: https://www.oracle.com/database/sqlde... 🚩 Connect with me on social Facebook: https://www.facebook.com/afgblog Website: https://afgdba.blogspot.com/ 🔔 Subscribe to my YouTube channel https://www.youtube.com/@entopdba501

Logical Standby in Oracle Data Guard Overview

  In Oracle Data Guard , a Logical Standby Database is a standby database that: Receives redo data from the Primary database Convert...