单实例数据库转换为RAC数据库–手工转换

联系:QQ(5163721)

标题:单实例数据库转换为RAC数据库–手工转换

作者:Lunar©版权所有[文章允许转载,但必须以链接方式注明源地址,否则追究法律责任.]

测试目的: 单实例数据库转换为RAC数据库
测试环境:Oracle 11.2.0.4
测试方法:手工转换

.
首先,安装一套RAC环境,并把单实例数据库通过通过rman还原到这个环境(通常如果是生产环境,我们会搭建从RAC到单实例数据库的ADG,以减少停机时间)。
然后生成一个源库(单实例数据库)spfile:

startup pfile=/home/oracle/lunar/spfile.lunardb.tmp
08:07:25 sys@lunardb>show parameter spfile
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string
08:08:38 sys@lunardb>

注意检查tnsnames.ora中用于local_listener参数的两个配置条目是否正确:

LISTENER_RAC1=(ADDRESS = (PROTOCOL = TCP)(HOST = dm0101-vip.lunar.com)(PORT = 1521))        
LISTENER_RAC2=(ADDRESS = (PROTOCOL = TCP)(HOST = dm0102-vip.lunar.com)(PORT = 1521))

修改刚才备份的pfile文件(/home/oracle/lunar/spfile.lunardb.tmp),添加RAC相关配置:

*.audit_file_dest='/u01/app/oracle/admin/lunardb/adump'
*.audit_trail='NONE'
*.compatible='11.2.0.3.0'
*.control_files='+DATADG/lunardb/control01.ctl','+DATADG/lunardb/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_files=2000
*.db_name='lunardb'
*.db_recovery_file_dest='+RECODG'
*.db_recovery_file_dest_size=336870912000
*.db_unique_name='lunardb'
*.deferred_segment_creation=FALSE
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=lunardbXDB)'
*.log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=lunardb'
*.log_archive_dest_state_1='ENABLE'
*.open_cursors=500
*.pga_aggregate_target=1059552256
*.processes=500
*.remote_login_passwordfile='EXCLUSIVE'
*.resource_manager_plan=''
*.session_cached_cursors=2000
*.sga_target=0
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'
#*.use_large_pages='ONLY'
*.db_cache_size=3g 
*.shared_pool_size=3g
*.streams_pool_size=28m
*.java_pool_size=200m
*.log_buffer=37108864
*.job_queue_processes=20
*.cluster_database=true
*.cluster_database_instances=2
*.undo_management=AUTO
*.db_create_file_dest='+DATADG'
*.db_create_online_log_dest_1='+RECODG'
lunardb1.undo_tablespace='UNDOTBS1'
lunardb2.undo_tablespace='UNDOTBS2'
lunardb1.instance_number=1
lunardb2.instance_number=2
lunardb1.instance_name=lunardb1
lunardb2.instance_name=lunardb2
lunardb1.thread=1
lunardb2.thread=2
lunardb1.local_listener=LISTENER_RAC1
lunardb2.local_listener=LISTENER_RAC2

使用这个pfile启动数据库:

08:26:59 @>startup pfile=/home/oracle/lunar/spfile.lunardb.tmp
ORACLE instance started.

Total System Global Area       6881869824 bytes
Fixed Size                        2266064 bytes
Variable Size                  3573550128 bytes
Database Buffers               3221225472 bytes
Redo Buffers                     84828160 bytes
Database mounted.
Database opened.
08:27:30 @>

添加thread2:

08:27:30 @>alter database add logfile thread 2
08:28:16   2    group 17  ('+RECODG') size 1024m,
08:28:16   3    group 18  ('+RECODG') size 1024m,
08:28:16   4    group 19  ('+RECODG') size 1024m,
        group 20  ('+RECODG') size 1024m,
08:28:16   5  08:28:16   6      group 21  ('+RECODG') size 1024m,
08:28:16   7    group 22  ('+RECODG') size 1024m,
        group 23  ('+RECODG') size 1024m,
08:28:16   8  08:28:16   9      group 24  ('+RECODG') size 1024m,
        group 25  ('+RECODG') size 1024m,
08:28:16  10  08:28:16  11      group 26  ('+RECODG') size 1024m,
08:28:16  12    group 27  ('+RECODG') size 1024m,
        group 28  ('+RECODG') size 1024m,
08:28:16  13  08:28:16  14      group 29  ('+RECODG') size 1024m,
08:28:16  15    group 30  ('+RECODG') size 1024m,
08:28:16  16    group 31  ('+RECODG') size 1024m,
08:28:16  17    group 32  ('+RECODG') size 1024m
;08:28:16  18  

