文章详述安装一套RAC环境,并把单实例数据库通过通过rman还原到这个环境(通常如果是生产环境,我们会搭建从RAC到单实例数据库的ADG,以减少停机时间)。
单实例数据库转换为RAC数据库,Oracle 11.2.0.4
首先,安装一套RAC环境,并把单实例数据库通过通过rman还原到这个环境(通常如果是生产环境,我们会搭建从RAC到单实例数据库的ADG,以减少停机时间)。 然后生成一个源库(单实例数据库)spfile:
startup pfile=/home/oracle/orcld/spfile.orclddb.tmp
08:07:25 sys@orclddb>show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile
注意检查tnsnames.ora中用于local_listener参数的两个配置条目是否正确:
LISTENER_RAC1=(ADDRESS = (PROTOCOL = TCP)(HOST = dm0101-vip.orcld.com)(PORT = 1521))
LISTENER_RAC2=(ADDRESS = (PROTOCOL = TCP)(HOST = dm0102-vip.orcld.com)(PORT = 1521))
修改刚才备份的pfile文件(/home/oracle/orcld/spfile.orclddb.tmp),添加RAC相关配置:
*.audit_file_dest='/u01/app/oracle/admin/orclddb/adump'
*.audit_trail='NONE'
*.compatible='11.2.0.3.0'
*.control_files='+DATADG/orclddb/control01.ctl','+DATADG/orclddb/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_files=2000
*.db_name='orclddb'
*.db_recovery_file_dest='+RECODG'
*.db_recovery_file_dest_size=336870912000
*.db_unique_name='orclddb'
*.deferred_segment_creation=FALSE
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclddbXDB)'
*.log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orclddb'
*.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'
orclddb1.undo_tablespace='UNDOTBS1'
orclddb2.undo_tablespace='UNDOTBS2'
orclddb1.instance_number=1
orclddb2.instance_number=2
orclddb1.instance_name=orclddb1
orclddb2.instance_name=orclddb2
orclddb1.thread=1
orclddb2.thread=2
orclddb1.local_listener=LISTENER_RAC1
orclddb2.local_listener=LISTENER_RAC2
使用这个pfile启动数据库:
08:26:59 @>startup pfile=/home/oracle/orcld/spfile.orclddb.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.
添加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
添加实例2的undo表空间:
08:28:46 @>CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE '+DATADG' SIZE 10480m ;
Tablespace created.
Elapsed: 00:00:09.87
启用实例2(thread2):
08:29:11 @>alter database enable public thread 2;
Database altered.
Elapsed: 00:00:00.59
创建spfile:
create spfile='+DATADG' from pfile='/home/oracle/orcld/spfile.orclddb.tmp';
File created.
Elapsed: 00:00:00.21
使用grid用户查看:
ASMCMD> ls
spfile.3296.878718931
ASMCMD> pwd
+datadg/orclddb/PARAMETERFILE
ASMCMD>
修改initorclddb1.ora 文件:
[oracle@dm01db01 dbs]$ cat initorclddb1.ora
SPFILE='+datadg/orclddb/PARAMETERFILE/spfile.3296.878718931'
[oracle@dm01db01 dbs]$
检查数据库:
sys@orclddb>show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +DATADG/orclddb/parameterfile/spf
ile.3296.878718931
08:42:11 sys@orclddb>show parameter cluster
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cluster_database boolean TRUE
cluster_database_instances integer 2
cluster_interconnects string
08:42:14 sys@orclddb>
执行@?/rdbms/admin/catclust.sql,这个过程按照文档即可,没啥说的,执行完了检查日志,看看是否有报错。
然后启动数据库,检查2个数据库实例是否都正常了
SYS@orclddb2>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@orclddb2>select * from v$active_instances;
INST_NUMBER INST_NAME
---------------- ------------------------------------------------------------------------------------------------------------------------
1 dm01db01.orcld.com:orclddb1
2 dm01db02.orcld.com:orclddb2
Elapsed: 00:00:00.00
SYS@orclddb2>
SYS@orclddb2>show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +DATADG/orclddb/parameterfile/spf
ile.3296.878718931
SYS@orclddb2>
把数据库实例添加到CRS中:
[oracle@dm01db01 ~]$ srvctl config database -d orclddb
PRCD-1120 : The resource for database orclddb could not be found.
PRCR-1001 : Resource ora.orclddb.db does not exist
[oracle@dm01db01 ~]$
[oracle@dm01db01 ~]$ srvctl add database -d orclddb -o /u01/app/oracle/product/11.2.0.4/dbhome_1
[oracle@dm01db01 ~]$ srvctl add instance -d orclddb -n dm01db01 -i orclddb1
[oracle@dm01db01 ~]$ srvctl add instance -d orclddb -n dm01db02 -i orclddb2
[oracle@dm01db01 ~]$ srvctl config database -d orclddb
Database unique name: orclddb
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: orclddb
Database instances: orclddb1,orclddb2
Disk Groups:
Mount point paths:
Services:
Type: RAC
Database is administrator managed
[oracle@dm01db01 ~]$
[oracle@dm01db01 ~]$ srvctl modify database -d orclddb -a DATADG,RECODG
[oracle@dm01db01 ~]$ srvctl modify database -d orclddb -p '+DATADG/orclddb/parameterfile/spfile.3296.878718931'
[oracle@dm01db01 ~]$ srvctl config database -d orclddb
Database unique name: orclddb
Database name:
Oracle home: /u01/app/oracle/product/11.2.0.4/dbhome_1
Oracle user: oracle
Spfile: +DATADG/orclddb/parameterfile/spfile.3296.878718931
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: orclddb
Database instances: orclddb1,orclddb2
Disk Groups: DATADG,RECODG
Mount point paths:
Services:
Type: RAC
Database is administrator managed
[oracle@dm01db01 ~]$
Copyright© 2013-2020
All Rights Reserved 京ICP备2023019179号-8