search
HomeDatabaseMysql TutorialOracle技术之用RMAN克隆数据库

源库RHEL4.5:192.168.137.199 GLOBAL_NAME=WENDING.LK Oracle_SID=WENDING 克隆库RHEL4.5:192.168.137.200 GLOBAL_NAME=STRM.L

源库RHEL4.5:192.168.137.199 GLOBAL_NAME=WENDING.LK Oracle_SID=WENDING

克隆库RHEL4.5:192.168.137.200 GLOBAL_NAME=STRM.LK ORACLE_SID=STRM

1. 全备份源库

$ sqlplus '/as sysdba'

记下备份前的SCN,规复的时间就规复到这个点。

SQL> select DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER from dual;

GET_SYSTEM_CHANGE_NUMBER

------------------------

181557

SQL> exit

$ mkdir -p /orahome/backup

$ cd /orahome

$ vi backup.rcv

run{

allocate channel c1 type disk;

backup full database format '/orahome/backup/db_t%t_s%s_p%p.bak';

backup archivelog all format '/orahome/backup/arch_u%u.bak';

backup current controlfile format '/orahome/backup/cf_u%u.bak';

release channel c1;

}

$ nohup rman target / @backup.rcv log backup.log &

$ tail -50f backup.log

参照源库参数文件新建一个克隆库参数文件:

SQL> create pfile = '/orahome/backup/initSTRM.ora' from spfile;

得到源库数据文件的编号和寄放职位 信息,是为了预备克隆库参数db_file_name_convert或rman规复时set newname的设置:

$ sqlplus '/as sysdba'

SQL> col name format a60

SQL> set lines 1024

SQL> select file#,name from v$datafile union all select file#,name from v$tempfile;

FILE# NAME

---------- ------------------------------------------------------------

1 /orahome/oradata/WENDING/system.dbf

2 /orahome/oradata/WENDING/undotbs1.dbf

3 /orahome/oradata/WENDING/sysaux.dbf

4 /orahome/oradata/WENDING/users01.dbf

1 /orahome/oradata/WENDING/temp01.dbf

SQL> exit

拷贝备份文件到克隆库主机的同一职位 ,确保克隆库主机也有目次 /orahome/backup。

$ cd /orahome/backup

$ scp *.bak 192.168.137.200:/orahome/backup

$ scp initSTRM.ora 192.168.137.200:/orahome/backup

2. 克隆库预备事变

克隆库上设置干系 的环境 变量:

$ vi .bash_profile (思量 从源库主机拷贝一份,,然后批改ORACLE_SID参数值)

export ORACLE_BASE=/u01/app/oracle;

export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1;

export ORACLE_SID=STRM;

export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"

export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"

$ . .bash_profile

3. 批改克隆库参数文件

$ vi /orahome/backup/initSTRM.ora

:%s/WENDING/STRM/g

一样平常批改以下参数:

audit_file_dest,background_dump_dest,core_dump_dest,user_dump_dest,db_name,db_unique_name,log_archive_dest_1,control_files.

并确保以下参数:

*.remote_login_passwordfile = exclusive

*.DB_FILE_NAME_CONVERT = '/orahome/oradata/WENDING/', '/orahome/oradata/STRM/'

4. 按照步调 3批改的路径信息在克隆库主机新建须要的目次

$ mkdir -p /orahome/flash_recovery_area

$ mkdir -p /orahome/arch/STRM

$ mkdir -p /orahome/oradata/STRM/

$ mkdir -p /u01/app/oracle/admin/STRM/adump

mkdir -p /u01/app/oracle/admin/STRM/bdump

mkdir -p /u01/app/oracle/admin/STRM/cdump

mkdir -p /u01/app/oracle/admin/STRM/dpdump

mkdir -p /u01/app/oracle/admin/STRM/udump

5. 在克隆库创建 一个新的password文件

(unix/Linux下暗码文件技俩必需是orapw

$ orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=iamwangnc force=y

6. 克隆库startup nomount

$ sqlplus '/as sysdba'

SQL> create spfile from pfile='/orahome/backup/initSTRM.ora';

SQL> startup nomount;

SQL> exit

7. 克隆库用rman规复

$ cd /orahome

$ vi recover.rcv (由于源库在全备后还也许发生归档文件,以是规复的时间要设置set until值,不然会发生过错 RMAN-06025)

run{

allocate auxiliary channel c1 type disk;

# set until time '2008-11-21.11:33:31';

# set until sequence 21254 thread 1;

set until scn 181557;

duplicate target database to STRM

LOGFILE

group 1 ('/orahome/oradata/STRM/REDO01.DBF') SIZE 50M,

group 2 ('/orahome/oradata/STRM/REDO02.DBF') SIZE 50M,

group 3 ('/orahome/oradata/STRM/REDO03.DBF') SIZE 50M;

}

其它set newname和LOGFILE后头的文件职位 信息可以按照本身必要 设定。

起头规复:(wending.lk是源库做事名,确保源库的监听已经启动)

$ nohup rman target sys/iamwangnc@192.168.137.199:1521/wending.lk auxiliary / @recover.rcv log recover.log &

$ tail -50f recover.log

database opened

Finished Duplicate Db at 2008-11-21 13:02:39

规复数据库时发生如下过错:RMAN-06025: no backup of log thread 1 seq 21255 scn 4144283685 found to restore

多次执行备份﹐然后克隆﹐发现有时候出错﹐有时候不出错。非常费解。后来在仔细观察发现,在短缺末了一个归档日记文件会出错。而这个日记文件是在备份之后产

生的﹐目标数据的备份中没有。把这个文件传递到目标主机就可以了。而假如产生备份之后﹐短时间之内克隆﹐原数据库没有归档文件﹐则不会出现错误。这个在很多

操纵文档中﹐没有讲到。

8. 测试克隆库

$ sqlplus '/as sysdba'

SQL> select status from v$instance;

SQL> archive log list;

linux

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

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.