Tuesday, September 17, 2013

TNS-12541: TNS:no listener


##########################
## Error
##########################

TNS-12541: TNS:no listener

### Full Error

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = hostp01)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED)
(SID = oralin)))
TNS-12541: TNS:no listener

##########################
#  Error Occurred
##########################

Error occured while trying to connect a database using its service name in 10.2.0.3.0 version and also tnsping of service name gives TNS-12541

##########################
## Command Executed
##########################

In terminal

tnsping oralin

##########################
## Issue Description.
##########################

### 11.2.0.3.0

#########################################
# 1) check whether listener is running or not
#########################################

+ASM @ hostp01:/opt/oracle/product/11.2.0.1/grid/network/admin
> ps -ef|grep tns
  oracle 16743  2737   0 01:00:52 ?           0:00 /opt/oracle/product/11.2.0.1/grid/bin/tnslsnr LISTENER -inherit
  oracle 16747 11537   0 01:00:58 pts/2       0:00 grep tns

From above output, we can see LISTENER is up and running.

#########################################
# 2) check services listened by LISTENER
#########################################

lsnrctl status LISTENER

+ASM @ hostp01:/opt/oracle/product/11.2.0.1/grid/network/admin
> lsnrctl status LISTENER

LSNRCTL for Solaris: Version 11.2.0.1.0 - Production on 17-SEP-2013 01:00:52

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Solaris: Version 11.2.0.1.0 - Production
Start Date                17-SEP-2013 01:00:52
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/oracle/product/11.2.0.1/grid/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/hostp01/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
The listener supports no services
The command completed successfully

Listener is not listening to any database service. So database is not using this listener.

##########################
## Solution
##########################

#########################################
# 1) check database home ( or ) Grid home listener.ora file
#########################################

Check database home or GRID home listener.ora to find the list of listeners configured and what are the services listening to that.

oralin @ hostp01:/opt/oracle/product/11.1.0.7/db_1/network/admin
> more listener.ora
# listener.ora Network Configuration File: /opt/oracle/product/11.2.0.1/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

LSNR_11G =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = hostp01)(PORT = 1521))
    )
  )

SID_LIST_LSNR_11G =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /opt/oracle/product/11.1.0.7/db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME=+ASM)
      (SID_NAME = +ASM)
      (ORACLE_HOME = /opt/oracle/product/11.2.0.1/grid)
    )
    (SID_DESC =
      (GLOBAL_DBNAME=oralin.example.com)
      (SID_NAME = oralin)
      (ORACLE_HOME = /opt/oracle/product/11.1.0.7/db_1)
    )
  )


From the above output, we can see that a listener named " LSNR_11G " is configured in LISTENER.ora and oralin database is listened using this listener.

#########################################
# 2) Start the Listener
#########################################

+ASM @ hostp01:/opt/oracle/product/11.1.0.7/db_1/network/admin
> lsnrctl start LSNR_11G

LSNRCTL for Solaris: Version 11.2.0.1.0 - Production on 17-SEP-2013 03:34:38

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Starting /opt/oracle/product/11.2.0.1/grid/bin/tnslsnr: please wait...

TNSLSNR for Solaris: Version 11.2.0.1.0 - Production
System parameter file is /opt/oracle/product/11.2.0.1/grid/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/hostp01/lsnr_11g/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostp01)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LSNR_11G
Version                   TNSLSNR for Solaris: Version 11.2.0.1.0 - Production
Start Date                17-SEP-2013 03:34:38
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/oracle/product/11.2.0.1/grid/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/hostp01/lsnr_11g/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostp01)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM", status UNKNOWN, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "oralin.example.com" has 1 instance(s).
  Instance "oralin", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully


+ASM @ hostp01:/opt/oracle/product/11.1.0.7/db_1/network/admin
> ps -ef|grep tns
  oracle 16743  2737   0 01:00:52 ?           0:01 /opt/oracle/product/11.2.0.1/grid/bin/tnslsnr LISTENER -inherit
  oracle 26233  2737   0 03:34:38 ?           0:00 /opt/oracle/product/11.2.0.1/grid/bin/tnslsnr LSNR_11G -inherit
  oracle 26240 11537   0 03:34:53 pts/2       0:00 grep tns

Now the tnsping output is successful and database can be connected.

oralin @ hostp01:/opt/oracle/product/11.1.0.7/db_1/network/admin
> tnsping oralin

TNS Ping Utility for Solaris: Version 11.1.0.7.0 - Production on 17-SEP-2013 04:45:58

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

Used parameter files:
/opt/oracle/product/11.1.0.7/db_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = hostp01)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SID =

oralin)))
OK (0 msec)

Thursday, September 12, 2013

ORA-19502: write error on file "", block number (block size=)


##########################
## Error
##########################

ORA-19502: write error on file "", block number  (block size=)

### Full Error

ORA-19502: write error on file "", block number  (block size=)

##########################
#  Error Occurred
##########################

Error occured while trying to check archive log destination status and its modes in 11.2.0.3.0 version

##########################
## Command Executed
##########################

set lines 200
col dest_name for a20
col db_unique_name for a15

select dest_name,db_unique_name,database_mode,recovery_mode,gap_status,error from v$archive_Dest_Status;

##########################
## Issue Description.
##########################

### 11.2.0.3.0

#########################################
# 1) check the Log archive destination and its status
#########################################

set lines 200
col dest_name for a20
col db_unique_name for a15

select dest_name,db_unique_name,database_mode,recovery_mode,gap_status,error from v$archive_Dest_Status;

