Sunday, 24 December 2017

ORA-00119: invalid specification for system parameter LOCAL_LISTENER

ERROE:

SQL> startup
ORA-00119: invalid specification for system parameter LOCAL_LISTENER
ORA-00132: syntax error or unresolved network name 'LISTENER_PROD'



Solution:

~]$ cd $ORACLE_HOME/dbs

dbs]$ vi initprod.ora

You've only one listener i.e. LISTENER where MYSID is your service. Since you're using only one default listener you don't need to have local_listenerset. Hence, you can remove the local_listener entry from your pfile initialization parameters and save (:wq!)  the parameter file.


~]$ sqlplus / as sysdba

SQL> startup
ORACLE instance started.
Total System Global Area  830930944 bytes
Fixed Size                  2232920 bytes
Variable Size             490737064 bytes
Database Buffers          335544320 bytes
Redo Buffers                2416640 bytes
Database mounted.
Database opened.
SQL>


Thursday, 21 December 2017

RMAN-06059: expected archived log not found, lost of archived log compromises recoverability


RMAN attempted to backup an archive log file, but couldn't find it.

This can happen for a variety of reasons; the file has been manually moved or deleted, the archive log destination has recently been changed, the file has been compressed, etc.


RMAN> backup archivelog all;

Starting backup at 22-DEC-17
current log archived
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 12/22/2017 12:23:08
RMAN-06059: expected archived log not found, loss of archived log compromises recoverability
ORA-19625: error identifying file /u01/home/app/prod/arch/1_6_961779399.dbf
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3


Your options are either to restore the missing file(s), or to perform a crosscheck. To perform a crosscheck, run the following command from within RMAN:

RMAN> change archivelog all crosscheck;
              Crosschecked 75 objects


RMAN> backup archivelog all;

Starting backup at 22-DEC-17
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=3 RECID=1 STAMP=961783298
input archived log thread=1 sequence=4 RECID=2 STAMP=961783689
input archived log thread=1 sequence=5 RECID=3 STAMP=961785306
input archived log thread=1 sequence=78 RECID=83 STAMP=963404881
channel ORA_DISK_1: starting piece 1 at 22-DEC-17
channel ORA_DISK_1: finished piece 1 at 22-DEC-17
piece handle=/u01/home/prodbkp/offbkp/HYD/backupset/2017_12_22/o1_mf_annnn_TAG20171222T122801_f3sc7t1y_.bkp tag=TAG20171222T122801 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
Finished backup at 22-DEC-17

Starting Control File Autobackup at 22-DEC-17
piece handle=/u01/home/prodbkp/offbkp/HYD/autobackup/2017_12_22/o1_mf_n_963404917_f3sc8xq6_.bkp comment=NONE
Finished Control File Autobackup at 22-DEC-17



It is advisable to perform a full backup of the database at this point.

When an archive log crosscheck is performed, RMAN checks each archive log in turn to make sure that it exists on disk (or tape). Those that are missing are marked as unavailable. If you have got missing logs, this won't bring them back. It will allow you to get past this error and back-up the database though.

ORA-01075: you are currently logged on

ERROR:

ORA-01075: you are currently logged on


ACTION:

~$ echo $ORACLE_SID
PROD

~$ ps -ef | grep prod

oracle    1943     1  0 23:16 ?        00:00:00 ora_pmon_prod

oracle    1947     1  0 23:16 ?        00:00:00 ora_psp0_prod

oracle    1951     1  0 23:16 ?        00:00:02 ora_vktm_prod

oracle    1957     1  0 23:16 ?        00:00:00 ora_gen0_prod

oracle    1961     1  0 23:16 ?        00:00:00 ora_diag_prod

oracle    1965     1  0 23:16 ?        00:00:00 ora_dbrm_prod

oracle    1969     1  0 23:16 ?        00:00:00 ora_dia0_prod

oracle    1973     1  0 23:16 ?        00:00:00 ora_mman_prod

oracle    1977     1  0 23:16 ?        00:00:00 ora_dbw0_prod

oracle    1981     1  0 23:16 ?        00:00:03 ora_lgwr_prod

oracle    1985     1  0 23:16 ?        00:00:00 ora_ckpt_prod


~$ kill -9 1943                    ( Solution: killed PMON,SMON pids )

$ sqlplus / as sysdba

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

Sunday, 10 December 2017

AWR REPORT (Automatic Workload Repository) Practical

AWR REPORT (Automatic Workload Repository)

~]$ export ORACLE_SID=dev
~]$ sqlplus / as sysdba

SQL> select name,instance_name,status from v$database,v$instance;    (open)


Taking snapshot
SQL> exec dbms_workload_repository.create_snapshot;

SQL> select DBID,SNAP_ID,BEGIN_INTERVAL_TIME,END_INTERVAL_TIME from dba_hist_snapshot;

Generating AWR report
SQL> @$ORACLE_HOME/rdbms/admin/awrrpt.sql

Specify the Report Type
Enter value for report_type: html

Specify the number of days of snapshots to choose from
Enter value for num_days: 1                          (base on snap id how much there)

Specify the Begin and End Snapshot Ids
Enter value for begin_snap: 1
Begin Snapshot Id specified: 1
Enter value for end_snap: 2
End Snapshot Id specified: 2

Specify the Report Name
Enter value for report_name: awrrpt.html

SQL> exit
~]$ firefox awrrpt.html

~]$ export ORACLE_SID=dev
~]$ sqlplus / as sysdba

Dropping the snapshots
Sql>exec dbms_workload_repository.drop_snapshot_range(low_snap_id=>21,
high_snap_id=>22);


~]$ export ORACLE_SID=dev
~]$ sqlplus / as sysdba

SQL> @$ORACLE_HOME/rdbms/admin/addmrpt.sql

Specify the Begin and End Snapshot Ids
Enter value for begin_snap: 1
Begin Snapshot Id specified: 1
Enter value for end_snap: 3
End Snapshot Id specified: 3

Specify the Report Name
Enter value for report_name: addm.html

Sql> exit

~]$ Firefox addm.html

~]$ export ORACLE_SID=dev
~]$ sqlplus / as sysdba


Generating Ash report
Sql>$ORACLE_HOME/rdbms/admin/ashrpt.sql;

Specify the Report Type
Enter value for report_type: html

Instances in this Workload Repository schema
Using instance number(s): 1

Specify the Report Name
Enter value for report_name: ash.html

SQL> exit

~]$ firefox ash.html

~]$ export ORACLE_SID=prod
~]$ sqlplus / as sysdba

SQL> grant connect,resource to u1 identified by u1;

SQL> conn u1/u1

SQL> create table emp (empno number(10),empname varchar(10));

SQL> insert into emp values(&empno,'&empname');
(Again 4 time / for insert values) then               sql> commit;

SQL> conn / as sysdba

SQL> alter session set sql_trace=true;

SQL> select *from u1.emp where empno=1212;

SQL> alter session set sql_trace=false;

SQL> exit



A trace file will be generated in user_dump_dest location
~]$ cd app
app]$ cd diag/
diag]$ cd rdbms/
rdbms]$ cd prod/
prod]$ cd prod/
prod]$ cd trace/
trace]$ ls –ltr

Converting trace file into human readable format using tkprof utility
trace]$ tkprof prod_ora_23552.trc
:q!

~]$ export ORACLE_SID=prod
~]$ sqlplus / as sysdba

SYS>grant connect,resource to riaz identified by riaz;

SYS>conn riaz/riaz


Open new terminal
~]$ export ORACLE_SID=prod
~]$ sqlplus / as sysdba

SYS>
SYS>select SERIAL#,USERNAME,SID from v$session where username='RIAZ';

SYS>exec dbms_monitor.session_trace_enable(SESSION_ID=>1,SERIAL_NUM=>23);

SYS>exec dbms_monitor.session_trace_disable(SESSION_ID=>1,SERIAL_NUM=>23);

~]$ export ORACLE_SID=prod
~]$ sqlplus / as sysdba

SYS>create user u1 identified by u1;

SYS>grant connect,resource to u1;
SYS>conn u1/u1

U1>create table emp (eno number(10),ename varchar2(10));

U1>insert into emp values(&eno,'&ename');
(Again 4 time / for insert values) then               sql> commit;

U1>select ename, rowid, rownum from emp;

U1>explain plan set statement_id='ID1' for select * from emp where ename='JACK';

U1>select * from table(dbms_xplan.display('PLAN_TABLE','ID1','BASIC'));

U1>select operation,options from plan_table where statement_id='ID1';

Online (Hot) backup (User Managed) practical

Online (Hot) backup:-

SQL> archive log list                                 (Enabled)

SQL> alter system switch logfile;

SQL> archive log list                                 (Enabled)



1.    Put the database into backup mode.

