BLOG文档结构图
之前的相关文章连接:
DBCA静默方式建库 :http://blog.itpub.net/26736162/viewspace-1448220/
【DBCA -SILENT】静默安装如何启用归档模式: http://blog.itpub.net/26736162/viewspace-1585925/
之前的文章中介绍了单实例的数据库静默安装方式,今天我们来看看rac数据库的静默安装方式。
查看集群环境是否准备好:
[root@node2 ~]# crsctl check cluster -all
**************************************************************
node1:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************
node2:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************
[root@node2 ~]#
查看磁盘组空间:
SQL> select name,state,free_mb,required_mirror_free_mb,usable_file_mb,a.group_number from v$asm_diskgroup a;
NAME STATE FREE_MB REQUIRED_MIRROR_FREE_MB USABLE_FILE_MB GROUP_NUMBER
------------------------------ ----------- ---------- ----------------------- -------------- ------------
ARCH MOUNTED 9142 0 9142 1
DATA MOUNTED 18242 0 18242 2
OVDISK MOUNTED 2703 0 2703 3
TEST MOUNTED 929 0 929 4
查看节点列表:
[root@node2 ~]# olsnodes
node1
node2
[root@node2 ~]#
修改General_Purpose.dbc 文件,让生成的rac库在归档模式:
[oracle@node1 dbca]$ strings $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc | grep -i arch
true</archiveLogMode>
[oracle@node1 dbca]$
确保以上集群环境已经搭建好后,开始创建rac数据库,当然有2种方式可以搭建,个人觉得2种方式都挺方便的,下边我们分别介绍:
一、 方法一:利用模板文件来创建
sid:jmrac
文件磁盘组:data
闪回恢复区:arch
节点:node1,node2
[oracle@node1 dbca]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname jmrac -sid jmrac -sysPassword lhr -systemPassword lhr -datafileDestination 'DATA/' -redoLogFileSize 50 -recoveryAreaDestination 'ARCH/' -storageType ASM -asmsnmpPassword lhr -diskGroupName 'DATA' -responseFile NO_VALUE -characterset ZHS16GBK -nationalCharacterSet AL16UTF16 -sampleSchema true -automaticMemoryManagement true -totalMemory 500 -nodeinfo node1,node2
Copying database files
1% complete
3% complete
9% complete
15% complete
21% complete
27% complete
30% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
44% complete
45% complete
48% complete
50% complete
Creating cluster database views
52% complete
70% complete
Completing Database Creation
73% complete
76% complete
85% complete
94% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/jmrac/jmrac.log" for further details.
[oracle@node1 jmrac]$ more /u01/app/oracle/cfgtoollogs/dbca/jmrac/jmrac.log
Copying database files
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
DBCA_PROGRESS : 9%
DBCA_PROGRESS : 15%
DBCA_PROGRESS : 21%
DBCA_PROGRESS : 27%
DBCA_PROGRESS : 30%
Creating and starting Oracle instance
DBCA_PROGRESS : 32%
DBCA_PROGRESS : 36%
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 44%
DBCA_PROGRESS : 45%
DBCA_PROGRESS : 48%
DBCA_PROGRESS : 50%
Creating cluster database views
DBCA_PROGRESS : 52%
DBCA_PROGRESS : 70%
Completing Database Creation
DBCA_PROGRESS : 73%
DBCA_PROGRESS : 76%
DBCA_PROGRESS : 85%
DBCA_PROGRESS : 94%
DBCA_PROGRESS : 100%
Database creation complete. For details check the logfiles at:
/u01/app/oracle/cfgtoollogs/dbca/jmrac.
Database Information:
Global Database Name:jmrac
System Identifier(SID) Prefix:jmrac
[oracle@node1 jmrac]$
[oracle@node1 jmrac]$ ORACLE_SID=jmrac1
[oracle@node1 jmrac]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sun Apr 19 22:00:18 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 4
Next log sequence to archive 5
Current log sequence 5
SQL>
SQL> set line 9999
SQL> col HOST_NAME format a10
SQL> select INSTANCE_NAME,HOST_NAME,VERSION,STARTUP_TIME,STATUS,ACTIVE_STATE,INSTANCE_ROLE,DATABASE_STATUS from gv$INSTANCE;
INSTANCE_NAME HOST_NAME VERSION STARTUP_T STATUS ACTIVE_ST INSTANCE_ROLE DATABASE_STATUS
---------------- ---------- ----------------- --------- ------------ --------- ------------------ -----------------
jmrac1 node1 11.2.0.1.0 19-APR-15 OPEN NORMAL PRIMARY_INSTANCE ACTIVE
jmrac2 node2 11.2.0.1.0 19-APR-15 OPEN NORMAL PRIMARY_INSTANCE ACTIVE
SQL> select INST_ID,name , open_mode, log_mode,force_logging from gv$database;
INST_ID NAME OPEN_MODE LOG_MODE FOR
---------- --------- -------------------- ------------ ---
1 JMRAC READ WRITE ARCHIVELOG NO
2 JMRAC READ WRITE ARCHIVELOG NO
SQL> show parameter DB_RECOVERY_FILE_DEST
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string +ARCH
db_recovery_file_dest_size big integer 3882M
SQL>
---查看tns和listener信息
[oracle@node1 dbca]$ cd /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/
[oracle@node1 admin]$ ll
total 12
drwxr-xr-x 2 oracle oinstall 4096 Feb 27 2012 samples
-rw-r--r-- 1 oracle oinstall 187 May 7 2007 shrept.lst
-rw-r----- 1 oracle oinstall 685 Apr 19 22:13 tnsnames.ora
[oracle@node1 admin]$ more tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
JMRAC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = cluster-SCAN)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jmrac)
)
)
[oracle@node1 dbca]$ srvctl status listener
Listener LISTENER is enabled
Listener LISTENER is running on node(s): node1,node2
[oracle@node1 dbca]$
说明tns已经自动添加,监听也已经启动
查看rac服务:
[root@node2 ~]# crsctl status resource -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCH.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.DATA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.LISTENER.lsnr
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.OVDISK.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.TEST.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.asm
ONLINE ONLINE node1 Started
ONLINE ONLINE node2 Started
ora.eons
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.gsd
OFFLINE OFFLINE node1
OFFLINE OFFLINE node2
ora.net1.network
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.ons
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.registry.acfs
ONLINE ONLINE node1
ONLINE ONLINE node2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE node1
ora.db.db
1 OFFLINE OFFLINE Instance Shutdown
2 OFFLINE OFFLINE Instance Shutdown
ora.jmrac.db
1 ONLINE ONLINE node1 Open
2 ONLINE ONLINE node2 Open
ora.node1.vip
1 ONLINE ONLINE node1
ora.node2.vip
1 ONLINE ONLINE node2
ora.oc4j
1 OFFLINE OFFLINE
ora.scan1.vip
1 ONLINE ONLINE node1
[root@node2 ~]# crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.ARCH.dg ora....up.type ONLINE ONLINE node1
ora.DATA.dg ora....up.type ONLINE ONLINE node1
ora....ER.lsnr ora....er.type ONLINE ONLINE node1
ora....N1.lsnr ora....er.type ONLINE ONLINE node1
ora.OVDISK.dg ora....up.type ONLINE ONLINE node1
ora.TEST.dg ora....up.type ONLINE ONLINE node1
ora.asm ora.asm.type ONLINE ONLINE node1
ora.db.db ora....se.type OFFLINE OFFLINE
ora.eons ora.eons.type ONLINE ONLINE node1
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora.jmrac.db ora....se.type ONLINE ONLINE node1
ora....network ora....rk.type ONLINE ONLINE node1
ora....SM1.asm application ONLINE ONLINE node1
ora....E1.lsnr application ONLINE ONLINE node1
ora.node1.gsd application OFFLINE OFFLINE
ora.node1.ons application ONLINE ONLINE node1
ora.node1.vip ora....t1.type ONLINE ONLINE node1
ora....SM2.asm application ONLINE ONLINE node2
ora....E2.lsnr application ONLINE ONLINE node2
ora.node2.gsd application OFFLINE OFFLINE
ora.node2.ons application ONLINE ONLINE node2
ora.node2.vip ora....t1.type ONLINE ONLINE node2
ora.oc4j ora.oc4j.type OFFLINE OFFLINE
ora.ons ora.ons.type ONLINE ONLINE node1
ora....ry.acfs ora....fs.type ONLINE ONLINE node1
ora.scan1.vip ora....ip.type ONLINE ONLINE node1
[root@node2 ~]# srvctl status database -d jmrac
Instance jmrac1 is running on node node1
Instance jmrac2 is running on node node2
[root@node2 ~]# srvctl config database -d jmrac
Database unique name: jmrac
Database name: jmrac
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +DATA/jmrac/spfilejmrac.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: jmrac
Database instances: jmrac1,jmrac2
Disk Groups: DATA
Services:
Database is administrator managed
[root@node2 ~]#
二、 方法二:编辑响应文件
添加文件$ORACLE_HOME/assistants/dbca/dbca_rac.rsp,内容如下:
[oracle@node1 dbca]$ more $ORACLE_HOME/assistants/dbca/dbca_rac.rsp
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "myrac"
SID = "myrac"
NODELIST=node1,node2
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "lhr"
SYSTEMPASSWORD = "lhr"
SYSMANPASSWORD = "lhr"
DBSNMPPASSWORD = "lhr"
STORAGETYPE=ASM
DISKGROUPNAME=DATA
ASMSNMP_PASSWORD="lhr"
RECOVERYGROUPNAME=ARCH
CHARACTERSET = "ZHS16GBK"
NATIONALCHARACTERSET= "UTF8"
利用响应文件来创建rac库:
[oracle@node1 dbca]$ dbca -silent -responseFile $ORACLE_HOME/assistants/dbca/dbca_rac.rsp
Copying database files
1% complete
3% complete
9% complete
15% complete
21% complete
27% complete
30% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
44% complete
45% complete
48% complete
50% complete
Creating cluster database views
52% complete
70% complete
Completing Database Creation
73% complete
76% complete
85% complete
94% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/myrac/myrac.log" for further details.
[oracle@node1 dbca]$ more /u01/app/oracle/cfgtoollogs/dbca/myrac/myrac.log
Copying database files
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
DBCA_PROGRESS : 9%
DBCA_PROGRESS : 15%
DBCA_PROGRESS : 21%
DBCA_PROGRESS : 27%
DBCA_PROGRESS : 30%
Creating and starting Oracle instance
DBCA_PROGRESS : 32%
DBCA_PROGRESS : 36%
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 44%
DBCA_PROGRESS : 45%
DBCA_PROGRESS : 48%
DBCA_PROGRESS : 50%
Creating cluster database views
DBCA_PROGRESS : 52%
DBCA_PROGRESS : 70%
Completing Database Creation
DBCA_PROGRESS : 73%
DBCA_PROGRESS : 76%
DBCA_PROGRESS : 85%
DBCA_PROGRESS : 94%
DBCA_PROGRESS : 100%
Database creation complete. For details check the logfiles at:
/u01/app/oracle/cfgtoollogs/dbca/myrac.
Database Information:
Global Database Name:myrac
System Identifier(SID) Prefix:myrac
[oracle@node1 dbca]$ ORACLE_SID=myrac1
[oracle@node1 admin]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sun Apr 19 22:37:08 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> set line 9999
SQL> col HOST_NAME format a10
SQL> select INSTANCE_NAME,HOST_NAME,VERSION,STARTUP_TIME,STATUS,ACTIVE_STATE,INSTANCE_ROLE,DATABASE_STATUS from gv$INSTANCE;
INSTANCE_NAME HOST_NAME VERSION STARTUP_T STATUS ACTIVE_ST INSTANCE_ROLE DATABASE_STATUS
---------------- ---------- ----------------- --------- ------------ --------- ------------------ -----------------
myrac1 node1 11.2.0.1.0 19-APR-15 OPEN NORMAL PRIMARY_INSTANCE ACTIVE
myrac2 node2 11.2.0.1.0 19-APR-15 OPEN NORMAL PRIMARY_INSTANCE ACTIVE
SQL> select INST_ID,name , open_mode, log_mode,force_logging from gv$database;
INST_ID NAME OPEN_MODE LOG_MODE FOR
---------- --------- -------------------- ------------ ---
1 MYRAC READ WRITE ARCHIVELOG NO
2 MYRAC READ WRITE ARCHIVELOG NO
SQL>
三、 删除新建的rac库
[oracle@node1 dbca]$ dbca -silent -deleteDatabase -sourceDB myrac -sysDBAUserName sys -sysDBAPassword lhr
Connecting to database
9% complete
14% complete
19% complete
23% complete
28% complete
33% complete
38% complete
47% complete
Updating network configuration files
48% complete
52% complete
Deleting instances and datafiles
66% complete
80% complete
95% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/myrac.log" for further details.
[oracle@node1 dbca]$