by Jeff Hunter, Sr. Database Administrator
Overview
This month, I introduce the UNIX nohup utility. Most of the information included in this article are taken directly from the nohup man page.
As a DBA, you have more than likely been faced with the need to run a command in UNIX that you know will take a long time to complete. Most often, you will want to run the command and "exit" from the terminal. When the shell exits though, it sends its children a SIGHUP signal, which by default causes them to be killed. All stopped, running and background jobs will ignore SIGHUP and continue running if their invocation is preceded by the nohup or if the process programmatically has chosen to ignore SIGHUP.
The nohup utility invokes the named command with the arguments supplied. When the command is invoked, nohup arranges for the SIGHUP signal to be ignored by the process.
Syntax
/usr/bin/nohup command [ argument ...]
Processes run by /usr/bin/nohup are immune to SIGHUP (hangup) and SIGQUIT (quit) signals.
/usr/xpg4/bin/nohup command [ argument ...]
Processes run by /usr/xpg4/bin/nohup are immune to SIGHUP.
Other Notes
The nohup utility does not arrange to make processes immune to a SIGTERM (terminate) signal, so unless they arrange to be immune to SIGTERM or the shell makes them immune to SIGTERM, they will receive it.
If nohup.out is not writable in the current directory, output is redirected to $HOME/nohup.out. If a file is created, the file will have read and write permission "600". If the standard error is a terminal, it is redirected to the standard output, otherwise it is not redirected. The priority of the process run by nohup is not altered.
If you are running the Korn shell as your login shell, and have nohup'ed jobs running when you attempt to logout, you will be warned with the message
You have jobs running.
You will then need to logout a second time to actually logout; however, your background jobs will continue to run.
The C-shell has a built-in command nohup that provides immunity from SIGHUP, but does not redirect output to nohup.out. Commands executed with `&' are automatically immune to HUP signals while in the background.
nohup does not recognize command sequences. In the case of the following command
example$ nohup command1; command2
The nohup utility applies only to command1. The command
example$ nohup (command1; command2)
is syntactically incorrect.
Operands
The following operands are supported:
command
The name of a command that is to be invoked. If the command operand names any of the special shell_builtins(1) utilities, the results are undefined.
argument
Any string to be supplied as an argument when invoking the command operand.
Examples
It is frequently desirable to apply nohup to pipelines or lists of commands. This can be done only by placing pipe- lines and command lists in a single file, called a shell script. One can then issue:
example$ nohup sh file
and the nohup applies to everything in file. If the shell script file is to be executed often, then the need to type sh can be eliminated by giving file execute permission.
Add an ampersand and the contents of file are run in the background with interrupts also ignored (see sh(1)):
example$ nohup file &
Tuesday, June 30, 2009
Thursday, June 25, 2009
Difference RMAN and EXPDP
Question: I've been using data pump (the export utility) to backup my database, but I wonder if I should be using RMAN instead. They both do backups, so what's the advantages of each?
Answer: Yes, RMAN and export both backup tables, and they both support flashback database, but there are some important differences:
* Data Pump Export (expdp) - The export utility is a "logical" backup, usually done by specifying specific tables. If you fail to do a "consistent" export, or if you fail to include related tables and use RESTRICTED and CONSISTENT mode (with referential integrity constraints), you may not be able to recover properly. Also, export can only read "cooked" files, and database with raw files (e.g. RAC) cannot be copied with export. Hence, export is often used as a supplement to RMAN, usually for the restore of specific tables.
* Recovery manager (rman) - RMAN is designed for backup and recovery, a extension of the Enterprise Backup Utility (EBU). RMAN reads raw files, takes time-consistent backups. manages referential integrity.
Advantages & disadvantages of Export:
* Free, and easy to use
* Very slow, compared to RMAN (examines every data block)
* Easy restore of a specific table
* Does not require ARCHIVELOG mode
* Export will discover the SCN that is closest to the specified time. This SCN is used to enable flashback with export.
Advantages & disadvantages of RMAN:
* Supports raw devices
* RMAN has block-level media recovery
* Has a catalog for backup tracking and a report utility
* Fast - If you dedicate a backup device for each production disk, you can backup terabytes in the time it takes to backup any single disk.
* Does hot or cold backups
* Backups and restores can be done in parallel
* Allows incremental backups (block change tracking)
* Interfaces with media management systems (TMS)
* RMAN can be used to backup changed data even after a nologging operation, and you can move away from archivelog mode.
by Burleson Consulting - www.dba-oracle.com
Answer: Yes, RMAN and export both backup tables, and they both support flashback database, but there are some important differences:
* Data Pump Export (expdp) - The export utility is a "logical" backup, usually done by specifying specific tables. If you fail to do a "consistent" export, or if you fail to include related tables and use RESTRICTED and CONSISTENT mode (with referential integrity constraints), you may not be able to recover properly. Also, export can only read "cooked" files, and database with raw files (e.g. RAC) cannot be copied with export. Hence, export is often used as a supplement to RMAN, usually for the restore of specific tables.
* Recovery manager (rman) - RMAN is designed for backup and recovery, a extension of the Enterprise Backup Utility (EBU). RMAN reads raw files, takes time-consistent backups. manages referential integrity.
Advantages & disadvantages of Export:
* Free, and easy to use
* Very slow, compared to RMAN (examines every data block)
* Easy restore of a specific table
* Does not require ARCHIVELOG mode
* Export will discover the SCN that is closest to the specified time. This SCN is used to enable flashback with export.
Advantages & disadvantages of RMAN:
* Supports raw devices
* RMAN has block-level media recovery
* Has a catalog for backup tracking and a report utility
* Fast - If you dedicate a backup device for each production disk, you can backup terabytes in the time it takes to backup any single disk.
* Does hot or cold backups
* Backups and restores can be done in parallel
* Allows incremental backups (block change tracking)
* Interfaces with media management systems (TMS)
* RMAN can be used to backup changed data even after a nologging operation, and you can move away from archivelog mode.
by Burleson Consulting - www.dba-oracle.com
Subscribe to:
Posts (Atom)