search
HomeDatabaseMysql TutorialOracle数据库自动备份的实现历程

Oracle数据库自动备份的实现历程

Jun 07, 2016 pm 04:18 PM
oraclebackupaccomplishdatabaseautomatic

问题描述: 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

然后再试

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How do you handle database upgrades in MySQL?How do you handle database upgrades in MySQL?Apr 30, 2025 am 12:28 AM

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

What are the different backup strategies you can use for MySQL?What are the different backup strategies you can use for MySQL?Apr 30, 2025 am 12:28 AM

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

What is MySQL clustering?What is MySQL clustering?Apr 30, 2025 am 12:28 AM

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

How do you optimize database schema design for performance in MySQL?How do you optimize database schema design for performance in MySQL?Apr 30, 2025 am 12:27 AM

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

How can you optimize MySQL performance?How can you optimize MySQL performance?Apr 30, 2025 am 12:26 AM

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi

How to use MySQL functions for data processing and calculationHow to use MySQL functions for data processing and calculationApr 29, 2025 pm 04:21 PM

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

An efficient way to batch insert data in MySQLAn efficient way to batch insert data in MySQLApr 29, 2025 pm 04:18 PM

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

Steps to add and delete fields to MySQL tablesSteps to add and delete fields to MySQL tablesApr 29, 2025 pm 04:15 PM

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor