Difference between revisions of "Oracle"

From Bashlinux
Jump to: navigation, search
 
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
=== Howto backup an online oracle database ===
= Oracle =
 
== Howto backup an online oracle database ==
 
 
1. Login as oracle user and setup archive log mode
 
1. Login as oracle user and setup archive log mode
 
# sqlplus /nolog
 
 
<pre><nowiki>
 
# sqlplus /nolog
 
 
 
SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 25 01:28:00 2008
 
SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 25 01:28:00 2008
 
 
 
Copyright (c) 1982, 2005, Oracle. All rights reserved.
 
Copyright (c) 1982, 2005, Oracle. All rights reserved.
 
 
 
SQL> connect / as sysdba
 
SQL> connect / as sysdba
 
Connected.
 
Connected.
Line 19: Line 16:
 
SQL> startup mount
 
SQL> startup mount
 
ORACLE instance started.
 
ORACLE instance started.
 
 
 
Total System Global Area 289406976 bytes
 
Total System Global Area 289406976 bytes
 
Fixed Size 1258488 bytes
 
Fixed Size 1258488 bytes
Line 27: Line 24:
 
Database mounted.
 
Database mounted.
 
SQL> alter database archivelog;
 
SQL> alter database archivelog;
  +
 
 
Database altered.
 
Database altered.
  +
 
 
SQL> alter database open;
 
SQL> alter database open;
  +
 
 
Database altered.
 
Database altered.
  +
 
 
SQL>
 
SQL>
</nowiki></pre>
 
   
 
* Run the initial backup
 
1. Run the initial backup
 
 
<pre><nowiki>
 
 
$ORACLE_HOME/config/scripts/backup.sh
 
$ORACLE_HOME/config/scripts/backup.sh
 
Doing online backup of the database.
 
Doing online backup of the database.
Line 46: Line 39:
 
Log file is at /usr/lib/oracle/xe/oxe_backup_current.log.
 
Log file is at /usr/lib/oracle/xe/oxe_backup_current.log.
 
Press ENTER key to exit
 
Press ENTER key to exit
</nowiki></pre>
 
   
 
* Remove the user notification line at the end of the script and add it to a cron file `/etc/cron.d/oracle`
 
1. Remove the user notification line at the end of the script and add it to a cron file `/etc/cron.d/oracle`
 
 
<pre><nowiki>
 
 
0 1 * * * oracle $ORACLE_HOME/config/scripts/backup.sh
 
0 1 * * * oracle $ORACLE_HOME/config/scripts/backup.sh
</nowiki></pre>
 
   
 
=== Howto do a mysqldump-like in oracle ===
 
== Howto do a mysqldump-like in oracle ==
 
 
Here is called export and is done with the following self-explained command:
 
Here is called export and is done with the following self-explained command:
 
<pre><nowiki>
 
 
su -l oracle -c 'exp userid=user/password@host file=/tmp/expdat.dmp'
 
su -l oracle -c 'exp userid=user/password@host file=/tmp/expdat.dmp'
</nowiki></pre>
 

Revision as of 02:08, 10 June 2015

Howto backup an online oracle database

1. Login as oracle user and setup archive log mode

# sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 25 01:28:00 2008

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

SQL> connect / as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  289406976 bytes
Fixed Size                  1258488 bytes
Variable Size              92277768 bytes
Database Buffers          192937984 bytes
Redo Buffers                2932736 bytes
Database mounted.
SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

SQL>
  • Run the initial backup
$ORACLE_HOME/config/scripts/backup.sh 
Doing online backup of the database.
Backup of the database succeeded.
Log file is at /usr/lib/oracle/xe/oxe_backup_current.log.
Press ENTER key to exit
  • Remove the user notification line at the end of the script and add it to a cron file `/etc/cron.d/oracle`
0 1 * * * oracle $ORACLE_HOME/config/scripts/backup.sh

Howto do a mysqldump-like in oracle

Here is called export and is done with the following self-explained command:

su -l oracle -c 'exp userid=user/password@host file=/tmp/expdat.dmp'