本文主要是介绍ASM 10G 基于RMAN 迁移,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
ASM 10G 基于RMAN 迁移场景
单节点基于10G R2 的数据库,其数据文件及日志文件均存放在ASM 里,现在为业务需求,将此数据库做迁
移,迁移到另个机房,但是两个机房的网络是通畅的,为尽量减少数据的丢失及平稳迁移和经济实惠,迁
移时,数据库需停应用
工具
本次采用RMAN 的duplicate 命令来进行迁移,运用此命令简化复杂度;
类型主机名IP 地址ASM 磁盘组ASM 实例名数据库实例名
source trsen 192.168.8.115
DATA_DG
+ASM oral
FLASHARE_DG
target clone.trsen.com 192.168.8.116
DATA_DG
+ASM clonedb
FLASHARE_DG
==>查看FRA 的位置
SQL> show parameter db_recovery_file_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string +FLASHARE_DG
==>查看该参数状态是否是EXCLUSIVE
SQL> show parameter remote_login_passwordfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile string EXCLUSIVE
若不是,修改,重启数据库
Alter system set remote_login_passwordfile= EXCLUSIVE scope=spfile
==>oral 库的DBID
SQL> select dbid from v$database;
DBID
----------
1363392650
==>查看数据库数据文件信息
SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
+DATA_DG/oral/datafile/users.259.835611833
+DATA_DG/oral/datafile/sysaux.257.835611829
+DATA_DG/oral/datafile/undotbs1.258.835611831
+DATA_DG/oral/datafile/system.256.835611829
+DATA_DG/oral/datafile/example.269.835611969
==>查看控制文件信息
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
+DATA_DG/oral/controlfile/current.261.835611915
+DATA_DG/oral/controlfile/current.260.835611919
==>查看redo 日志信息
SQL> set linesize 200;
SQL> col member for a50;
SQL> select group#,member,status from v$logfile;
GROUP# MEMBER STATUS
---------- -------------------------------------------------- -------
3 +DATA_DG/oral/onlinelog/group_3.266.835611939 STALE
3 +DATA_DG/oral/onlinelog/group_3.267.835611945 STALE
2 +DATA_DG/oral/onlinelog/group_2.264.835611933 STALE
2 +DATA_DG/oral/onlinelog/group_2.265.835611937 STALE
1 +DATA_DG/oral/onlinelog/group_1.262.835611925
1 +DATA_DG/oral/onlinelog/group_1.263.835611927
==>查看归档日志模式,一定是归档
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 247
Next log sequence to archive 249
Current log sequence 249
==>查看数据库版本信息
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 – Production
==>估算source 库的大小
SQL> select sum(bytes)/1024/1024 ||'MB' from dba_segments;
SUM(BYTES)/1024/1024||'MB'
------------------------------------------
953.8125MB
==>放置备份集的位置
[root@trsen rman_backup]# pwd
/u01/rman_backup
[root@trsen rman_backup]# ls -l
total 1635328
-rw-r----- 1 oracle oinstall 845312 May 20 10:15 archive_ORCL_40:848052941:1.dbf
-rw-r----- 1 oracle oinstall 1664638976 May 20 10:15 backdb_ORCL_38:848052850:1.dbf
-rw-r----- 1 oracle oinstall 7438336 May 20 10:15 backdb_ORCL_39:848052935:1.dbf
==>在oral 库上进行rman 备份的脚本;注:rman 的备份集位置要统一,即目标和源都要此目录
/u01/rman_backup/,
run {
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE BACKUP OPTIMIZATION ON;
ALLOCATE CHANNEL 'ch00' TYPE DISK;
backup database include current controlfile format '/u01/rman_backup/backdb_%d_%s:%t:%p.dbf';
backup archivelog all delete all input format '/u01/rman_backup/archive_%d_%s:%t:%p.dbf';
RELEASE CHANNEL 'ch00';
}
==>创建oral 库的pfile,给clonedb 库使用
SQL> create pfile='/u01/rman_backup/init.ora' from spfile;
File created.
[oracle@trsen rman_backup]$ pwd
/u01/rman_backup
[oracle@trsen rman_backup]$ ls -l init.ora
-rw-r--r-- 1 oracle oinstall 1010 May 20 13:35 init.ora
参数文件内容
orcl.__db_cache_size=192937984
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__shared_pool_size=79691776
orcl.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/oral/adump'
*.background_dump_dest='/u01/app/oracle/admin/oral/bdump'
*.compatible='10.2.0.1.0'
*.control_files='+DATA_DG/orcl/controlfile/current.261.835611915','+DATA_DG/orcl/controlfile
/current.260.835611919'
*.core_dump_dest='/u01/app/oracle/admin/oral/cdump'
*.db_block_size=8192
*.db_create_file_dest='+DATA_DG'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='oral'
*.db_recovery_file_dest='+FLASHARE_DG'
*.db_recovery_file_dest_size=2956984320
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.job_queue_processes=10
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_max_size=209715200
*.sga_target=284164096
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/oral/udump'
*.utl_file_dir=''
==>在orcl 库,创建密码文件
[oracle@trsen dbs]$ orapwd file=orapwclonedb password=oracle
将产生的orapwclonedb 文件复制到clonedb 库的/u01/app/oracle/product/10.2.0/db_1/dbs 目录下
==>这里的ASM 配置及数据软件安装、监听配置不在说明
==>将oral 库创建的pfile scp 到clonedb 所在服务器上指定位置,并命名为init+实例名.ora
/u01/app/oracle/product/10.2.0/db_1/dbs/initclonedb.ora
修改参数文件为
clonedb.__db_cache_size=197132288
clonedb.__java_pool_size=4194304
clonedb.__large_pool_size=4194304
clonedb.__shared_pool_size=75497472
clonedb.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/clonedb/adump'
*.background_dump_dest='/u01/app/oracle/admin/clonedb/bdump'
*.compatible='10.2.0.1.0'
*.control_files='+DATA_DG/clonedb/controlfile/controlfile.ctl','+DATA_DG/clonedb/controlfile
/controlfile2.ctl'
*.core_dump_dest='/u01/app/oracle/admin/clonedb/cdump'
*.db_block_size=8192
*.db_create_file_dest='+DATA_DG'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_unique_name='clonedb'
*.db_name='clonedb'
*.db_recovery_file_dest='+FLASHARE_DG'
*.db_recovery_file_dest_size=2956984320
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.job_queue_processes=10
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_max_size=209715200
*.sga_target=284164096
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/clonedb/udump'
*.utl_file_dir=''
*.db_file_name_convert='+DATA_DG/orcl','+DATA_DG/clonedb'==>转换数据文件位置
*.log_file_name_convert='+DATA_DG/orcl','+DATA_DG/clonedb'==>转换日志文件位置
==>clonedb 数据库端的网络配置,这里主要是tnsname.ora
[oracle@clone admin]$ more tnsnames.ora
# tnsnames.ora Network Configuration File:
/u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
orcl =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.115)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
CLONEDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.116)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = clonedb)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
==>目录结构及权限
[oracle@clone clonedb]$ pwd
/u01/app/oracle/admin/clonedb
[oracle@clone clonedb]$ ll
total 24
drwxr-x--- 2 oracle oinstall 4096 May 20 12:36 adump
drwxr-x--- 2 oracle oinstall 4096 May 20 12:41 bdump
drwxr-x--- 2 oracle oinstall 4096 May 13 12:26 cdump
drwxr-x--- 2 oracle oinstall 4096 May 13 12:27 dpdump
drwxr-x--- 2 oracle oinstall 4096 May 20 13:43 pfile
drwxr-x--- 2 oracle oinstall 4096 May 20 12:36 udump
[oracle@clone +ASM]$ pwd
/u01/app/oracle/admin/+ASM
[oracle@clone +ASM]$ ll
total 20
drwxr-x--- 2 oracle oinstall 4096 May 20 12:26 bdump
drwxr-x--- 2 oracle oinstall 4096 May 19 16:34 cdump
drwxr-x--- 2 oracle oinstall 4096 May 13 12:26 cudmp
drwxr-x--- 2 oracle oinstall 4096 May 19 16:34 pfile
drwxr-x--- 2 oracle oinstall 4096 May 20 12:27 udump
1、启动cloned 数据库到nomount 阶段
[oracle@clone ~]$ echo $ORACLE_SID
clonedb
[oracle@clone ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Tue May 20 14:33:24 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 83887696 bytes
Database Buffers 197132288 bytes
Redo Buffers
2、在cloned 数据库服务器端,用rman 连接orcl 数据库;并且连接clonedb 数据库的辅助实例
[oracle@clone ~]$ rman target sys/oracle@orcl
Recovery Manager: Release 10.2.0.1.0 - Production on Tue May 20 14:34:12 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1363392650)
RMAN> CONNECT AUXILIARY sys/oracle@clonedb
connected to auxiliary database: CLONEDB (not mounted)
RMAN>
3、在rman 里运行DUPLICATE TARGET DATABASE TO clonedb 命令
RMAN> DUPLICATE TARGET DATABASE TO clonedb;
Starting Duplicate Db at 20-MAY-14
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=156 devtype=DISK
contents of Memory Script:
{
set until scn 2838685;
set newname for datafile 1 to
"+DATA_DG/clonedb/datafile/system.256.835611829";
set newname for datafile 2 to
"+DATA_DG/clonedb/datafile/undotbs1.258.835611831";
set newname for datafile 3 to
"+DATA_DG/clonedb/datafile/sysaux.257.835611829";
set newname for datafile 4 to
"+DATA_DG/clonedb/datafile/users.259.835611833";
set newname for datafile 5 to
"+DATA_DG/clonedb/datafile/example.269.835611969";
restore
check readonly
clone database
;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 20-MAY-14
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to +DATA_DG/clonedb/datafile/system.256.835611829
restoring datafile 00002 to +DATA_DG/clonedb/datafile/undotbs1.258.835611831
restoring datafile 00003 to +DATA_DG/clonedb/datafile/sysaux.257.835611829
restoring datafile 00004 to +DATA_DG/clonedb/datafile/users.259.835611833
restoring datafile 00005 to +DATA_DG/clonedb/datafile/example.269.835611969
channel ORA_AUX_DISK_1: reading from backup piece
/u01/rman_backup/backdb_ORCL_38:848052850:1.dbf
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/rman_backup/backdb_ORCL_38:848052850:1.dbf tag=TAG20140520T101410
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:16
Finished restore at 20-MAY-14
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "CLONEDB" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '+DATA_DG/clonedb/onlinelog/group_1.262.835611925',
'+DATA_DG/clonedb/onlinelog/group_1.263.835611927' ) SIZE 50 M REUSE,
GROUP 2 ( '+DATA_DG/clonedb/onlinelog/group_2.264.835611933',
'+DATA_DG/clonedb/onlinelog/group_2.265.835611937' ) SIZE 50 M REUSE,
GROUP 3 ( '+DATA_DG/clonedb/onlinelog/group_3.266.835611939',
'+DATA_DG/clonedb/onlinelog/group_3.267.835611945' ) SIZE 50 M REUSE
DATAFILE
'+DATA_DG/clonedb/datafile/system.257.848068879'
CHARACTER SET WE8ISO8859P1
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
released channel: ORA_AUX_DISK_1
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=848069024
filename=+DATA_DG/clonedb/datafile/undotbs1.256.848068877
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=848069024
filename=+DATA_DG/clonedb/datafile/sysaux.259.848068881
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=848069024
filename=+DATA_DG/clonedb/datafile/users.258.848068879
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=848069024
filename=+DATA_DG/clonedb/datafile/example.260.848068881
contents of Memory Script:
{
set until scn 2838685;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 20-MAY-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=156 devtype=DISK
starting media recovery
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=285
channel ORA_AUX_DISK_1: reading from backup piece
/u01/rman_backup/archive_ORCL_40:848052941:1.dbf
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/rman_backup/archive_ORCL_40:848052941:1.dbf tag=TAG20140520T101540
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:17
archive log
filename=+FLASHARE_DG/clonedb/archivelog/2014_05_20/thread_1_seq_285.256.848069029 thread=1
sequence=285
channel clone_default: deleting archive log(s)
archive log
filename=+FLASHARE_DG/clonedb/archivelog/2014_05_20/thread_1_seq_285.256.848069029 recid=1
stamp=848069035
media recovery complete, elapsed time: 00:00:02
Finished recover at 20-MAY-14
contents of Memory Script:
{
shutdown clone;
startup clone nomount ;
}
executing Memory Script
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 83887696 bytes
Database Buffers 197132288 bytes
Redo Buffers 2973696 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "CLONEDB" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '+DATA_DG/clonedb/onlinelog/group_1.262.835611925',
'+DATA_DG/clonedb/onlinelog/group_1.263.835611927' ) SIZE 50 M REUSE,
GROUP 2 ( '+DATA_DG/clonedb/onlinelog/group_2.264.835611933',
'+DATA_DG/clonedb/onlinelog/group_2.265.835611937' ) SIZE 50 M REUSE,
GROUP 3 ( '+DATA_DG/clonedb/onlinelog/group_3.266.835611939',
'+DATA_DG/clonedb/onlinelog/group_3.267.835611945' ) SIZE 50 M REUSE
DATAFILE
'+DATA_DG/clonedb/datafile/system.257.848068879'
CHARACTER SET WE8ISO8859P1
contents of Memory Script:
{
set newname for tempfile 1 to
"+DATA_DG/clonedb/tempfile/temp.268.835611959";
switch clone tempfile all;
catalog clone datafilecopy "+DATA_DG/clonedb/datafile/undotbs1.256.848068877";
catalog clone datafilecopy "+DATA_DG/clonedb/datafile/sysaux.259.848068881";
catalog clone datafilecopy "+DATA_DG/clonedb/datafile/users.258.848068879";
catalog clone datafilecopy "+DATA_DG/clonedb/datafile/example.260.848068881";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to +DATA_DG/clonedb/tempfile/temp.268.835611959 in control file
cataloged datafile copy
datafile copy filename=+DATA_DG/clonedb/datafile/undotbs1.256.848068877 recid=1
stamp=848069068
cataloged datafile copy
datafile copy filename=+DATA_DG/clonedb/datafile/sysaux.259.848068881 recid=2 stamp=848069068
cataloged datafile copy
datafile copy filename=+DATA_DG/clonedb/datafile/users.258.848068879 recid=3 stamp=848069068
cataloged datafile copy
datafile copy filename=+DATA_DG/clonedb/datafile/example.260.848068881 recid=4 stamp=848069068
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=848069068
filename=+DATA_DG/clonedb/datafile/undotbs1.256.848068877
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=848069068
filename=+DATA_DG/clonedb/datafile/sysaux.259.848068881
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=848069068
filename=+DATA_DG/clonedb/datafile/users.258.848068879
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=848069068
filename=+DATA_DG/clonedb/datafile/example.260.848068881
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 20-MAY-14
RMAN>
六、对clonedb 数据库信息检查
==>查看name 信息
SQL> show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string +DATA_DG/orcl, +DATA_DG/clonedb
db_name string clonedb
db_unique_name string clonedb
global_names boolean FALSE
instance_name string clonedb
lock_name_space string
log_file_name_convert string +DATA_DG/orcl, +DATA_DG/clonedb
service_names string clonedb
==>检查最近五天的无效对象
SQL> select owner, object_name, object_type, created, last_ddl_time, status
2 from dba_objects
3 where status = 'INVALID'
4 and last_ddl_time <= (select sysdate from dual)
5 and last_ddl_time >= (select sysdate - 5 from dual);
no rows selected
==>查看数据库实例状态
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
clonedb OPEN
==>重启clonedb 数据库,查看dbid,并且尝试网络连接
SQL> select dbid from v$database;
DBID
----------
934742089
==>截至此,数据库的迁移全部做完了
这篇关于ASM 10G 基于RMAN 迁移的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!