vicker313 tech blog

June 11, 2011

Copy or Move Oracle Database

Filed under: Oracle — Tags: , , — vicker313 @ 12:18 pm

Consider the following scenario: I got a oracle database that reside in /db/mydb. For some reason I need to copy or move the database to somewhere else, let’s say /db2/mydb2.

To do this, follow the steps:

  1. Shutdown the database either using service or sql statement: shutdown immediate.
  2. Copy or move the database to /db2 and rename the new database directory to mydb2.
  3. Edit the initialize parameter file in the mydb2 (something like initxxx.ora), change the all the paths to the new path (from /db/mydb to /db2/mydb2)
  4. Log in to sqlplus with NOLOG (run in terminal): sqlplus /nolog
  5. Connect to empty instance (run in SQLPLUS): connection / as sysdba
  6. Create SPFILE, aware that the path of the initialize parameter file might be vary (run in SQLPLUS): create spfile from pfile='/db2/mydb2/admin/pfile/initxxx.ora';
  7. Start database in mount mode (run in SQLPLUS): startup mount;
  8. Change the data file path to the new path (run in SQLPLUS): alter database rename file '/db/mydb/data.dbf', '/db/mydb/system.dbf' to '/db2/mydb2/data.dbf', '/db2/mydb2/system.dbf';
  9. Ensure you change all the data file path! Or else it will cause the orginal database cannot be startup! (Refer updates below)
  10. Open your database (run in SQLPLUS): alter database open;
  11. Now it is good to go.

If you want to run both databases in the same time, you need to rename the new database. Follow the following steps:

  1. Rename the new database to mydb2
  2. Remember to change the database name in mydb2 parameter file as well.
  3. Log into SQLPLUS. At this point, you need to aware the SID_NAME in your environment parameter, need to be point to the database that you want to log in. Now we want to log in to the original, so we set the SID_NAME to mydb (terminal): export SID_NAME=mydb
  4. Connect to empty instance (SQLPLUS): connect / as sysdba
  5. Create the SPFILE again using the original parameter file (SQLPLUS): create spfile from pfile='/db/mydb/admin/pfile/initxxx.ora';
  6. Now you should able to start your database (SQLPLUS): startup

Update 2013/2/24

You may find out the data files path using the following query (thanks to Concerned_Netizen):

  • select name from v$datafile
  • select member from v$tempfile
  • select member from v$logfile

June 8, 2011

Recover Root Password in RHEL6

Filed under: Linux — Tags: , , — vicker313 @ 10:59 pm

There are a lot of guide lines on recovering ROOT password in a Red Hat or Fedora, by entering single user mode and change the ROOT password using passwd command. However the trick isn’t work in RHEL 6 any more, where issuing the passwd command in single user mode will not prompt you to enter the new password.

Here is a trick where I discover in order to recover the ROOT password in RHEL6.

  1. First enter single user mode. To do this, boot your machine and wait until the message to enter GRUB (the one with a counter). Press any key to enter GRUB, then press e to edit the boot argument. Just append the word single at the back of the arguments and press enter to continue boot.
  2. You should enter single user mode, with the root prompt. Instead of using entering only passwd, enter the following command:passwd -d root
  3. “-d” is meant for making the password blank. Now your root password should be blank. Reboot your machine and change your ROOT password.

Rebuild Partition after Change Hard Disk in Disk Array of HPUX Machine

Filed under: HPUX — Tags: , , , — vicker313 @ 10:38 pm

A little experience on dealing with Disk Array in HPUX machine to be shared.

It is happened at an old HPUX machine with disk array attached. After 2 of the hard disks in the disk array are being replaced, the new hard disks cannot be seen in SAM. To discover back the missing hard disks, issue the following command:

armdiscover <array alias>

After the command, you should able to see the hard disks in SAM, and even can see the unmounted partitions. However you wouldn’t able to do anything with it, either mount it, remove it or recreate it. You should get some errors like “can’t find /dev/dsk/cxtxdx”. Then issue the following command:

armdsp -s <array alias>

This command will show the hard disks path in the disk array. You will see that the path is not the same inside the error. The unmounted partitions are actually still referring to the old hard disk path, where you need to remove it using the following command:

vgreduce -l /dev/vgxx /dev/dsk/cxtxdx

You must include “-l” in the command to remove the missing path. After that you need to add back the actual hard disk path either using SAM or vgextend command, and everything should be back to normal.

Blog at WordPress.com.