Search This Blog

Total Pageviews

Saturday, 24 December 2016

Oracle oradebug



SQL> !ps -e -o pcpu,user,pid,args | sort -k 1 | grep oracle
0.0 oracle 15876 -bash
0.0 oracle 15902 sqlplus
0.0 oracle 15978 oracleorcl (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
0.0 oracle 15982 ora_w000_orcl
0.0 oracle 16387 /bin/bash -c ps -e -o pcpu,user,pid,args | sort -k 1 | grep oracle
0.0 oracle 16389 sort -k 1
0.0 oracle 16390 grep oracle
0.0 oracle 29333 /opt/app/oracle/product/11.2/bin/tnslsnr LISTENER -inherit -----
0.0 oracle 5867 -bash
0.0 oracle 6002 ora_pmon_orcl
0.0 oracle 6004 ora_vktm_orcl
0.0 oracle 6008 ora_gen0_orcl
0.0 oracle 6010 ora_diag_orcl
0.0 oracle 6012 ora_dbrm_orcl
0.0 oracle 6014 ora_psp0_orcl
0.0 oracle 6016 ora_dia0_orcl
0.0 oracle 6018 ora_mman_orcl
0.0 oracle 6020 ora_dbw0_orcl
0.0 oracle 6022 ora_lgwr_orcl
0.0 oracle 6024 ora_ckpt_orcl
0.0 oracle 6026 ora_smon_orcl
0.0 oracle 6028 ora_reco_orcl
0.0 oracle 6030 ora_mmon_orcl
0.0 oracle 6032 ora_mmnl_orcl
0.0 oracle 6034 ora_d000_orcl
0.0 oracle 6036 ora_s000_orcl
0.0 oracle 6101 ora_arc0_orcl
0.0 oracle 6103 ora_arc1_orcl
0.0 oracle 6105 ora_arc2_orcl
0.0 oracle 6107 ora_arc3_orcl
0.0 oracle 6117 ora_qmnc_orcl
0.0 oracle 6137 ora_q000_orcl
0.0 oracle 6139 ora_q001_orcl
0.0 oracle 6143 ora_cjq0_orcl
0.0 oracle 6685 ora_smco_orcl
0.0 root 15872 su - oracle
0.0 root 5859 su - oracle
100 oracle 16388 ps -e -o pcpu,user,pid,args

SQL> oradebug setospid 29333 ---- for LISTENER
ORA-00075: process "Unix process pid: 29333, image: " not found in this instance

SQL> oradebug setospid 6101
Oracle pid: 20, Unix process pid: 6101, image: oracle@apt-amd-02 (ARC0)

SQL> oradebug event 10046 trace name context off;
Statement processed.

SQL> oradebug TRACEFILE_NAME
/opt/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_arc0_6101.trc

SQL> oradebug suspend
Statement processed.

SQL> oradebug resume
Statement processed.

SQL> oradebug event 10046 trace name context off;
Statement processed.

Sunday, 11 December 2016

connect to a pluggable database without password ..

connect to a pluggable database without password .. 



connect to a pluggable database without password 

This note explains how one can configure SEPS ( Secure External Password Store) to connect to a pluggable database. 
This is useful when creating passwordless connections for expdp. 



on sqlnet.ora


Example ...
WALLET_LOCATION =
(SOURCE =
(METHOD = FILE)
(METHOD_DATA =
(DIRECTORY =<wallet location directory>)
)
)

SQLNET.WALLET_OVERRIDE = TRUE
SSL_CLIENT_AUTHENTICATION = FALSE
SSL_VERSION = 0



---- 
WALLET_LOCATION = (SOURCE =(METHOD = FILE) (METHOD_DATA = (DIRECTORY =/u01/app/oracle/wallet)))

SQLNET.WALLET_OVERRIDE = TRUE
SSL_CLIENT_AUTHENTICATION = FALSE
SSL_VERSION = 0




 mkstore -wrl . -create
Oracle Secret Store Tool : Version 12.1.0.2
Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.

Enter password:
Enter password again:


mkstore -wrl "/u01/app/oracle/wallet" -createCredential vihaan anuj vihaan

mkstore -wrl "<wallet location directory>" -createCredential <Pluggable DB service name> <username> <password>



mkstore -wrl "/u01/app/oracle/wallet" -createCredential vihaan anuj vihaan
Oracle Secret Store Tool : Version 12.1.0.2
Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.

Enter wallet password:
Create credential oracle.security.client.connect_string1


on tnsnames.ora


Example ..

<Pluggable DB service name> =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = <hostname>)(PORT = <port#>))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = <Pluggable DB SID>)
)
)



