Oracle backup

846 views

Published on

Oracle backup

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
846
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
95
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Oracle backup

  1. 1. PREPARED BY RAVI KUMAR LANKE Page 1ORACLE BACKUPBacking up an Oracle database can be done in many different ways and is quite difficult to get agrasp on compared to other mainstream databases. Backup is best done through RMAN whetheryou access RMAN from a command line interface (CLI) or from within Oracle EnterpriseManager (GUI)Oracle versions tested here:1. Oracle 11gR2 on Windows/Linux/Solaris2. Oracle Express 10g XE on Windows/LinuxConfigure Oracle backup environment - using EnterpriseManager (GUI)Before you start taking backup, you should configure your backup environment. Here is how toconfigure the Oracle backup environment using Enterprise Manager.
  2. 2. PREPARED BY RAVI KUMAR LANKE Page 2Log on to Enterprise Manager as sys as sysdba.
  3. 3. PREPARED BY RAVI KUMAR LANKE Page 3Go to "Availability tab > Backup/Recovery > Backup Settings".
  4. 4. PREPARED BY RAVI KUMAR LANKE Page 4
  5. 5. PREPARED BY RAVI KUMAR LANKE Page 5
  6. 6. PREPARED BY RAVI KUMAR LANKE Page 6Under the "Device" tab set :1. Disk backup location. If you change the from default (the fast recovery area), you need topoint to an existing directory2. Choose backup type :o Backup Set (default) : will create backup files in a format that only RMANunderstands.o Image Copy : will create backup files corresponding to the files that make up thedatabase, that is : 5 data files (prefixed DATA_), a copy of the SPFILE, a copy ofthe Control file and if in ARCHIVELOG mode also a number of redo files(prefixed ARCH_).3. Enter host credentials (the user who installed Oracle).4. press the Test Disk Backup button to confirm it works.3.4. If you are on Solaris you may get Connection to host as user oracle failed:ERROR: NMO not setuid-root (Unix-only). If you get that error then:1. Open a shell as root2. #> su oracle : switch to user oracle.3. $> emctl stop dbconsole : stop the dbconsole.4. $> exit : back to root user.5. #> ORACLE_OWNER=oracle : initialize the ORACLE_OWNERvariable.6. #> export ORACLE_OWNER : add the ORACLE_OWNER to the rootenvironment.7. #> cd $ORACLE_HOME :8. #> ./root.sh : execute the root.sh script and answer yes to all prompts.9. #> su oracle : switch to user oracle.10. $> emctl start dbconsole : start the dbconsole.11. Try the "Test Disk Backup" button again.5. Press the OK button to save the settings4. Under the Backup Set tab there is no settings necessary to set5. Under the Policy tab it is possible to tune the backup, however I feel the backup resultfiles become less independent and I choose to skip optimize options. The RetentionPolicy I like to choose the default "Retain at least the specified number of full backupsfor each datafile" with a value of 1. This is because it then gives meaning to let a 3. partybackup program copy the backup result to a remote backup store and handle the retentionperiod outside of Enterprise Manager control.You are now ready to do backup.
  7. 7. PREPARED BY RAVI KUMAR LANKE Page 7Backup Oracle - using RMAN (CLI) -Windows/Linux/SolarisThe RMAN backup procedure depends on whether your Oracle database is in ARCHIVELOG orNOARCHIVELOG mode, therefore start by checking the log_mode :1. Open a command prompt2. shell> sqlplus / as sysdba : start SQL*Plus and log in as sysdba3. sql> select log_name from v$database; : will display whether you are in ARCHIVELOG orNOARCHIVELOG mode4. sql> exitNow that you know your log_mode, ARCHIVELOG or NOARCHIVELOG, you can choose theappropiate step-by-step procedure : If in ARCHIVELOG mode :The backup is quite simple because you can take the backup while the database is open (onlinebackup)1. Open a shell.2. shell> rman target / : logon to RMAN using host credentials.3. rman> show all; : shows the environment configuration (that can be setup using the"Enterprise Manager > Availability tab > Backup/Recovery > Backup Settings")4. rman> backup database plus archivelog; : start backup and include the archivelog sincethey are needed to secure a consistent restore5. rman> exit : you are finished.
  8. 8. PREPARED BY RAVI KUMAR LANKE Page 8 If in NOARCHIVELOG mode :The backup is less simple because you need to be sure the database is in a consistent state andthen mount the database without opening it (offline backup)1. Open a shell.2. shell> rman target / : logon to RMAN using host credentials.3. rman> shutdown immediate; : shutdown and rollback pending transactions (without theimmediate keyword, the shutdown will wait for all pending transactions to finish)4. rman> startup mount; : startup and mount the database but without opening it(datafiles location will be known but not loaded).5. rman> show all; : shows the environment configuration you did under Configure Oraclebackup environment.6. Depending on configured Backup type : ("Enterprise Manager > Availability tab >Backup/Recovery > Backup Settings") rman> backup database; : if Backup type = Backup Set (default). rman> backup as copy database; : if Backup type = Image Copy.7. rman> alter database open; : open the database (the datafiles will be loaded and thedatabase therefore online).8. rman> exit : you are finished.The database is now backed up and the resulting backup files located in the Disk backup location(specified then configuring the Oracle backup environment).The resulting backup files could then be copied to some remote storage location for increasedsecurity (eg. if the Disk backup location is on the same harddisk as the live datafiles and thatharddisk fails, then the backup is not going to help)
  9. 9. PREPARED BY RAVI KUMAR LANKE Page 9Backup Oracle - using Enterprise Manager (GUI) -Windows/Linux/SolarisNote that Enterprise Manager is only a GUI on top of RMAN.Log on to Enterprise Manager as sys as sysdba
  10. 10. PREPARED BY RAVI KUMAR LANKE Page 10Go to "Availability tab > Backup/Recovery > Schedule Backup
  11. 11. PREPARED BY RAVI KUMAR LANKE Page 11On the "Schedule Backup" page you can choose between "Schedule Oracle Suggested Backup"and "Schedule Customized Backup". The main difference between the two is that "Schedulecustomized backup" allows you to : Choose between an immediate non-scheduled backup or a scheduled backup. Override default backup environment settings
  12. 12. PREPARED BY RAVI KUMAR LANKE Page 12Since Oracle suggested backup dont offer any significant convenience, press the "Schedule CustomizedBackup" button.On the "Options" page accept default "Full Backup" and press the "Next" button
  13. 13. PREPARED BY RAVI KUMAR LANKE Page 13On the "Settings" page the defaults will depend on your Oracle environment configuration, however incase of an immediate single backup you maybe want to change the settings in which case you press the"Override default settings" button. Then you are happy, press the "Next" button
  14. 14. PREPARED BY RAVI KUMAR LANKE Page 14On the "Schedule" page, the job needs a name, a description and a schedule (here One TimeImmediately). Press the "Next" button.Press the "Submit Job" buttonYou now have a backup in your designated backup folder. Best to copy that backup to a remote storage,so that if your harddrive fails, you still have a copy of the backup files
  15. 15. PREPARED BY RAVI KUMAR LANKE Page 15Backup Oracle - using Flashback - Windows/Linux/SolarisFlashback is not available in all editions.In editions containing Flashback, Flashback is disabled by default. However, if you haveFlashback and you have the disk space, then Flashback is important to enable because it is amore efficient alternative to DBPITR (DataBase Point-In-Time Recovery), that is: then adatabase needs to roll back because of unwanted changes eg. a user have overwritten data or anadministrator have dropped a table.As with DBPITR, Flashback cannot be used in case of media errors, eg. data file corruption.If Flashback is enabled, the database will continously write data file blocks to the flashback logsas well as create, delete and resize them. Flashback logs are not archived and cannot be backedup to disk.First check if flashback is already turned on :1. Open a shell.2. #> su oracle : ONLY Solaris : if you have opened a shell as root, you may not be able to useSQL*Plus, so better switch user to oracle.3. shell> sqlplus / as sysdba : logon to SQL*Plus as sydba.4. sql> select flashback_on from v$database; : you will get either YES or NO.If Flashback is not enabled, you can enable Flashback using either SQL*Plus or Enterprise Manager :
  16. 16. PREPARED BY RAVI KUMAR LANKE Page 16 Enable Flashback using SQL*Plus (CLI) :1. Open a shell.2. shell> sqlplus / as sysdba : logon to SQL*Plus as sysdba.3. sql> alter database set db_flashback_retention_target=4320; : setting flashbackretention to 3 days (default is 1440 minutes = 1 day). If fast recovery area disk constraintallows it, this will make it possible to look 3 days into the past4. sql> alter database flashback on; : enable flashback. If you get error ORA-38703: Mediarecovery is not enabled, then you are most likely in NOARCHIVELOG mode. sql> select log_mode from v$database; : confirm your log mode. If you are inNOARCHIVELOG and you want to change to ARCHIVELOG so that you can enableFlashback :1. sql> shutdown immediate; :2. sql> startup mount; :3. sql> alter database archivelog; :4. sql> alter database open; :5. sql> alter database flashback on; : this time you should be able toenable flashback.
  17. 17. PREPARED BY RAVI KUMAR LANKE Page 17Enable Flashback using Enterprise Manager (GUI) :Log on to Enterprise Manager as sys as sysdba.
  18. 18. PREPARED BY RAVI KUMAR LANKE Page 18On the Availability tab click on the "Recovery Settings" link
  19. 19. PREPARED BY RAVI KUMAR LANKE Page 19On the Recovery Settings page :
  20. 20. PREPARED BY RAVI KUMAR LANKE Page 201. Be sure ARCHIVELOG mode is enabled - it is not possible to enable Flashback inNOARCHIVELOG mode.2. "Flash Recovery Area Size" is the maximum space allocated for Flashback logs, thereforif set too low, it will cap your Flashback Retention Time. (The size of the flashback log isapproximately the same as the size of the redo log files, so if the flashback retention is 3days, then the size of the flashback logs will be 3 times that of the redo logs).3. Check the "Enable Flashback Database", this it what we came here for.4. "Flashback Retention Time" is the time you will be able to roll your database back. If setto default 24 hours and you found out that a user overwrote data 25 hours ago, you willnot be able to use Flashback to get the overwritten data back. Disable Flashback using SQL*Plus (CLI) :
  21. 21. PREPARED BY RAVI KUMAR LANKE Page 21(just here for completness)1. Open a shell.2. shell> sqlplus / as sysdba : logon to SQL*Plus as sysdba.3. sql> alter database flashback off; : disable Flashback.Flashback should now be enabledBackup Oracle - using Export - Windows/Linux/solarisOracles Export (exp) & Import (imp) utilities are popular for backup of Oracle databases smallerthan say 50 GB (which is bigger than most databases). The reason they are so popular is becausethey are both easy and versatile.Oracles Export & Import utilities are used for the following tasks : Database backup - what we will do here Reducing fragmentation in the database. Move data from one owner to another. Move data from one version to another, eg. from version 9i to 11g. Moving the database from one operation system to another, eg. from Solaris to Windows.Oracles Export & Import utilities are called exp & imp respectively, however from version 10,Oracle introduced the DataPump utilities called expdp & impdp respectively. The DataPumputilities should be superiour eg. faster and with support for network. The old exp & imp utilitiescan still be used with Oracle 11gR2.The DataPump utilities, expdp & impdp, works right away, however the old export/importutilities, exp & imp, needs to be prepared by runnning the catexp.sql script :1. Open a shell2. shell> sqlplus / as sysdba : logon to SQL*Plus as sys as sysdba using host credentials3. Execute the catexp.sql script :o Windows : sql> @?rdbmsadmincatexp.sql : @ executes a script and ? points to%ORACLE_HOME%.o Solaris/Linux : sql> @?/rdbms/admin/catexp.sql : @ executes a script and ?points to $ORACLE_HOME.The exp utility can be used in 3 different modes : (from the shell)
  22. 22. PREPARED BY RAVI KUMAR LANKE Page 22Interactive prompt : (holding your hand)shell> exp : start the interactive prompt
  23. 23. PREPARED BY RAVI KUMAR LANKE Page 23ogin. Here i use the same user as I want to export, however you can also use sys as sysdba
  24. 24. PREPARED BY RAVI KUMAR LANKE Page 24specify the dump file location
  25. 25. PREPARED BY RAVI KUMAR LANKE Page 25specify how to choose objects - here I want to export all objects for specific users
  26. 26. PREPARED BY RAVI KUMAR LANKE Page 26
  27. 27. PREPARED BY RAVI KUMAR LANKE Page 27I am not sure what it means if you choose no, maybe all objects will be free of permissions
  28. 28. PREPARED BY RAVI KUMAR LANKE Page 28yes, I want to export the data, however if I chose no I would get only the table structures
  29. 29. PREPARED BY RAVI KUMAR LANKE Page 29yes just compress it
  30. 30. PREPARED BY RAVI KUMAR LANKE Page 30choose the users for which I want to export objects, here just one user : rasmus
  31. 31. PREPARED BY RAVI KUMAR LANKE Page 31the rasmus user have only one table with only 1 row
  32. 32. PREPARED BY RAVI KUMAR LANKE Page 32
  33. 33. PREPARED BY RAVI KUMAR LANKE Page 33that went well.
  34. 34. PREPARED BY RAVI KUMAR LANKE Page 34
  35. 35. PREPARED BY RAVI KUMAR LANKE Page 35 Standard command line : (fast dump on-the-fly)o shell> exp scott/tiger file=scott.dmp : fast dumping all objects belonging to scott(note that scott/tiger is the credentials used to login to the exp utility - it is justdefault that you will then export the scott objects if nothing else specified)o shell> exp scott/tiger file=scott.dmp log=scott.log : fast dumping all objectsbelonging to scott and also a log file to see how the export wento shell> exp scott/tiger file=scott.dmp log=scott.log tables=(tbl1,tbl2) : dumpingonly the tables tbl1 & tbl2 (these tables must belong to scott) and a log file.o shell> exp scott/tiger file=scott.dmp log=scott.log tables=(tbl1,tbl2) rows=no :dumping only the structures (not the data) of tables tbl1 & tbl2 and a log file. Command line with parameter file : (if you need many parameters and you need to doit often)o no examples
  36. 36. PREPARED BY RAVI KUMAR LANKE Page 36Appendix : SQL*Plus & RMAN : logon & managementcommands Logon to SQL*Plus (no normal logon for user sys - either use as sysdba or as sysoper)o shell> sqlplus / as sysdba : logon to SQL*Plus as sys as sysdba using hostcredentials.o shell> sqlplus sys/SysPassword as sysdba : logon to SQL*Plus as sys as sysdbausing sys password.o shell> sqlplus scott/tiger : logon to SQL*Plus as scott who have the passwordtiger. Logon to RMAN :o shell> rman target / : logon to RMAN using host credentials.o shell> rman : start the RMAN shell to logon from within RMAN : rman> connect target sys@orcl : format user@dbname. rman> connect target sys@ipadress/orcl : format user@ipaddress/dbname. rman> connect target sys@localhost/orcl) : format user@host/dbname. SQL*Plus management commands (most will require that you are logged on as sysdba)o Managing database : sql> shutdown : database will wait for all pending transactions to commit,then close, then dismount, then shutdown. sql> shutdown immediate : instead of waiting to commit all pendingtransactions, Oracle will roll them all back - fast shutdown. sql> startup nomount : will start the database instance but not mount it.Then issuing the startup command, Oracle will read the initalizationparameter file (init.ora or spfile) to get database configuration eg. size ofall memory areas which will then be allocated and all backgroundprocesses will be started and together these processes and allocatedmemory is called an Oracle instance and that instance is now started. sql> startup mount : will start and then mount the database but not open it.In the mount stage, the control file is read to locate the datafiles butwithout opening them (without making access possible) - the instance isnow mounted. Obviously this is the right stage in which to take backupsince the datafile locations are now known and most likely consistent(except for online backup that qua log files do not need consistentdatafiles). sql> startup : will start, mount and open the database. An open database isalso called an online database and makes it possible to access the datafilesthrough Oracle eg. using sql (Stages in starting an Oracle database). sql> alter database mount; : change a nomounted to mounted. sql> alter database open; : change a mounted not opened to opened. sql> alter database open resetlogs; : change a mounted not opened toopened and starts a new incarnation. sql> select name from v$database; : find the name of your database.
  37. 37. PREPARED BY RAVI KUMAR LANKE Page 37 sql> select log_mode from v$database; : find out if your database is inARCHIVELOG or NOARCHIVELOG mode. sql> select open_mode from v$database; : show access, eg. OPENWRITE (gives error ORA-01034: ORACLE not available if the instance isnot started). sql> show parameters CONTROL_FILES; : find the path to your controlfiles. sql> select * from v$database_incarnation; : list all incarnations, howeverRMAN creates a more nice list :rman> list incarnation; sql> select value$ from sys.props$ where name =NLS_CHARACTERSET; : shows the database ordinary characterset. sql> select * from nls_database_parameters; : shows additional languageinformation. NSL_CHARACTERSET is ordinary andNLS__NCHAR_CHARACTERSET is national characterset. sql> alter database character set WE8MSWIN1252; : changes thecharacterset to WE8MSWIN1252 - note if the new character is not asuperset of the old, you will get ora-12712: new character set must be asuperset of old character set.(Official Character set Migration should be consulted).o Managing users : sql> select * from all_users; : fast list of all users. sql> select username, user_id, account_status from dba_users order byusername; : dba_users contains quite a lot more info than all_users. sql> select user#, name from sys.user$; : more users and more info. sql> create user rasmus identified by myPassword; : creating a user calledrasmus with the password myPassword. sql> alter user rasmus identified by newPassword; : change the passwordfor rasmus from myPassword to newPassword. sql> grant connect to rasmus; : granting rasmus connect privilege. sql> create tablespace tsrasmus datafile C:apporadataorcltsrasmus.dbfsize 20M;create a tablespace with a 20 MB datafile. sql> alter user rasmus default tablespace tsrasmus quota unlimited ontsrasmus; : specify that rasmus default should store objects in tsrasmusinstead of in the user tablespace. sql> alter user rasmus account unlock; : unlock the rasmus user account. sql> drop user rasmus cascade; : deleting the rasmus user. Specify cascadeto also delete all objects belonging to rasmus.o Managing tables : sql> desc dba_users; : show the structure of the dba_users table. sql> select * from cat; : shows all tables belonging to current user. sql> select table_name from dictionary; have less tables but moreinformation. sql> select table_name from dba_tables; : shows all tables in the databaseregardless of user and having a lot of info.
  38. 38. PREPARED BY RAVI KUMAR LANKE Page 38 sql> select owner, table_name, tablespace_name from dba_tables whereowner = RASMUS; : show all tables and there they are stored for therasmus user. sql> create table employees (firstname varchar2(100), age number); :creating a table called employees. sql> drop table employees; : deleting the employees table.o Managing SQL*Plus : sql> show all; : show all SQL*Plus settings. sql> help topics; : list all topics that there are help for. sql> @myscript.sql : executes myscript.sql which must be in the currentdirectory sql> @C:appproductdbhome_1rdbmsadmincatexp.sql : if the script isnot in current directory, then specify the full path. sql> @?rdbmsadmincatexp.sql : ? is a shorthand for%ORACLE_HOME% (windows) or $ORACLE_HOME (solaris/linux). sql> ed myscript.sql; : starts an associated text editor and opens opmyscript.sql from current directory. sql> define; : will show all defined variables. sql> define rasmus=programmer : declare a new variable called rasmusand initializes it with the value programmer. sql> undefine rasmus; :Appendix : Oracle backup related concepts : RMAN : Recovery MANager command utility. Preferred to to backup & restore Oracledatabases as it provides an OS independent interface as well as removes OS dependenciesin the backup files RMAN Repository : records of database files and backups for each database on whichRMAN performs operations. These meta data are stored in the control file of the targetdatabase, therefore you should always backup the control file. Enterprise Manager : (normally abbreviated EM or OEM) : Web application to manageOracle. It is possible to perform and schedule backups using EM (EM backup will useRMAN underneath and as such EM is a GUI frontend to RMAN) Fast Recovery Area : (earlier named flash recovery area). A directory to store recoveryrelated files such as control file, online redo log copies, archived redo log files, flashbacklogs and RMAN backups. Oracle & RMAN automatically manage the files in thisdirectory, eg. automatically delete files that are no longer needed. Oracle Flashback : Oracle Flashback is built-in to some but not all Oracle databaseeditions and enables you to recover data from unwanted database changes withoutrestoring files from backup or performing media recovery - this feature relies on undodata. Flashback must be turned on though and can be turned on for individual tables and aretention period must be specified, this will create a flashback data archive. SCN : System Change Number : Everytime a transaction is committed, Oracle records anew SCN. Then Oracle starts up, Oracle check SCN in all datafile headers and in the
  39. 39. PREPARED BY RAVI KUMAR LANKE Page 39control file and if they are all the same then the database is consistent. If they are not thesame, the database is in need of recovery. Offline Backup : (sometimes called cold backup) backups that run when the database isin the mounted but not open state. Oracle in NOARCHIVELOG log_mode must dooffline backup Online Backup : (sometimes called hot backup) backups that run when the database is inopen state. Oracle in ARCHIVELOG log_mode can do online backup log_mode : Oracle can be in either ARCHIVELOG or NOARCHIVELOG log_mode.The ARCHIVELOG have 2 advantageso Oracle can do Online Backupo Oracle can restore ALL committed data to the point of failure as opposed toNOARCHIVELOG log_mode there Oracle restore will loose all data committedsince the last backup Physical >< Logical Backup : Physical backup refers to the files making up the databasewhile Logical backup referes to data, tables etc. Oracle backup is mostly physical backup Backing up a database : means to make copies of the data files, control file and if inARCHIVELOG mode then also copies of archived redo log files Restoring a database : means copying the physical files that comprise the database froma backup medium (disk or tape) to their original or to new locations Database recovery : is the process of updating database files restored from a backupwith the changes made to the database after the backup (typically using the redo log files) Media Recovery : most often used to recover from media failure, eg. loss of a file or diskor a user error eg. deletion of the contents of a table. Media recovery requires a controlfile, data filees (typically restored from backup) and online and archived redo log files(that contains the changes since the time the data files were backed up. Control file : contains among other things names & locations of data files and online &archive log records and backup records. Also without the control file, the database cannotbe mounted and therefore recovery cannot be performed - you need to backup the controlfile. SPFILE : Server Parameter file : A binary parameter file that Oracle is using uponstartup (alternatively a text based PFILE can be used). The name of the SPFILE may bespfileSID.ora, where SID is the database name (PFILE nomenclature is initSID.ora). If noparameter file can be found, Oracle cannot start up. Table spaces : Logical storage unit (logical because there is no file representation on thefile system) used to organizing objects. A table space have at least one data file and a datafile can only belong to one table space. Tables, indexes etc. belongs to a tablespace.Table spaces can be created, but then a database is created it will be created with 5default table spaces : system, sysaux, temp, undotbs1 & users. Data files : Physical representation of the table spaces, that is: data files physically holdsthe data. Schema : Collection of objects owned by a user of the same name. Eg if the user isRasmus, then all objects like tables, views, indexes etc. owned by Rasmus is collected ina Schema named Rasmus. Management Repository Encryption key : If Enterprise Manager data is encrypted(Management Repository has been placed in secure mode), then this key MUST be
  40. 40. PREPARED BY RAVI KUMAR LANKE Page 40backed up as the encrypted data will become unusable if this file is lost. Location is :/export/home/oracle/app/oracle/product/11.2.0/dbhome_1/localhost_orcl/sysman/config/emkey.ora.Appendix : default Oracle file locationsBelow USER_NAME is the user that installed Oracle. Fast Recovery Area (called flash recovery area on Oracle Express XE 10g)o Oracle 11gR2 on Windows :C:appUSER_NAMEflash_recovery_areaDB_NAMEo Oracle 11gR2 on Solaris : /export/home/oracle/app/oracle/flash_recovery_areao Oracle Express XE 10g on Windows :C:oraclexeapporacleflash_recovery_areaXEo Oracle Express XE 10g on Linux :/usr/lib/oracle/xe/app/oracle/flash_recovery_area/ Data files :o Oracle 11gR2 on Windows : C:appUSER_NAMEoradataDB_NAMEo Oracle 11gR2 on Solaris : /export/home/oracle/app/oracle/oradata/?? Installation files :o Oracle 11gR2 on Solaris :/export/home/oracle/app/oraInventory/PRODUCT_NAME Control file :o Oracle 11gR2 on Windows : C:appUSER_NAMEoradataDB_NAME (sameplace as the data files) SPFILE :o Oracle 11gR2 on Solaris :/export/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorcl.ora listener.ora & tnsnames.ora :o Oracle 11gR2 on Solaris :/export/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin oratab : (defines home folders for each database instance in the format SID:FOLDER)o Oracle 11gR2 on Solaris : /var/opt/oracle/oratabo Oracle 11gR2 on Linux : /var/oratab Environment Variables :o Oracle 11gR2 on Solaris $ORACLE_BASE : /export/home/oracle/app/oracleo Oracle 11gR2 on Solaris $ORACLE_HOME :/export/home/oracle/app/oracle/product/11.2.0/dbhome_1o Oracle 11gR2 on Solaris $ORACLE_OWNER : oracleo Oracle 11gR2 on Solaris $ORACLE_SID : orcl
  41. 41. PREPARED BY RAVI KUMAR LANKE Page 41Appendix : Common errors & Solutions1. c:> emctl dbconsole status : errors EM Configuration issue.c:appUSERNAMEproduct11.2.0dbhome_1/HOSTNAME_DBNAME not found2. $> emctl dbconsole status : errors EM Configuration issue./export/home/app/oracle/product/aa.2.0/dbhome_1/HOSTNAME_DBNAME not found3. $> emctl dbconsole start : exactly the same error as 2.4. $> emctl start dbconsole : errors OC4J Configuration issue..../oc4j/j2ee/OC4J_DBConsole_HOSTNAME_DBNAME not foundReason : If you have one of the above errors, 1, 2, 3 or 4, you have most likely not set the$ORACLE_HOSTNAME environment variable. The problem is that the Oracle installer will uselocalhost for HOSTNAME at least then installing a desktop class system. However, then servicesstart, Oracle will match hostname with $ORACLE_HOSTNAME and if$ORACLE_HOSTNAME is empty then substitute with the system hostname, which likely isdifferent from localhost.Example : If your hostname is Solaris10 and your database name is orcl, then emctl will searchfor ../oc4j/j2ee/OC4J_DBConsole_Solaris10_orcl, but the installer created../oc4j/j2ee/OC4J_DBConsole_localhost_orcl.Solution : There are different possible solutions of which by far the easiest is to set the$ORACLE_HOSTNAME to localhost :1. On Windows1. Open a shell.2. c:> set ORACLE_HOSTNAME=localhost : declare, initialize and add thevariable to your environment3. c:> echo %ORACLE_HOSTNAME% : confirm the variable - you should getlocalhost.2. On Solaris1. Open a shell.2. #> ORACLE_HOSTNAME=localhost : declare & initialize the variable.3. #> export ORACLE_HOSTNAME : add the variable to your environment.4. #> echo $ORACLE_HOSTNAME : confirm the variable - you should getlocalhost.
  42. 42. PREPARED BY RAVI KUMAR LANKE Page 42To persist $ORACLE_HOSTNAME on system boot (Solaris), please see here (step 9).5. c:> emctl dbconsole status : errors Environment variable ORACLE_UNQNAME notdefined. Please set ORACLE_UNQNAME to database unique name.Solution : Set the ORACLE_UNQNAME to the value of your database name : On Windows1. Open a shell.2. c:> set ORACLE_UNQNAME=orcl : declare, initialize and add the variable toyour environment3. c:> echo %ORACLE_UNQNAME% : confirm the variable - you should get orcl. On Solaris1. Open a shell.2. #> ORACLE_UNQNAME=localhost : declare & initialize the variable.3. #> export ORACLE_UNQNAME : add the variable to your environment.4. #> echo $ORACLE_UNQNAME : confirm the variable - you should get orcl.Enterprise Manager cannot connect.
  43. 43. PREPARED BY RAVI KUMAR LANKE Page 43Solution : This solution worked for me. If it does not work for you, you can read more here1. On Windows1. Open a shell.2. c:> set ORACLE_SID=orcl : declare, initialize and add the variable to yourenvironment3. c:> emca -deconfig dbconsole db : you will be prompted for your database name.4. c:> emca -config dbconsole db : you will be prompted for dbname, severalpasswords, ORACLE_HOME and Listener port number (default 1521).5. Refresh Enterprise Manager in your browser.
  44. 44. PREPARED BY RAVI KUMAR LANKE Page 44sql> alter database open; : errors ORA-38760: This database instance failed to turn on flashbackdatabaseSolution : Turning flashback off and then on should solve the problem, however any guaranteedrestore point need to dropped.1. You should already be in your SQL*Plus shell.2. Be sure your database is started and in mounted stage :1. sql> shutdown immediate;2. sql> startup mount;3. Check for quaranteed restore points and delete them if found :1. sql> select name, scn, guarantee_flashback_database, database_incarnation# fromv$restore_point; : list your restore points.2. If you found any then drop themExample: sql> drop restore point RESTORE_POINT_NAME;.4. sql> alter database flashback off; : turn off flashback.5. sql> alter database flashback on; : turn on flashback.6. sql> alter database open; : this time you should succeed.Enterprise Manager import/export give error ORA-20446: The owner of the job is not registered ORA-06512: at "SYSMAN.MGMT_JOBS", line 168 ORA-06512: at "SYSMAN.MGMT_JOBS", line 86 ORA-06512:at line 1.
  45. 45. PREPARED BY RAVI KUMAR LANKE Page 45Reason : This is likely a bug in Oracle 11gSolution :1. On Windows/Solaris/Linux1. Open a shell.2. shell> sqlplus sysman/SysmanPassword : logon to SQL*Plus as SYSMAN.3. sql> execute MGMT_USER.MAKE_EM_USER(‘USERID’); : USERID is theuser that you use to login to Enterprise Manager then doing import/export.4. Try running import/export again.

×