Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

Script archive log transfer to standby db

SOLVED
Go to solution
John Flanagan
Regular Advisor

Script archive log transfer to standby db

Hi,

I have just setup a standby db (Oracle 8.0.5) and everything works fine but I would like to script the transfer for archive log files from one computer to the other. Please submit any scripts to do this.

John.
16 REPLIES
RAC_1
Honored Contributor

Re: Script archive log transfer to standby db

you have few options here.

1 you have remsh/rlogin enabled for the user. (Not secure)
2 ftp.(not so secure)
ftp -in hostname << EOF
user username password
bin
cd /dir_you want
put file_you_want
close
EOF

Put this in script and run it at the time you want.

3 Scp - secure copy. a part of ssh.
There is no substitute to HARDWORK
Ian Dennison_1
Honored Contributor

Re: Script archive log transfer to standby db

John,

I did this last year at my old employer.

Basic Steps to follow,...

Check if another copy of this script is already running
Check if any logs to transfer (keep a record of the last log transferred)

Check if connection to remote server is available

Build list of files to transfer

For each file to transfer
Compress and relocate (ftp, rcp, or ssh)
Check File arrived at remote site
Update record of last log transferred
end loop

At the standby server end, you are going to have to ensure that the logs you apply are in sequence and alerts if anything if wrong.

Share and Enjoy! Ian
Building a dumber user
Christian Gebhardt
Honored Contributor

Re: Script archive log transfer to standby db

Hi

4. you can use nfs, it's easy to script, you only need the copy-command, maybe a little bit slow.

5. Do you have EMC? There's a software from EMC called timefinder to split VG's and mount them on other hosts, very quick and expensive.

Chris
Yogeeraj_1
Honored Contributor

Re: Script archive log transfer to standby db

Hi,

If Oracle is not archiving logs automatically to the standby site, then manually transfer the logs to the desired location on the standby host using an appropriate operating system utility for transferring binary data. For example, enter:

Using NFS:

% cp /oracle/arc_dest/*.arc /standby/arc_dest


Or Remote command:
% rcp remote_server:/oracle/arc_dest/*.arc /standby/arc_dest

Both assuming you have a high speed LAN interconnecting the servers. (otherwise, you may have to use compression/decompression techniques to reduce the size of the files for faster transmission.

After you have transferred the log files, you would issue a RECOVER statement to place the standby database in manual recovery mode.

For example, execute one of the following statements:

RECOVER STANDBY DATABASE # uses location for logs specified in
# initialization parameter file
RECOVER FROM '/logs' STANDBY DATABASE # specifies nondefault location


Note that: As Oracle generates archived redo logs, you must continually transfer and apply them to the standby database to keep it current.

Hope this helps!
Best Regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
John Flanagan
Regular Advisor

Re: Script archive log transfer to standby db

Thanks everybody, but the bit I need help on is how to compare the 2 directories and copy across only the new files.

John
James R. Ferguson
Acclaimed Contributor

Re: Script archive log transfer to standby db

Hi John:

To compare two directories, you can use 'dircmp(1)'. Have a look at its man pages.

Regards!

...JRF...
Ian Dennison_1
Honored Contributor

Re: Script archive log transfer to standby db

John,

If you keep a record of the last Redo Log 'shipped' to the remote site by your script, and perform an 'll -lt *.dbf |head -n 2' on your local archive directory, this will give you the information you require.

Note: My version of this also detected the last Archive Log applied by the Standby Database ('archive log list' in svrmgrl), and confirmed the sequential number for the Redo Logs (in case the Redo Log Archiving Tools you use delete the Redo Log before you can ship it to the Remote site).

Share and Enjoy! Ian
Building a dumber user
Ralph Grothe
Honored Contributor

Re: Script archive log transfer to standby db

If you want to avoid redundant file transfers you might consider rsync

see:

http://hpux.asknet.de/hppd/hpux/Networking/Admin/rsync-2.5.5/
Madness, thy name is system administration
John Flanagan
Regular Advisor

Re: Script archive log transfer to standby db

resync sounds nice but it seems to only be available on 11. I am still using 10.20. I am creating a script to try to solve the problem.

John.
John Flanagan
Regular Advisor

Re: Script archive log transfer to standby db

If anybody is interested this is the script I created. Seems to work OK so far.

John.

livelogno()
{
remsh ptihp1 'ls -t /archive/oradata/PAULIVE/*.ARC | head -n 1 | cut -c 37-46'
}

stdbylogno()
{
ls -t /archive/oradata/PAULIVE/*.ARC | head -n 1 | cut -c 37-46
}

livelogcount=`livelogno`
stdbylogcount=`stdbylogno`
filestocopy=`expr $livelogcount - $stdbylogcount`
echo $livelogcount
echo $stdbylogcount
echo $filestocopy

for arcfile in `remsh ptihp1 'ls -t /archive/oradata/PAULIVE/*.ARC' | head -n $filestocopy`
do
echo $arcfile
echo `rcp ptihp1:$arcfile $arcfile`
done
Brian Crabtree
Honored Contributor
Solution

Re: Script archive log transfer to standby db

John,

Here is the script that I wrote to do what you are talking about. It assumes that you are running with OFA standards (/var/opt/oracle/arch// as a log directory). You will need to change lines 18 and 43 (if not-OFA). Otherwise, it should work. If you want, I can post the script to apply the logs to the standby database as well.

Brian
Brian Crabtree
Honored Contributor

Re: Script archive log transfer to standby db

Forgot attachment. Sorry.
John Flanagan
Regular Advisor

Re: Script archive log transfer to standby db

Brian,

Thanks for the script. My one works but it is probably not the best. I now have 3 scripts 1) to swithch logs on the current system 2) copy log files 3) import log files. All work but I have no logging or error checking so all scripts posted are useful.

As you can see my scripting knowledge is basic and I have a question on your script. Take for example the copy file line

rcp ${j} ${2}:${3}

What do the {} do?

John.
Marty Metras
Super Advisor

Re: Script archive log transfer to standby db

John,

I am doing just what you are asking.
On the Primary Server:
I force a log switch.
I copy the archive logs to a safe directory and another directory for the standby server to pickup and write a file there is only there when there are files for the Standby server to get. Then I remove the files from the Archive Log directory.

On the Standby Server:
The scripts checks to see if there are new files get. When there is it gets them from the primary server and then copies then to a save directory and to the archive log directory. Then it tells Oracle to do the "recover standby database". Then it removes the flag from the Primary server so it will get new files ready.

There are many other things that happen in these scripts. Files are compressed; the program will not run if the primary or standby processes are already running. It checks to see what the last log# was so when the standby was updated the log# should match on both servers. Much more.

I'm using rsync, ssh, sftp and gzip. And the two servers are 1000 miles apart. Oh! 1600km
Also using Oracle 8.0.5 and HP-UX 11.0

I'm in the process of rewriting the scrip to clean it up. Would like to see it?

Marty
The only thing that always remain the same are the changes.
John Flanagan
Regular Advisor

Re: Script archive log transfer to standby db

Marty,

I am allways willing to learn something so I would like to see your scripts. However I am using HP-UX 10.20 and I don't think rsync is available.

Thanks,

John.
Brian Crabtree
Honored Contributor

Re: Script archive log transfer to standby db

The "{}" (brackets) around a variable mean that only the information inside the brackets will be parsed.

ie: Run the following:

export ORACLE=temp
export ORACLE_SID=BLAH
echo ${ORACLE_SID}
echo ${ORACLE}_SID

It is a good idea to use brackets around the variable just to make sure that something doesn't get parsed that you dont want to get parsed.

I will also post the apply script.

Brian