Showing posts with label Oracle. Show all posts
Showing posts with label Oracle. Show all posts

Thursday, January 14, 2010

How to restore an Oracle database from its original files

Background:
I recently had to bring an Oracle database online from its original files an old laptop hard drive. It had some data on it that I needed to get off, and as usual, Oracle is anything but straightforward. This post describes how I ended up doing it.
To start with, I had to connect the old hard drive to the machine. I did this with a USB-SATA2.5" external adapter. You can find hard drive multi-adapters like these on newegg or any other online hardware store for around $20 - $30.

Running:
- Windows XP SP3
- Oracle 10g

Solution Steps:
1) Locate your current Oracle database files. The default location for this is C:\oracle\product\10.2.0\oradata. Each folder in that directory contains the data files for the database by the same name.

2) I'll call the database you're trying to restore "OldDatabase". If the path for OldDatabase folder was different from your current Oracle data folders, this might not work (but of course the drive letter will be different if you're using an old disk drive via USB). If it doesn't work, see if you can install Oracle into a directory on the new machine that has the same path as the old one had.

3) Make sure you don't have any databases in your current Oracle installation that have the same name as OldDatabase. If they match and you continue anyways, things will get very screwed up. If you do have a match, see if you can migrate the matching new one to another new database with a different name. You might want to back up that db's files first.

4) Now, go ahead and create a new database with all the default settings and the same name as OldDatabase. You can do this via the Database Configuration Assistant that should have been included with your Oracle installation. I found mine under Start > All Programs > Oracle - OraDb10g_home1 > Configuration and Migration Tools.

5) Go into your Administration Assistant for Windows (in the same start menu folder as the Database Config Assist.) and find your newly created database, right click it, and choose Stop Service.

6) The data files for the new database you just created are now in your current oradata folder. Copy the contents of your old OldDatabase folder into the new one by the same name, replacing all files (you might want to back up your new folder first).

7) Back in the Admin. Assist., right-click your new database and choose Start Service. With any luck, you'll be able to connect to it in a few moments, and it will look just like your old database!

Hope this helps!

Wednesday, July 8, 2009

Oracle Installation error: ORA-12560

I'm setting up a development environment on my machine for a new web app in Ruby on Rails with an Oracle back-end. This was my first time installing an Oracle database. It's quite an archaic and un-user-friendly process. The good news is, I've spent a lot more time praying than I usually do while at work. I'll try to keep this short.

OS: Windows XP, SP3
Installing: Oracle 10g Standard Edition
Steps:
  1. Download the zipped 10gR2 installer package from Oracle's website (~625MB).
  2. Extract the zip file somewhere on my hard drive.
  3. Run the setup file in the extracted folder.
  4. Follow the wizard, selecting not to create the sample database at the beginning. Use the defaults for everything else. Yay, now we've got an empty Oracle installation.
  5. Now to create a database. Click Start > All Programs > Oracle - OraDb10g_home1 > Configuration and Migration Tools > Database Configuration Assistant.
  6. Follow the wizard, keeping the defaults (except I changed the character encoding to Unicode).
The Problem: I got a whole ton of error dialog boxes popping up. I chose "ignore" on all of them, allowed the database to finish being created, and then took a look at the log file (myOracleFolder\product\10.2.0\db_1\cfgtoollogs\dbca\myDatabaseName\emConfig.log). The log file mentions:

CONFIG: ORA-12560: TNS:protocol adapter error

oracle.sysman.assistants.util.sqlEngine.SQLFatalErrorException: ORA-12560: TNS:protocol adapter error

at oracle.sysman.assistants.util.sqlEngine.SQLEngine.executeImpl(SQLEngine.java:1467)
at oracle.sysman.assistants.util.sqlEngine.SQLEngine.connect(SQLEngine.java:814)
at oracle.sysman.emcp.util.GeneralUtil.initSQLEngine(GeneralUtil.java:363)
at oracle.sysman.emcp.DatabaseChecks.validateUserCredentials(DatabaseChecks.java:986)
at oracle.sysman.emcp.ParamsManager.validatePassword(ParamsManager.java:2694)
at oracle.sysman.emcp.EMDBPreConfig.checkConfigParams(EMDBPreConfig.java:1268)
at oracle.sysman.emcp.EMDBPreConfig.checkParameters(EMDBPreConfig.java:1060)
at oracle.sysman.emcp.EMDBPreConfig.invoke(EMDBPreConfig.java:174)
at oracle.sysman.emcp.EMDBPreConfig.invoke(EMDBPreConfig.java:160)
at oracle.sysman.emcp.EMConfig.perform(EMConfig.java:141)
at oracle.sysman.assistants.util.em.EMConfiguration.run(EMConfiguration.java:430)
at java.lang.Thread.run(Thread.java:534)
Jul 8, 2009 9:50:33 AM oracle.sysman.emcp.EMConfig perform
SEVERE: Invalid username/password.
Refer to the log file at C:\oracle\product\10.2.0\db_1\cfgtoollogs\dbca\orcl\emConfig.log for more details.
Jul 8, 2009 9:50:33 AM oracle.sysman.emcp.EMConfig perform
CONFIG: Stack Trace:
oracle.sysman.emcp.exception.EMConfigException: Invalid username/password.
at oracle.sysman.emcp.EMDBPreConfig.checkConfigParams(EMDBPreConfig.java:1272)
at oracle.sysman.emcp.EMDBPreConfig.checkParameters(EMDBPreConfig.java:1060)
at oracle.sysman.emcp.EMDBPreConfig.invoke(EMDBPreConfig.java:174)
at oracle.sysman.emcp.EMDBPreConfig.invoke(EMDBPreConfig.java:160)
at oracle.sysman.emcp.EMConfig.perform(EMConfig.java:141)
at oracle.sysman.assistants.util.em.EMConfiguration.run(EMConfiguration.java:430)
at java.lang.Thread.run(Thread.java:534)


The solution:
Uninstall the half-created database I just made, restart my machine, and then recreate the database. Now it works. *smacks forehead*