Advertisement
trishoar

RHN prep.sh

Mar 4th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.07 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # This script prepares an embedded Oracle database to be able to use RMAN. It
  4. # only ever needs to be run once for a particular database, however running it
  5. # multiple times is safe.
  6.  
  7. # Matthew Booth <mbooth@redhat.com> 22/09/2006
  8.  
  9. # Make sure we're root
  10. # Could just be Oracle, but root is simpler for administrators
  11. if [ `id -u` -ne 0 ]; then
  12.     echo This script must be executed as root
  13.     exit 1
  14. fi
  15.  
  16. # Check the rhn database isn't already running
  17. if service rhn-database status; then
  18.     echo You must stop the rhn-database service before running this script
  19.     exit 1
  20. fi
  21.  
  22. # Become the oracle user
  23. su - oracle -c "/bin/bash -s" <<-'ORACLE'
  24.     export ORACLE_SID=rhnsat
  25.  
  26.     # Enable archive log on the database
  27.     sqlplus "/ as sysdba" <<-'EOF'
  28.         startup nomount;
  29.         alter database mount exclusive;
  30.         alter database archivelog;
  31.         shutdown immediate;
  32.     EOF
  33.  
  34.     # Configure the rman retention policy
  35.     rman target / nocatalog <<-'EOF'
  36.         startup;
  37.         configure retention policy to redundancy 2;
  38.         shutdown;
  39.     EOF
  40. ORACLE
  41.  
  42. # vim: ts=4 sw=4 smartindent noexpandtab
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement