This discussion is archived
7 Replies Latest reply: Jul 29, 2013 6:14 AM by Mihael RSS

How to schedule a *nix backup shell script in a clustered database

aLuViAn Newbie
Currently Being Moderated

Hi,

 

We have a 3 node clustered Production database (11gR2) on RHEL 5.4 and I've written a couple of linux shell scripts to create full and incremental backups, check the integrity, delete the obsolete backups and so on..

 

Right now I have my script files loaded on one of the servers and using cron, I have scheduled the backup. Its working perfectly.

But the problem is, if the server which has the script fails, there won't be any scheduled backups running and that makes me worry..

I've read about the DBMS scheduler in Oracle documentation and tried to use it but no luck.

Can someone help me over this issue? I mean, not necessarily using Scheduler but a method to have my backup scripts scheduled on the database (and not on a single server).

Also we will be moving to AIX soon, will that make any major difference?

  • 1. Re: How to schedule a *nix backup shell script in a clustered database
    Mihael Pro
    Currently Being Moderated

    With DBMS_SCHEDULER you can create local external job (JOB_TYPE='EXECUTABLE') that will use shell script as JOB_ACTION. The script should be on shared file system or copied on all nodes to the same location.

  • 2. Re: How to schedule a *nix backup shell script in a clustered database
    aLuViAn Newbie
    Currently Being Moderated

    I've created a test.sh which puts the word "test" each time it runs. I created my scheduled job as follows:

     

    begin

    dbms_scheduler.create_job('testjob',

       job_action=>'/bin/sh /dbapp/test.sh',

       job_type=>'executable', enabled=>false,

       repeat_interval => 'FREQ=MINUTELY;INTERVAL=5');

    dbms_scheduler.enable('testjob');

    end;

     

    I've distributed the file on the same place over my cluster. By getting the query from dba_scheduler_jobs, I see the status is RUNNING and it has failed each time that has been run...what am I getting wrong? Is there any place which can I check the logs / reasons of failure?

  • 3. Re: How to schedule a *nix backup shell script in a clustered database
    Mihael Pro
    Currently Being Moderated

    dbms_scheduler.create_job('testjob',

       job_action=>'/bin/sh /dbapp/test.sh',

     

    I've distributed the file on the same place over my cluster. By getting the query from dba_scheduler_jobs, I see the status is RUNNING and it has failed each time that has been run...what am I getting wrong? Is there any place which can I check the logs / reasons of failure?

     

    Try this : job_action => '/dbapp/test.sh'

     

    Logs can be found in DBA_SCHEDULER_JOB_LOG and DBA_SCHEDULER_JOB_RUN_DETAILS

  • 4. Re: How to schedule a *nix backup shell script in a clustered database
    aLuViAn Newbie
    Currently Being Moderated

    I'm getting these errors:

    ORA-27370: job slave failed to launch a job of type EXECUTABLE

    ORA-27300: OS system dependent operation:timed out getting external job p failed with status: 11

    ORA-27301: OS failure message: Resource temporarily unavailable

    ORA-27302: failure occurred at: sjsec 6a

     

    After a couple of searches on the web, I tried compiling my job with SYS schema instead of SYSTEM. Now I'm getting:

    ORA-27369: job of type EXECUTABLE failed with exit code: Operation not permitted

    STANDARD_ERROR="/dbapp/test.sh: line 2: result.log: Permission denied"

    (result.log is a file that the executable creates)

     

    Then I changed the run_user and run_group in /rdbms/admin/externaljob.ora to oracle user and oinstall group, still I'm getting the same error. Do I need to restart the instance in order to have my changes take effect?

  • 5. Re: How to schedule a *nix backup shell script in a clustered database
    Mihael Pro
    Currently Being Moderated

    You can use DBMS_SCHEDULER.CREATE_CREDENTIAL procedure to create OS username/password pair with wich job will run. Then set credential_name parameter for job.

  • 6. Re: How to schedule a *nix backup shell script in a clustered database
    aLuViAn Newbie
    Currently Being Moderated

    Thanks very much...it worked!

    I hope I don't have any issue with the cluster, the thing is, in my backup script I need to put SID in order to be able to log in to RMAN. As you know, in RAC you have to mention your instance name instead of database name when you're logging in from shell, which differs in each node of the cluster.

    I have put the corresponding ORACLE_SID in the copy of each script on each node, so the copies are not "exactly" the same. I still don't know the results.

  • 7. Re: How to schedule a *nix backup shell script in a clustered database
    Mihael Pro
    Currently Being Moderated

    To make the script identical on each node, you can use tns name when connecting to target:

     

    rman target sys/pwd@tns

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points