SQL> select * from v$backup;                (STATUS CHANGE#= NOT ACTIVE)

SQL> alter database begin backup;

SQL> select * from v$backup;                (STATUS = ACTIVE)



2.    Go to OS level and copy all datafiles.
SQL> exit

~]$ mkdir onlinebkp

~]$ cd onlinebkp/

onlinebkp]$ pwd
onlinebkp]$ cd

~]$ cd prod

prod]$ cp -rvf *.dbf /u01/home/onlinebkp

prod]$ cd
~]$ cd onlinebkp

onlinebkp]$ sqlplus / as sysdba



3.    End the backup mode of database.

SQL> select * from v$backup;                (STATUS = ACTIVE)

SQL> alter database end backup;

SQL> select * from v$backup;                (STATUS = NOT ACTIVE)



4.    Take backup of control file.

SQL> alter database backup controlfile to trace as '/u01/home/onlinebkp/bkp.ctl';




Online Backup of Database Tablespace Wise
To backup data files of a particular Tablespace

SQL> alter system switch logfile;

SQL> archive log list

SQL> alter tablespace tech begin backup;
SQL> exit

~]$ cd prod

prod]$ cp -rvf tech01.dbf /u01/home/onlinebkp

prod]$ cd
~]$ cd onlinebkp

onlinebkp]$ sqlplus / as sysdba

SQL> alter tablespace tech end backup;


Views:-
V$backup, V$datafile, V$controlfile
V$datafile_header




To Take the Backup of Oracle Software/Binaries (ORACLE_HOME):-

Steps:
1) Stop the db services (instances, listener)
2) Backup the software $cp –R $ORACLE_HOME /backup

3) Startup the db services (instances, listener)

Offline (Cold) backup (User Managed) practical

Offline (Cold) backup:-


$ export ORACLE_SID=prod

$ sqlplus / as sysdba
SQL> startup

SQL> select file_name,tablespace_name from dba_data_files;

SQL> select member from v$logfile;

SQL> select name from v$controlfile;

SQL> shut immediate
SQL> exit

~]$ mkdir offlinebkp

~]$ cd offlinebkp/

offlinebkp]$ pwd

offlinebkp]$ cd

~]$ cd prod

prod]$ cp -rvf *.dbf /u01/home/offlinebkp

prod]$ cp -rvf *.log /u01/home/offlinebkp

prod]$ cp -rvf *.ctl /u01/home/offlinebkp

prod]$ cd
~]$ cd offlinebkp/


VIEWS:-
dba_data_files;

v$logfile;

v$controlfile;

Configure catalog Practical

Configure catalog

Target database (prod) Side:-

$ export ORACLE_SID=prod
$ sqlplus / as sysdba
SQL> startup

Catalog database (test) Side:-

$ export ORACLE_SID=test
$ sqlplus / as sysdba
SQL> startup

Create a tablespace---
SQL> create tablespace cat datafile '/u01/home/test/cat01.dbf' size 50m autoextend on;

Create a user---
SQL> create user cat identified by cat;

SQL> grant connect,resource,recovery_catalog_owner to cat;

SQL> alter user cat default tablespace cat;
SQL> exit

~]$ rman catalog cat/cat

RMAN> create catalog;
SQL> exit

$ netmgr (create listener) -----(service name= Catalog database name)
$ lsnrctl start list_cat



Target database (prod) Side:-

SQL> exit
$ netmgr(create tns) -----(service name= Catalog database name)

$ tnsping tocat

]$ rman target / catalog cat/cat@tocat

RMAN> register database;

Catalog database (test) Side:-

$ sqlplus / as sysdba
SQL> conn cat/cat

SQL> select * from rc_database;

Taking backup of Target db with Catalog From the Target host connect to rman

Target database (prod) Side:-

RMAN> exit
~]$ sqlplus / as sysdba

SQL> archive log list  (enable)
SQL> exit

~]$ rman target / catalog cat/cat@tocat

RMAN> list db_unique_name all;

RMAN> backup database;



Catalog database (test) Side:-

SQL> select DB_NAME,FILE#,FILESIZE,TSNAME from RC_BACKUP_DATAFILE_DETAILS;


VIEWS:-
dba_tablespaces;

dba_data_files;

dba_users;

session_privs;

rc_database;


RC_BACKUP_DATAFILE_DETAILS;

relink a single executable (binary file) using ADADMIN utility

In this post, I would like to write something useful for patching and fine-tuning. When times, we have to relink a particular binary file ...