Table of Contents
< All Topics
Print

[aCloud] Error when entering rman, ORA-12560: TNS: protocol adapter error

Problem Description

The bat script for running Rman backup crashes and reports the following error. At the same time, using the command rman target / to log in to Oracle Recovery Manager (Rman) in cmd also reports the same error.
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: Internal recovery manager package initialization failed
RMAN-04005: Error in target database:
ORA-12560: TNS:protocol adapter error

Alarm Information

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: Internal recovery manager package initialization failed
RMAN-04005: Error in target database:
ORA-12560: TNS:protocol adapter error

Root Cause

Recovery Manager (Rman) did not obtain the SID environment variable to log in to the database.

Solution

  1. Execute set ORACLE_SID=database instance name in cmd, log in again and use command: rman target / to log in and find that the problem has been solved;
  2. To avoid Rman backup script exceptions, you need to add the "set ORACLE_SID=orcl" statement (where orcl is the instance name of the database to be backed up) when defining variables at the beginning of the script, and set the environment variables for Rman to log in to the database, as shown in the following code:
  3. set ORACLE_SID=orcl
  4. set BACKUP_DATE=%date:0,4%%date:5,2%%date:~8,2%
  5. set BACKUP_PATH=D:\RmanBackUp
  6. mkdir %BACKUP_PATH%\%BACKUP_DATE%
  7. rman target / cmdfile 'D:\scripts\rman_full_bak.txt' log 'D:\RmanBackUp\rmanfull_bak.log'

Suggestions and Summary

Whether you are writing an Rman backup script for Linux or Windows, you must consider adding statements to export or set the current environment variables.

Original Link

https://support.sangfor.com.cn/cases/list?product_id=33&type=1&category_id=15739&isOpen=true