DEST_NAME            DB_UNIQUE_NAME  DATABASE_MODE   RECOVERY_MODE           GAP_STATUS               ERROR
-------------------- --------------- --------------- ----------------------- ------------------------ -----------------------------------------------------------------
LOG_ARCHIVE_DEST_1   oralin_prim    OPEN            IDLE
LOG_ARCHIVE_DEST_2   oralin_std    MOUNTED-STANDBY MANAGED REAL TIME APPLY
LOG_ARCHIVE_DEST_3   oralin_prim    OPEN            IDLE                                             ORA-19502: write error on file "", block number  (block size=)

LOG_ARCHIVE_DEST_3 has been set as an alternate destination.


sho parameter LOG_ARCHIVE_DEST_1

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1                   string      LOCATION=USE_DB_RECOVERY_FILE_
                                                 DEST VALID_FOR=(ALL_LOGFILES,A
                                                 LL_ROLES) DB_UNIQUE_NAME=oralin_prim noreopen max_failure=0
                                                  mandatory alternate=log_archi
                                                 ve_dest_3

sho parameter LOG_ARCHIVE_DEST_3

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_3                   string      location=/u01/app/oracle/exp/oralin/arch02 VALID_FOR=(ALL_
                                                 LOGFILES,ALL_ROLES) DB_UNIQUE_
                                                 NAME=oralin_prim

sho parameter LOG_ARCHIVE_DEST_state_3

SQL> sho parameter LOG_ARCHIVE_DEST_state_3

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_3             string      ALTERNATE

No Errors has been recorded in Alert log file.

##########################
## Solution
##########################


Tried reset the parameter back to its same value again and it worked like a charm,

Alter system set log_archive_Dest_3='location=/u01/app/oracle/exp/oralin/arch02 VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=oralin_prim';

SQL> Alter system set log_archive_Dest_3='location=/u01/app/oracle/exp/oralin/arch02 VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=oralin_prim';

System altered.

SQL> sho parameter log_archive_dest_3

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_3                   string      location=/u01/app/oracle/exp/oralin/arch02 VALID_FOR=(ALL_
                                                 LOGFILES,ALL_ROLES) DB_UNIQUE_
                                                 NAME=oralin_prim


DEST_NAME            DB_UNIQUE_NAME  DATABASE_MODE   RECOVERY_MODE           GAP_STATUS               ERROR
-------------------- --------------- --------------- ----------------------- ------------------------ -----------------------------------------------------------------
LOG_ARCHIVE_DEST_1   oralin_prim    OPEN            IDLE
LOG_ARCHIVE_DEST_2   oralin_std    MOUNTED-STANDBY MANAGED REAL TIME APPLY NO GAP
LOG_ARCHIVE_DEST_3   oralin_prim    OPEN            IDLE

Tuesday, September 3, 2013

expdp ESTIMATE_ONLY=Y gives ORA-39070: Unable to open the log file.


##########################
## Error
##########################

ORA-39070: Unable to open the log file.

### Full Error

ORA-39002: invalid operation
ORA-39070: Unable to open the log file.
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation

##########################
## Cause
##########################

Error occured while trying to estimate the size of the size of the dump file using expdp

##########################
## Command Executed
##########################

expdp \'/ as sysdba\' tablespaces=USERS ESTIMATE_ONLY=Y

##########################
## Solution
##########################

### Ran the ESTIMATE_ONLY=Y option without Directory Option, failed in this database.

oralin_3 @ hostu07:/u01/home/oracle
> expdp \'/ as sysdba\' tablespaces=USERS ESTIMATE_ONLY=Y

Export: Release 11.2.0.3.0 - Production on Mon Sep 2 07:09:11 2013

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
ORA-39002: invalid operation
ORA-39070: Unable to open the log file.
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation

So initially what i did is ran the estimate_only command with directory option and it got succeeded.

expdp \'/ as sysdba\' tablespaces=USERS ESTIMATE_ONLY=Y directory=export_dump

I have never given directory option before for estimating the size of the dumpfile earlier.

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

Again i tried the same in another database ( orawin_1 ) without directory option and it has succeeded.

orawin_1 @ hostp03:/u01/home/oracle
> expdp \'/ as sysdba\' tablespaces=USERS ESTIMATE_ONLY=Y

Export: Release 11.2.0.3.0 - Production on Tue Sep 3 00:04:04 2013

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_TABLESPACE_01":  "/******** AS SYSDBA" tablespaces=USERS ESTIMATE_ONLY=Y
Estimate in progress using BLOCKS method...
Total estimation using BLOCKS method: 0 KB
Job "SYS"."SYS_EXPORT_TABLESPACE_01" successfully completed at 00:04:52

So i investigated more on this and found below.

When a expdp command is run with ESTIMATE_ONLY=Y option, it doesnt create any dump file but it tries to create a log file, due to this i got the error when i ran 
the command in oralin_3 database.

You might be wondering why i didnt receive the same error in orawin_1 database its because from Oracle 10g onwards, a default directory named DATA_PUMP_DIR is created.

So if a directory option is not mentioned it will try to create the dumpfile and logfile in the location mentioned in DATA_PUMP_DIR directory.

In orawin_1 this directory exist and its physical location is also VALID.


OWNER           DIRECTORY_NAME            DIRECTORY_PATH
--------------- ------------------------- ------------------------------------------------------------
SYS             DATA_PUMP_DIR             /u01/app/oracle/product/11.2/db_10/rdbms/log/

SQL> !ls -ltr /u01/app/oracle/product/11.2/db_10/rdbms/log/
total 16
-rw-r--r-- 1 oracle dba 14365 Sep  3 00:06 export.log

But in oralin_3, the physical location of this directory is not available and it failed.