Home Database Mysql Tutorial Oracle技术之用RMAN克隆数据库

Oracle技术之用RMAN克隆数据库

Jun 07, 2016 pm 05:30 PM

源库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 of this Website
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

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

When might a full table scan be faster than using an index in MySQL? When might a full table scan be faster than using an index in MySQL? Apr 09, 2025 am 12:05 AM

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Can I install mysql on Windows 7 Can I install mysql on Windows 7 Apr 08, 2025 pm 03:21 PM

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

Explain InnoDB Full-Text Search capabilities. Explain InnoDB Full-Text Search capabilities. Apr 02, 2025 pm 06:09 PM

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

Difference between clustered index and non-clustered index (secondary index) in InnoDB. Difference between clustered index and non-clustered index (secondary index) in InnoDB. Apr 02, 2025 pm 06:25 PM

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values ​​and pointers to data rows, and is suitable for non-primary key column queries.

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

Can mysql and mariadb coexist Can mysql and mariadb coexist Apr 08, 2025 pm 02:27 PM

MySQL and MariaDB can coexist, but need to be configured with caution. The key is to allocate different port numbers and data directories to each database, and adjust parameters such as memory allocation and cache size. Connection pooling, application configuration, and version differences also need to be considered and need to be carefully tested and planned to avoid pitfalls. Running two databases simultaneously can cause performance problems in situations where resources are limited.

The relationship between mysql user and database The relationship between mysql user and database Apr 08, 2025 pm 07:15 PM

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Apr 02, 2025 pm 07:05 PM

MySQL supports four index types: B-Tree, Hash, Full-text, and Spatial. 1.B-Tree index is suitable for equal value search, range query and sorting. 2. Hash index is suitable for equal value searches, but does not support range query and sorting. 3. Full-text index is used for full-text search and is suitable for processing large amounts of text data. 4. Spatial index is used for geospatial data query and is suitable for GIS applications.

See all articles