11.2单机数据库转换为RAC-2-手工方式(与9i,10g,11.1的方法一样)

联系:QQ(5163721)

标题:11.2单机数据库转换为RAC-2-手工方式(与9i,10g,11.1的方法一样)

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

单机数据库转换为RAC,方法很多,前面的已经讲过使用rconfig的方法(11.2以后Oracle推荐的方法)。
但是我还是喜欢手工转换,感觉还是简单省事的,整个过程15分钟左右(主要是启动和关闭数据库的时间):
首先将单机数据库的pfile修改为RAC的pfile,具体如下:

*.audit_file_dest='/u01/app/oracle/admin/lunar/adump'
*.audit_trail='NONE'
*.compatible='11.2.0.3.0'
*.control_files='+DATADG/lunar/control01.ctl','+DATADG/lunar/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_files=2000
*.db_name='lunar'
lunar1.instance_number=1
lunar2.instance_number=2
*.db_recovery_file_dest='+RECODG'
*.db_recovery_file_dest_size=536870912000
*.db_unique_name='lunar'
*.deferred_segment_creation=FALSE
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=lunarXDB)'
*.log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=lunar'
*.log_archive_dest_state_1='ENABLE'
*.open_cursors=200
*.pga_aggregate_target=7059552256
lunar1.local_listener=LISTENER_RAC1
lunar2.local_listener=LISTENER_RAC2
*.processes=2400
*.remote_login_passwordfile='EXCLUSIVE'
*.resource_manager_plan=''
*.session_cached_cursors=200
*.sga_target=0
*.standby_file_management='AUTO'
lunar1.undo_tablespace='UNDOTBS1'
lunar2.undo_tablespace='UNDOTBS2'
*.undo_tablespace='UNDOTBS1'
*.db_cache_size=3g 
*.shared_pool_size=3g
*.streams_pool_size=128m
lunar1.instance_name=lunar1
lunar2.instance_name=lunar2
*.java_pool_size=200m
*.log_buffer=67108864
*.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'
lunar1.thread=1
lunar2.thread=2

然后使用这个pfile启动数据库:

08:26:59 @>startup pfile=/home/oracle/lunar/spfile.lunar.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 @>

然后添加thread 2的redo log group:

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 @>

创建thread 2使用的UNDO TABLESPACE:

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

Tablespace created.

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

然后enable这个thread 2:

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

Database altered.

Elapsed: 00:00:00.59
08:29:29 @>

最后,执行创建RAC的一些必要试图的脚本:
@?/rdbms/admin/catclust.sql
有些人说这个可以不执行,也有很多GV$的视图,但是实际上这个脚本是必须执行的,否则会缺少一部分GI需要视图
比如V$BH等等,具体可以查看catclust.sql脚本
都做完以后,就可以启动数据库了:

[oracle@dm01db02 ~]$ ss

SQL*Plus: Release 11.2.0.4.0 Production on Sun May 3 08:47:51 2015

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SYS@lunar2>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@lunar2>select * from v$active_instances;

     INST_NUMBER INST_NAME
---------------- ------------------------------------------------------------------------------------------------------------------------
               1 lunar1.lunar.com:lunar1
               2 lunar2.lunar.com:lunar2

Elapsed: 00:00:00.00
SYS@lunar2>

这里看到已经是RAC数据库了,RAC中最好使用spfile文件,因此我们也创建spfile,例如:

SYS@lunar2>show parameter spfile

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

然后把这数据库加入到CRS,就可以由CRS来管理了:

[oracle@dm01db01 ~]$ srvctl add database -d lunar -o /u01/app/oracle/product/11.2.0.4/dbhome_1
[oracle@dm01db01 ~]$ srvctl add instance -d lunar -n dm01db01 -i lunar1
[oracle@dm01db01 ~]$ srvctl add instance -d lunar -n dm01db02 -i lunar2
[oracle@dm01db01 ~]$ srvctl modify database -d lunar -n lunar
[oracle@dm01db01 ~]$ srvctl config database -d lunar
Database unique name: lunar
Database name: lunar
Oracle home: /u01/app/oracle/product/11.2.0.4/dbhome_1
Oracle user: oracle
Spfile: +DATADG/lunar/parameterfile/spfile.3296.878718931
Domain: 
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: lunar
Database instances: lunar1,lunar2
Disk Groups: DATADG,RECODG
Mount point paths: 
Services: 
Type: RAC
Database is administrator managed
[oracle@dm01db01 ~]$ 
此条目发表在 RAC 分类目录。将固定链接加入收藏夹。

发表评论

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