vihaan =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.71)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = vihaan)
      (SERVER = dedicated)
    )
  )



[oracle@ora-prim wallet]$ tnsping vihaan

TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 08-DEC-2016 17:40:47

Copyright (c) 1997, 2014, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.71)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = vihaan) (SERVER = dedicated)))
OK (10 msec)



[oracle@ora-prim admin]$ sqlplus /@vihaan

SQL*Plus: Release 12.1.0.2.0 Production on Thu Dec 8 17:41:57 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Last Successful login time: Thu Dec 08 2016 17:34:26 +00:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options



expdp /@vihaan dumpfile=INT1.DMP directory=anujdir logfile=INT1.LOG tables='INTERVAL_SALES' CONSISTENT=Y  ESTIMATE=STATISTICS reuse_dumpfiles=y

Export: Release 12.1.0.2.0 - Production on Thu Dec 8 18:20:00 2016

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Legacy Mode Active due to the following parameters:
Legacy Mode Parameter: "consistent=TRUE" Location: Command Line, Replaced with: "flashback_time=TO_TIMESTAMP('2016-12-08 18:20:00', 'YYYY-MM-DD HH24:MI:SS')"
Legacy Mode has set reuse_dumpfiles=true parameter.
Starting "ANUJ"."SYS_EXPORT_TABLE_01":  /********@vihaan dumpfile=INT1.DMP directory=anujdir logfile=INT1.LOG tables=INTERVAL_SALES flashback_time=TO_TIMESTAMP('2016-12-08 18:20:00', 'YYYY-MM-DD HH24:MI:SS') ESTIMATE=STATISTICS reuse_dumpfiles=y
Estimate in progress using STATISTICS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
.  estimated "ANUJ"."INTERVAL_SALES":"P0"                4.683 KB
.  estimated "ANUJ"."INTERVAL_SALES":"P1"                4.683 KB
.  estimated "ANUJ"."INTERVAL_SALES":"P2"                4.683 KB
.  estimated "ANUJ"."INTERVAL_SALES":"P3"                4.683 KB
.  estimated "ANUJ"."INTERVAL_SALES":"SYS_P261"          4.683 KB
.  estimated "ANUJ"."INTERVAL_SALES":"SYS_P262"          4.683 KB
.  estimated "ANUJ"."INTERVAL_SALES":"SYS_P263"          4.683 KB
.  estimated "ANUJ"."INTERVAL_SALES":"SYS_P264"          4.683 KB
.  estimated "ANUJ"."INTERVAL_SALES":"SYS_P265"          4.683 KB
.  estimated "ANUJ"."INTERVAL_SALES":"SYS_P266"          4.683 KB
.  estimated "ANUJ"."INTERVAL_SALES":"SYS_P267"          4.683 KB
Total estimation using STATISTICS method: 51.51 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
. . exported "ANUJ"."INTERVAL_SALES":"P0"                7.773 KB       0 rows
. . exported "ANUJ"."INTERVAL_SALES":"P1"                7.773 KB       0 rows
. . exported "ANUJ"."INTERVAL_SALES":"P2"                7.773 KB       0 rows
. . exported "ANUJ"."INTERVAL_SALES":"P3"                7.773 KB       0 rows
. . exported "ANUJ"."INTERVAL_SALES":"SYS_P261"          7.812 KB       1 rows
. . exported "ANUJ"."INTERVAL_SALES":"SYS_P262"          7.812 KB       1 rows
. . exported "ANUJ"."INTERVAL_SALES":"SYS_P263"          7.812 KB       1 rows
. . exported "ANUJ"."INTERVAL_SALES":"SYS_P264"          7.812 KB       1 rows
. . exported "ANUJ"."INTERVAL_SALES":"SYS_P265"          7.812 KB       1 rows
. . exported "ANUJ"."INTERVAL_SALES":"SYS_P266"          7.812 KB       1 rows
. . exported "ANUJ"."INTERVAL_SALES":"SYS_P267"          7.812 KB       1 rows
Master table "ANUJ"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for ANUJ.SYS_EXPORT_TABLE_01 is:
  /home/oracle/INT1.DMP
Job "ANUJ"."SYS_EXPORT_TABLE_01" successfully completed at Thu Dec 8 18:21:07 2016 elapsed 0 00:00:51

How to use SYSBACKUP privilege to perform backup and recovery tasks without accessing data....

How to use SYSBACKUP privilege to perform backup and recovery tasks without accessing data....


SYSBACKUP  role 


create OS user
useradd -c "Oracle backup user"  orabackup -p root123


[root@ora-prim ~]# su - orabackup

[orabackup@ora-prim ~]$ pwd
/home/orabackup



 cd /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/

[root@ora-prim admin]# ls -ltr
total 16
-rw-r--r-- 1 oracle oinstall 373 Oct 31  2013 shrept.lst
drwxr-xr-x 2 oracle oinstall  61 Nov 27 19:49 samples
-rw-r--r-- 1 oracle oinstall 460 Dec  3 22:51 listener.ora
-rw-r--r-- 1 oracle oinstall 601 Dec  8 17:40 tnsnames.ora
-rw-r--r-- 1 oracle oinstall 177 Dec  8 17:41 sqlnet.ora

[root@ora-prim admin]# cp tnsnames.ora /home/orabackup



[root@ora-prim orabackup]# chown orabackup:orabackup tnsnames.ora

[root@ora-prim orabackup]# pwd
/home/orabackup

[root@ora-prim orabackup]# cp /home/oracle/.bash_profile .


[orabackup@ora-prim ~]$ cat .bash_profile

cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

export ORACLE_UNQNAME=prim
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
export ORACLE_SID=prim
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export TNS_ADMIN=/home/orabackup   




[orabackup@ora-prim ~]$ sqlplus anuj/vihaan@vihaan

SQL*Plus: Release 12.1.0.2.0 Production on Sat Dec 10 08:00:43 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Last Successful login time: Sat Dec 10 2016 06:14:29 +00:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options


SQL> !id
uid=1001(orabackup) gid=1001(orabackup) groups=1001(orabackup)


SQL> grant sysbackup to orabackup ;
grant sysbackup to orabackup
                   *
ERROR at line 1:
ORA-01917: user or role 'ORABACKUP' does not exist

good news ...


Now creating new user 


SQL> alter session set container=vihaan ;

Session altered.

SQL> create user ORABACKUP identified by root123 ;

User created.

SQL> grant sysbackup to orabackup ;

Grant succeeded.




[root@ora-prim orabackup]# su - orabackup
Last login: Sat Dec 10 07:58:34 GMT 2016 on pts/0
[orabackup@ora-prim ~]$ sqlplus ORABACKUP/root123@vihaan as sysbackup

SQL*Plus: Release 12.1.0.2.0 Production on Sat Dec 10 08:13:49 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options


SQL>  select * from v$pwfile_users;

USERNAME                       SYSDB SYSOP SYSAS SYSBA SYSDG SYSKM     CON_ID
------------------------------ ----- ----- ----- ----- ----- ----- ----------
SYS                            TRUE  TRUE  FALSE FALSE FALSE FALSE          0
ORABACKUP                      FALSE FALSE FALSE TRUE  FALSE FALSE          3


set pages 200 linesize 200 
col grantee      format a25
col granted_role format a25
select * from dba_sys_privs where grantee = 'SYSBACKUP';


col current_schema format a20
col session_user format a20
select sys_context('USERENV', 'CURRENT_SCHEMA') current_schema, sys_context('USERENV', 'SESSION_USER') session_user from dual;


CURRENT_SCHEMA       SESSION_USER
-------------------- --------------------
SYS                  SYSBACKUP

 SQL> show user
USER is "SYSBACKUP"


RMAN> connect target ORABACKUP/root123@vihaan as sysbackup

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "as": expecting one of: "newline, ;"
RMAN-01007: at line 1 column 41 file: standard input



use like this ...

RMAN> connect target 'ORABACKUP/root123@vihaan as sysbackup'

connected to target database: PRIM (DBID=4221955747)



RMAN> select sys_context('USERENV', 'CURRENT_SCHEMA') current_schema, sys_context('USERENV', 'SESSION_USER') session_user from dual;

using target database control file instead of recovery catalog


CURRENT_SCHEMA
--------------------------------------------------------------------------------
SESSION_USER
--------------------------------------------------------------------------------

SYS
SYSBACKUP


RMAN> list backup;

specification does not match any backup in the repository



RMAN> backup current controlfile;

Starting backup at 10-DEC-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=62 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 10-DEC-16
channel ORA_DISK_1: finished piece 1 at 10-DEC-16
piece handle=/u01/app/oracle/fast_recovery_area/PRIM/42C8A9F4DB2B18EBE0534700A8C0C45C/backupset/2016_12_10/o1_mf_ncnnf_TAG20161210T082630_d4qh1v9r_.bkp tag=TAG20161210T082630 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:09
Finished backup at 10-DEC-16

Starting Control File and SPFILE Autobackup at 10-DEC-16
piece handle=/u01/app/oracle/fast_recovery_area/PRIM/autobackup/2016_12_10/o1_mf_s_930212804_d4qh247h_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 10-DEC-16

RMAN>  list backup;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2       Full    17.23M     DISK        00:00:06     10-DEC-16
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20161210T082630
        Piece Name: /u01/app/oracle/fast_recovery_area/PRIM/42C8A9F4DB2B18EBE0534700A8C0C45C/backupset/2016_12_10/o1_mf_ncnnf_TAG20161210T082630_d4qh1v9r_.bkp
  Control File Included: Ckp SCN: 2518618      Ckp time: 10-DEC-16

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3       Full    17.27M     DISK        00:00:00     10-DEC-16
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20161210T082644
        Piece Name: /u01/app/oracle/fast_recovery_area/PRIM/autobackup/2016_12_10/o1_mf_s_930212804_d4qh247h_.bkp
  SPFILE Included: Modification time: 10-DEC-16
  SPFILE db_unique_name: PRIM
  Control File Included: Ckp SCN: 2518644      Ckp time: 10-DEC-16

Thursday, 1 December 2016

sqlplus / as sysdba ORA-01017: invalid username/password; logon denied


ORA-01017: invalid username/password; logon denied.. 


oracle@generic ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Sun Nov 20 07:08:07 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

ERROR:
ORA-01017: invalid username/password; logon denied



[oracle@generic ~]$ echo $TWO_TASK
ORCL

Unset this variable TWO_TASK  <<<<<<<<<<<<<<<<

[oracle@generic ~]$ unset TWO_TASK

[oracle@generic ~]$ echo $TWO_TASKS


[oracle@generic ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Sun Nov 20 07:20:15 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> 


===========

[oracle@localhost ~]$ ps -ef|grep -i smon
oracle      1970       1  0 05:00 ?        00:00:00 db_smon_FREE
oracle      6247    6193  0 06:26 pts/2    00:00:00 grep --color=auto -i smon

[oracle@localhost ~]$ . oraenv
ORACLE_SID = [FREE] ?
The Oracle base remains unchanged with value /opt/oracle
[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Sun Sep 10 06:26:33 2023
Version 23.2.0.0.0

Copyright (c) 1982, 2023, Oracle.  All rights reserved.

ERROR:
ORA-01017: invalid credential or not authorized; logon denied




[oracle@localhost ~]$ echo $TWO_TASK
FREEPDB1
[oracle@localhost ~]$ unset TWO_TASK  ---- unset 


[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Sun Sep 10 06:28:14 2023
Version 23.2.0.0.0

Copyright (c) 1982, 2023, Oracle.  All rights reserved.


Connected to:
Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0

SQL>


====


connect to user 


 sqlplus hr/hr@//192.168.0.70:1521/freepdb1

SQL*Plus: Release 23.0.0.0.0 - Production on Tue Nov 7 11:46:00 2023
Version 23.3.0.23.09

Copyright (c) 1982, 2023, Oracle.  All rights reserved.

Last Successful login time: Wed Sep 13 2023 19:50:31 +00:00

Connected to:
Oracle Database 23c Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.3.0.23.09

SQL> def
DEFINE _DATE           = "07-NOV-23" (CHAR)
DEFINE _CONNECT_IDENTIFIER = "//192.168.0.70:1521/freepdb1" (CHAR)    <<<<<<<<<<<<---
DEFINE _USER           = "HR" (CHAR)
DEFINE _PRIVILEGE      = "" (CHAR)
DEFINE _SQLPLUS_RELEASE = "2303002309" (CHAR)
DEFINE _EDITOR         = "vi" (CHAR)
DEFINE _O_VERSION      = "Oracle Database 23c Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.3.0.23.09" (CHAR)
DEFINE _O_RELEASE      = "2303002309" (CHAR)
SQL>

SQL> show user
USER is "HR"
SQL>


Friday, 18 November 2016

Oracle datapump Dir & grant Info ....

Oracle datapump Dir & grant Info ....




set heading on linesize 200 pagesize 100 termout on trimout on trimspool on 
col owner            format a10   heading 'Owner'
col directory_name   format a30   heading 'Directory name'
col directory_path   format a90   heading 'Directory path'
select
    owner
  , directory_name
  , directory_path
from  dba_directories
order by owner,directory_name;
clear columns  breaks  computes


col "Directory path" format a90   heading 'Directory path'
select
    *
from  dba_directories
order by owner,directory_name;


create or replace directory data_pump_dir as '<operating_system_path>';

grant read on directory <directory_name> to <schema_name> ;

revoke write on directory <directory_name> from <schema_name> ;



create or replace directory data_pump_dir1 as '/home/oracle';

grant read on directory data_pump_dir1 to scott ;

grant write on directory data_pump_dir1 to scott ;


set linesize 200 pagesize 200 
col owner for a10
col privilege for a10
col directory_path for a50
col grantee         for a20 
col directory_name  for a30 
select d.owner, d.directory_name, p.grantee, p.privilege, d.directory_path from dba_directories d, dba_tab_privs p
where d.owner = p.owner
and d.directory_name = p.table_name
order by d.owner, d.directory_name;


col grantor for a20
col grantee for a20
col table_schema for a20
col table_name for a20
col privilege for a10
select grantor, grantee, table_schema, table_name, privilege from all_tab_privs where table_name = 'EMP';



set lines 200
col privilege for a12
col grantee for a25
col owner for a25
select p.grantee, p.privilege, p.owner, d.directory_name from dba_tab_privs p, dba_directories d
WHERE p.table_name=d.directory_name
  and (grantee IN ('TEST', 'PUBLIC')  OR grantee IN (select granted_role from dba_role_privs  where grantee IN ('TEST', 'PUBLIC')))
ORDER BY 4,3,2;



set lines 80  
col privilege for a40  
SELECT grantee, granted_role, default_role  FROM dba_role_privs  
WHERE granted_role IN ('DBA', 'EXP_FULL_DATABASE', 'IMP_FULL_DATABASE')  
ORDER BY 1,2; 



set linesize 250 trimspool on
set pagesize 100

col owner format a15
col directory_name format a30
col directory_path format a100
col oreated format a19
col last_ddl_time format a19

select
distinct
o.con_id
,d.owner
, d.directory_name
, to_char(o.created,'dd-mm-yyyy hh24:mi:ss') oreated
, to_char(o.last_ddl_time,'dd-mm-yyyy hh24:mi:ss') last_ddl_time
, d.directory_path
from cdb_directories d
join cdb_objects o on o.owner = d.owner and o.object_name = d.directory_name
order by 1,2,3
/

set pagesize 0
SELECT 'drop table ' || owner_name || '.' || job_name || ';' FROM dba_datapump_jobs 
WHERE state='NOT RUNNING' 
and job_name NOT LIKE 'BIN$%'
;


 expdp userid=scott/tiger@//rac02.int.s.de.net:1523/anujz tables=scott.emp directory=DATA_PUMP_DIR dumpfile=emp1.dmp logfile=emp.log

Monday, 31 October 2016

ORA-16179: incremental changes to "log_archive_dest_1" not allowed with SPFILE

ORA-16179: incremental changes to "log_archive_dest_1" not allowed with SPFILE ... 


SQL> alter system set log_archive_dest_1='+LOGS' SCOPE=SPFILE;
alter system set log_archive_dest_1='+LOGS' SCOPE=SPFILE
*
ERROR at line 1:
ORA-32017: failure in updating SPFILE
ORA-16179: incremental changes to "log_archive_dest_1" not allowed with SPFILE


------ use "LOCATION" variable with LOG_ARCHIVE_DEST_1 parameter

SQL> ALTER SYSTEM SET log_archive_dest_1='LOCATION=+LOGS';

System altered.


Wednesday, 19 October 2016

Oracle Home clone or clone oracle home


Oracle  Home clone ...


Clone Oracle Home




aim to clone oracle home on same host from oracle owner to oraaj owner 



From home /u01/app/oracle/product/11.2.0/dbhome_1 as oracle user and owner oracle

To home /u01/app/oraaj/product/11.2.0/dbhome_1 as oracle user and owner oraaj



create new user 

/usr/sbin/useradd -d /home/oraaj -g oinstall -G dba,asmdba -s /bin/bash -u 1500 oraaj

set passwd ...

echo "oracle" | /usr/bin/passwd oraaj --stdin



mkdir -p /u01/app/oraaj/product/11.2.0

cd /u01/app/
ls -ltr
chown -R oraaj:oinstall oraaj/





as root 

For Zip and tar

cd /u01/app/oracle/product/11.2.0/

tar cvf - dbhome_1 | gzip -c > dbhome_1.tar.gz ---------- [or for full path tar cvf - /u01/app/oracle/product/11.2.0/dbhome_1 | gzip -c > dbhome_1.tar.gz]



[root@oraasm11g 11.2.0]# ls -ltr
total 2638088
drwxr-xr-x 77 oracle oinstall 4096 Jun 14 10:27 dbhome_1
-rw-r--r-- 1 root root 2701390392 Oct 14 08:02 dbhome_1.tar.gz

mv dbhome_1.tar.gz /u01/app/oraaj/product/11.2.0/


unzip and untar the file 

[root@oraasm11g 11.2.0]# gunzip -c dbhome_1.tar.gz | tar xf -


chown -R oraaj:oinstall dbhome_1/


[root@oraasm11g ~]# su - oraaj

[oraaj@oraasm11g ~]$ id
uid=1500(oraaj) gid=54321(oinstall) groups=54321(oinstall),1300(asmdba),54322(dba)




export ORACLE_HOME=/u01/app/oraaj/product/11.2.0/dbhome_1



[oraaj@oraasm11g dbhome_1]$ echo $ORACLE_HOME
/u01/app/oraaj/product/11.2.0/dbhome_1



$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/clone/bin/clone.pl ORACLE_BASE="/u01/app/oraaj/" ORACLE_HOME="/u01/app/oraaj/product/11.2.0/dbhome_1" OSDBA_GROUP=dba -defaultHomeName ORACLE_HOME_NAME="ORAAJ_HOME"

./runInstaller -clone -waitForCompletion "ORACLE_BASE=/u01/app/oraaj/" "ORACLE_HOME=/u01/app/oraaj/product/11.2.0/dbhome_1" "oracle_install_OSDBA=dba" -defaultHomeName "ORACLE_HOME_NAME=ORAAJ_HOME" -silent -noConfig -nowait
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB. Actual 3999 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2016-10-14_10-07-17AM. Please wait ...
Oracle Universal Installer, Version 11.2.0.4.0 Production
Copyright (C) 1999, 2013, Oracle. All rights reserved.

You can find the log of this install session at:
 /u01/app/oraInventory/logs/cloneActions2016-10-14_10-07-17AM.log
....................................................................................................
 100% Done.



Installation in progress (Friday, October 14, 2016 10:07:48 AM BST)
.............................................................................. 78% Done.
Install successful

Linking in progress (Friday, October 14, 2016 10:08:16 AM BST)
Link successful

Setup in progress (Friday, October 14, 2016 10:11:51 AM BST)
Setup successful

End of install phases.(Friday, October 14, 2016 10:12:30 AM BST)
WARNING:
The following configuration scripts need to be executed as the "root" user.
/u01/app/oraaj/product/11.2.0/dbhome_1/root.sh
To execute the configuration scripts:
 1. Open a terminal window
 2. Log in as "root"
 3. Run the scripts

The cloning of ORAAJ_HOME was successful.
Please check '/u01/app/oraInventory/logs/cloneActions2016-10-14_10-07-17AM.log' for more details.


============

as a root !!!!!!!!!!!!!!


[root@oraasm11g ~]# /u01/app/oraaj/product/11.2.0/dbhome_1/root.sh
Check /u01/app/oraaj/product/11.2.0/dbhome_1/install/root_oraasm11g_2016-10-14_10-13-55.log for the output of root script
[root@oraasm11g ~]# cat /u01/app/oraaj/product/11.2.0/dbhome_1/install/root_oraasm11g_2016-10-14_10-13-55.log
Performing root user operation for Oracle 11g

The following environment variables are set as:
 ORACLE_OWNER= oraaj
 ORACLE_HOME= /u01/app/oraaj/product/11.2.0/dbhome_1
 Copying dbhome to /usr/local/bin ...
 Copying oraenv to /usr/local/bin ...
 Copying coraenv to /usr/local/bin ...

Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
Finished product-specific root actions.



*****************************************************************




to detach home if required 


./runInstaller.sh -silent -detachHome ORACLE_HOME="/u01/app/oraaj/product/11.2.0/dbhome_1"
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB. Actual 3999 MB Passed
The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /u01/app/oraInventory
'DetachHome' was successful.

Oracle DBA

anuj blog Archive