分类: Oracle
2010-04-17 21:25:52
itpub上朋友想知道,如何有单机转到RAC环境里。
手头没有单机环境,只有一个RAC环境,建库太麻烦了,直接导一个库从RAC环境里过来就是了。
下面就是这个过程。RAC环境的DB_name是inthrac,新产生的数据DB_NAME为single
首先建立pfile文件,根据这个pfile文件能够启动single的实例。pfile不要最简单的方法,是就是用create pfile from spfile=…
导一个过来,这里不多赘述了。
pfile的文件根据自己需要做如下修改
###########################################
# Archive
###########################################
log_archive_dest_1=’LOCATION=+DG1/single/’
###########################################
# Database Identification
###########################################
db_domain=”"
db_name=single###########################################
# Diagnostics and Statistics
###########################################
background_dump_dest=/u01/app/oracle/admin/single/bdump
core_dump_dest=/u01/app/oracle/admin/single/cdump
user_dump_dest=/u01/app/oracle/admin/single/udump
###########################################
# File Configuration
###########################################
db_create_file_dest=+DG1
###########################################
# Security and Auditing
###########################################
audit_file_dest=/u01/app/oracle/admin/single/adump
remote_login_passwordfile=exclusive
###########################################
# Control File
###########################################
control_files=(”+DG1/single/controlfile/current01.ctl”)
###########################################
# Convert Pattern
###########################################
db_file_name_convert=’+DG1/inthrac’,'+DG1/single’
log_file_name_convert=’+DG1/inthrac’,'+DG1/single’
建立single的admin的目录
[oracle@inthrac01 admin]$ cd $ORACLE_BASE/admin
[oracle@inthrac01 admin]$ mkdir single
[oracle@inthrac01 inthrac]$ cd ./single/
[oracle@inthrac01 single]$ mkdir adump bdump cdump dpdump hdump pfile udump
新的数据实例想还是使用asmcmd,创建指定的目录,如果没有安装asmlib的话,有所不同。
[oracle@inthrac01 oracle]$ asmcmd
ASMCMD> cd DG1
ASMCMD> mkdir SINGLE
ASMCMD> cd ../SINGLE
ASMCMD> mkdir ARCHIVELOG
ASMCMD> mkdir CONTROLFILE
ASMCMD> mkdir DATAFILE
ASMCMD> mkdir ONLINELOG
ASMCMD> mkdir PARAMETERFILE
ASMCMD> mkdir TEMPFILE
建立密码文件
[oracle@inthrac01 oracle]$ orapwd file=/u01/app/oracle/product/10.2.0/db_1/dbs/orapwsingle password=XXXXXX
建立今天监听,这个在我以前将监听的文章里专门有提到过
[oracle@inthrac01 oracle]$ vi /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
在监听里加上
(SID_DESC =
(GLOBAL_NAME = single)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(SID_NAME = single)
)
启动监听
[oracle@inthrac01 oracle]$ lsnrctl start LISTENER_INTHRAC01(这里和你自己的机器配置的listener名字一致)
用rman先对源库做个全备,这里可以参照rman的文档
我以前做过全备这里就用以前的全备,检查一下以前全备的备份集完全即可
RMAN> report need backup;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of files with less than 1 redundant backups
File #bkps Name
—- —– —————————————————–
RMAN> exit
备份很全,可以开始复制数据库了。
先启动目标库到nomount
[oracle@inthrac01 oracle]$ sqlplus sys/1qaz2wsx@single as sysdba
SQL> startup nomount;
ORACLE instance started.Total System Global Area 230686720 bytes
Fixed Size 2082944 bytes
Variable Size 83888000 bytes
Database Buffers 138412032 bytes
Redo Buffers 6303744 bytes
SQL> show parameter control;
下面开始duplicate数据库了
[oracle@inthrac01 oracle]$ rman target / auxiliary sys/1qaz2wsx@single
Recovery Manager: Release 10.2.0.4.0 - Production on Fri Mar 26 08:04:09 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: INTHRAC (DBID=1794719859)
connected to auxiliary database: SINGLE (not mounted)RMAN> duplicate target database to single;
Starting Duplicate Db at 26-MAR-10
…….
executing Memory Scriptdatabase opened
Finished Duplicate Db at 26-MAR-10
RMAN>
现在复制数据库已经成功
检查目标库
数据文件
SQL> select file_name, file_id from dba_data_files;
FILE_NAME FILE_ID
——————————————— ———-
+DG1/single/datafile/system.315.714643485 1
+DG1/single/datafile/undotbs1.310.714643497 2
+DG1/single/datafile/sysaux.314.714643489 3
+DG1/single/datafile/users.308.714643501 4
+DG1/single/datafile/undotbs2.312.714643491 5
+DG1/single/datafile/xpr91ts.1 66 rows selected.
日志文件
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
———- ——- ——- ——————————————— —
2 ONLINE +DG1/single/onlinelog/group_2.302.714643733 NO
1 ONLINE +DG1/single/onlinelog/group_1.303.714643731 NO
3 ONLINE +DG1/single/onlinelog/group_3.306.714643723 NO
4 ONLINE +DG1/single/onlinelog/group_4.304.714643727 NO
控制文件
SQL> select * from v$controlfile;
STATUS NAME IS_ BLOCK_SIZE FILE_SIZE_BLKS
——- ————————————————– — ———- ————–
+DG1/single/controlfile/current01.ctl NO 16384 952
现在复制成功,把你的spfile建到asm里吧
SQL> create spfile=’+DG1/single/spfilesingle’ from pfile=’/u01/app/oracle/product/10.2.0/db_1/dbs/initsingle.ora’;
File created.
修改你的/u01/app/oracle/product/10.2.0/db_1/dbs /initsingle.ora
将spfile定位到ASM的DG上
vi /u01/app/oracle/product/10.2.0/db_1/dbs/initsingle.ora
spfile=’+DG1/single/spfilesingle’
启动数据库
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
SQL> show parameter spfile;
NAME TYPE VALUE
———————————— ———– ——————————
spfile string +DG1/single/spfilesingle
[oracle@inthrac01 oracle]$ rman target /