Database altered.

Elapsed: 00:00:28.51
08:28:46 @>

添加实例2的undo表空间:

08:28:46 @>CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE '+DATADG' SIZE 10480m ;        

Tablespace created.

Elapsed: 00:00:09.87
08:29:11 @>

启用实例2(thread2):

08:29:11 @>alter database enable public thread 2; 

Database altered.

Elapsed: 00:00:00.59
08:29:29 @>
1
创建spfile:

08:33:58 @>create spfile='+DATADG' from pfile='/home/oracle/lunar/spfile.lunardb.tmp';

File created.

Elapsed: 00:00:00.21
08:35:30 @>

使用grid用户查看:

ASMCMD> ls
spfile.3296.878718931
ASMCMD> pwd
+datadg/lunardb/PARAMETERFILE
ASMCMD> 

修改initlunardb1.ora 文件:

[oracle@dm01db01 dbs]$ cat initlunardb1.ora 
SPFILE='+datadg/lunardb/PARAMETERFILE/spfile.3296.878718931'
[oracle@dm01db01 dbs]$ 

检查数据库:

08:42:07 sys@lunardb>show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATADG/lunardb/parameterfile/spf
                                                 ile.3296.878718931
08:42:11 sys@lunardb>show parameter cluster

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
cluster_database                     boolean     TRUE
cluster_database_instances           integer     2
cluster_interconnects                string
08:42:14 sys@lunardb>

执行@?/rdbms/admin/catclust.sql,这个过程按照文档即可,没啥说的,执行完了检查日志,看看是否有报错。
然后启动数据库,检查2个数据库实例是否都正常了

SYS@lunardb2>startup
ORACLE instance started.

Total System Global Area       6881869824 bytes
Fixed Size                        2266064 bytes
Variable Size                  3573550128 bytes
Database Buffers               3221225472 bytes
Redo Buffers                     84828160 bytes
Database mounted.
Database opened.
SYS@lunardb2>select * from v$active_instances;

     INST_NUMBER INST_NAME
---------------- ------------------------------------------------------------------------------------------------------------------------
               1 dm01db01.lunar.com:lunardb1
               2 dm01db02.lunar.com:lunardb2

Elapsed: 00:00:00.00
SYS@lunardb2>
SYS@lunardb2>show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATADG/lunardb/parameterfile/spf
                                                 ile.3296.878718931
SYS@lunardb2>

把数据库实例添加到CRS中:

[oracle@dm01db01 ~]$ srvctl config database -d lunardb
PRCD-1120 : The resource for database lunardb could not be found.
PRCR-1001 : Resource ora.lunardb.db does not exist
[oracle@dm01db01 ~]$ 
[oracle@dm01db01 ~]$ srvctl add database -d lunardb -o /u01/app/oracle/product/11.2.0.4/dbhome_1
[oracle@dm01db01 ~]$ srvctl add instance -d lunardb -n dm01db01 -i lunardb1
[oracle@dm01db01 ~]$ srvctl add instance -d lunardb -n dm01db02 -i lunardb2
[oracle@dm01db01 ~]$ srvctl config database -d lunardb
Database unique name: lunardb
Database name: 
Oracle home: /u01/app/oracle/product/11.2.0.4/dbhome_1
Oracle user: oracle
Spfile: 
Domain: 
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: lunardb
Database instances: lunardb1,lunardb2
Disk Groups: 
Mount point paths: 
Services: 
Type: RAC
Database is administrator managed
[oracle@dm01db01 ~]$ 
[oracle@dm01db01 ~]$ srvctl modify database -d lunardb -a DATADG,RECODG
[oracle@dm01db01 ~]$ srvctl modify database -d lunardb -p '+DATADG/lunardb/parameterfile/spfile.3296.878718931'
[oracle@dm01db01 ~]$ srvctl config database -d lunardb
Database unique name: lunardb
Database name: 
Oracle home: /u01/app/oracle/product/11.2.0.4/dbhome_1
Oracle user: oracle
Spfile: +DATADG/lunardb/parameterfile/spfile.3296.878718931
Domain: 
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: lunardb
Database instances: lunardb1,lunardb2
Disk Groups: DATADG,RECODG
Mount point paths: 
Services: 
Type: RAC
Database is administrator managed
[oracle@dm01db01 ~]$ 
此条目发表在 Database, RAC 分类目录,贴了 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注