Oracle数据库自动备份的实现历程
问题描述: Oracle自动备份脚本的实现。 错误提示1: Message file RMAN.msb not found Verify that Oracle_HOME is set properly 。。。。。。 错误原因: 自动执行的不能够识别相应的命令,需要在自动备份脚本中显式的声明Oracle的环境变量。 错误提示2:
问题描述:
Oracle自动备份脚本的实现。
错误提示1:
Message file RMAN.msb not found
Verify that Oracle_HOME is set properly
。。。。。。
错误原因:
自动执行的不能够识别相应的命令,需要在自动备份脚本中显式的声明Oracle的环境变量。
错误提示2:
standard in must be a tty
。。。。。。
错误原因:
不能在cron使用su或者管道等操作,必须将su命令移动到相关的shell脚本中。
错误提示3:
Argument Value Description
-----------------------------------------------------------------------------
target quoted-string connect-string for target database
catalog quoted-string connect-string for recovery catalog
nocatalog none if specified, then no recovery catalog
cmdfile quoted-string name of input command file
log quoted-string name of output message log file
trace quoted-string name of output debugging message log file
append none if specified, log is opened in append mode
debug optional-args activate debugging
msgno none show RMAN-nnnn prefix for all messages
send quoted-string send a command to the media manager
pipe string building block for pipe names
timeout integer number of seconds to wait for pipe input
checksyntax none check the command file for syntax errors
-----------------------------------------------------------------------------
Both single and double quotes (' or ") are accepted for a quoted-string.
Quotes are not required unless the string contains embedded white-space.
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00556: could not open CMDFILE "backup_ar.rcv"
。。。。。。
错误原因:
需要在cmdfile中指明绝对路径,不能因为shell脚本调用的cmdfile是在同一个目录下就可以直接使用文件名或者直接使用./
正确示例代码:
1、#cron文件
0 12,18 * * * /home/Oracle/bak_sh/backup_ar.sh
#表示每天12,18点对数据库归档日至进行全备份
2、入口shell文件,,文件名:backup_ar.sh
export Oracle_HOME=/home/u01/app/Oracle/Oracle/product/10.2.0/db_1
export Oracle_SID=test
export LANG=en_US.UTF-8
/home/u01/app/Oracle/Oracle/product/10.2.0/db_1/bin/rman cmdfile = backup_ar.rcv
3、rman备份脚本
connect target /
connect catalog rman/rman@rman
run{
allocate channel d1 device type disk;
sql 'alter system archive log current';
backup archivelog all delete input
format '/opt/rmanback/full_%u_%p_%c.ac' filesperset = 3;
release channel d1;
}
解决方法:
1、两种办法
一是用root的crontab,*/2 * * * * a.sh --》su - Oracle -c a.sh
一是在a.sh里加上Oracle的环境。
2、我们做的cron测试:
实例:
Vi /etc/cron.minly/new.sh
内容:
Su – Oracle –c “/home/Oracle/mginfo.sh”
Vi /home/Oracle/mginfo.sh
内容:
Exp mginfotech/mginfotech file=mginfotech.dmp log=mginfotech.log
Vi /etc/crontab
内容:
59 23 * * * root run-parts /etc/cron.minly
每晚23:59分钟执行
cron中无法读取环境变量
在shell中显示地export环境变量
export Oracle_HOME=/opt/ora9/product/9.2
export Oracle_SID=Oracle
export NLS_LANG=xxxxx
然后再试

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The retention period of Oracle database logs depends on the log type and configuration, including: Redo logs: determined by the maximum size configured with the "LOG_ARCHIVE_DEST" parameter. Archived redo logs: Determined by the maximum size configured by the "DB_RECOVERY_FILE_DEST_SIZE" parameter. Online redo logs: not archived, lost when the database is restarted, and the retention period is consistent with the instance running time. Audit log: Configured by the "AUDIT_TRAIL" parameter, retained for 30 days by default.

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

The amount of memory required by Oracle depends on database size, activity level, and required performance level: for storing data buffers, index buffers, executing SQL statements, and managing the data dictionary cache. The exact amount is affected by database size, activity level, and required performance level. Best practices include setting the appropriate SGA size, sizing SGA components, using AMM, and monitoring memory usage.

Oracle database server hardware configuration requirements: Processor: multi-core, with a main frequency of at least 2.5 GHz. For large databases, 32 cores or more are recommended. Memory: At least 8GB for small databases, 16-64GB for medium sizes, up to 512GB or more for large databases or heavy workloads. Storage: SSD or NVMe disks, RAID arrays for redundancy and performance. Network: High-speed network (10GbE or higher), dedicated network card, low-latency network. Others: Stable power supply, redundant components, compatible operating system and software, heat dissipation and cooling system.

The amount of memory required for an Oracle database depends on the database size, workload type, and number of concurrent users. General recommendations: Small databases: 16-32 GB, Medium databases: 32-64 GB, Large databases: 64 GB or more. Other factors to consider include database version, memory optimization options, virtualization, and best practices (monitor memory usage, adjust allocations).

To create a scheduled task in Oracle that executes once a day, you need to perform the following three steps: Create a job. Add a subjob to the job and set its schedule expression to "INTERVAL 1 DAY". Enable the job.

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())
