1、(ORACLE)查看集群中的数据库运行状态,最后接着是RAC名,不是实例的名称。
srvctlstatus database -d tax
oracle@svrtrpc001:~>srvctl status database -d tax
Instancetax1 is running on node svrtrpc001
Instancetax2 is running on node svrtrpc002
Instancetax3 is running on node svrtrpc003
-----------------------------------------------------
(ORACLE)查看数据库的运行状态,最后接着是RAC名,不是实例的名称。
srvctlstatus database -d tax -v
oracle@svrtrpc001:~>srvctl status database -d tax -v
Instancetax1 is running on node svrtrpc001. Instance status: Open.
Instance tax2is running on node svrtrpc002. Instance status: Open.
Instancetax3 is running on node svrtrpc003. Instance status: Open.
-----------------------------------------
(ORACLE)查看实例运行状态,最后接着节点名
srvctlstatus instance -d tax -i tax1
oracle@svrtrpc001:~>srvctl status instance -d tax -i tax1
Instancetax1 is running on node svrtrpc001
---------------------------------------------------
(ORACLE)查看集群的配置情况
srvctlconfig -p tax -n tax
oracle@svrtrpc001:~>srvctl config -p tax -n tax
Databaseunique name: tax
Databasename: tax
Oraclehome: /u01/app/oracle/product/11.2.0
Oracleuser: oracle
Spfile:+DATADG/tax/spfiletax.ora
Domain:
Startoptions: open
Stopoptions: immediate
Databaserole: PRIMARY
Managementpolicy: AUTOMATIC
Serverpools: tax
Database instances:tax1,tax2,tax3
DiskGroups: DATADG
Mountpoint paths:
Services:
Type: RAC
Databaseis administrator managed
-----------------------------------------------
2、启动:srvctl start
I thinkmaybe it's one of the most frequently used commands as well as 'srvctl stop'.
Availableoptions: database|instance|service|nodeapps|asm
# Startdatabase
srvctlstart database -d orcl -o nomount
srvctlstart database -d orcl -o mount
srvctlstart database -d orcl -o open
# Grammarfor start instance
srvctl start instance -d [db_name] -i [instance_name]
-o[start_option] -c [connect_str] -q
# Startall instances on the all nodes
srvctlstart instance -d orcl -i orcl1,orcl2,...
# StartASM instance
srvctlstart ASM -n [node_name] -i asm1 -o open
# Startall apps in one node
srvctlstart nodeapps -n [node_name]
# New:srvctl can manage listener's startup in DB 10.2
srvctlstart listener -n <node_name>
-------------------------------------------------
3、关闭:srvctl stop
I thinkmaybe it's also one of the most frequently used
commandsas well as 'srvctl start'.
Availableoptions: database|instance|service|nodeapps|asm
# Stopdatabase
srvctlstop database -d orcl -o normal
srvctlstop database -d orcl -o immediate
srvctlstop database -d orcl -o abort
# Grammarfor start instance
srvctlstop instance -d [db_name] -i [instance_name]
-o[start_option] -c
--------------------------
4、检查集群状态:
[grid@rac02~]$ crsctl check cluster
CRS-4537:Cluster Ready Services is online
CRS-4529:Cluster Synchronization Services is online
CRS-4533:Event Manager is online
4.1、所有 Oracle 实例 —(数据库状态):
[grid@rac02~]$ srvctl status database -d racdb
Instanceracdb1 is running on node rac01
Instanceracdb2 is running on node rac02
4.2、检查单个实例状态:
[grid@rac02~]$ srvctl status instance -d racdb -i racdb1
Instanceracdb1 is running on node rac01
4.3、节点应用程序状态:
[grid@rac02~]$ srvctl status nodeapps
VIPrac01-vip is enabled
VIPrac01-vip is running on node: rac01
VIPrac02-vip is enabled
VIPrac02-vip is running on node: rac02
Network isenabled
Networkis running on node: rac01
Networkis running on node: rac02
GSD isdisabled
GSD isnot running on node: rac01
GSD isnot running on node: rac02
ONS isenabled
ONSdaemon is running on node: rac01
ONSdaemon is running on node: rac02
eONS isenabled
eONSdaemon is running on node: rac01
eONSdaemon is running on node: rac02
4.4、列出所有的配置数据库:
[grid@rac02~]$ srvctl config database
racdb
4.5、数据库配置:
[grid@rac02~]$ srvctl config database -d racdb -a
Databaseunique name: racdb
Databasename: racdb
Oraclehome: /u01/app/oracle/product/11.2.0/dbhome_1
Oracleuser: oracle
Spfile:+RACDB_DATA/racdb/spfileracdb.ora
Domain:xzxj.edu.cn
Startoptions: open
Stopoptions: immediate
Databaserole: PRIMARY
Managementpolicy: AUTOMATIC
Serverpools: racdb
Databaseinstances: racdb1,racdb2
DiskGroups: RACDB_DATA,FRA
Services:
Databaseis enabled
Databaseis administrator managed
4.6、ASM状态以及ASM配置:
[grid@rac02~]$ srvctl status asm
ASM isrunning on rac01,rac02
[grid@rac02~]$ srvctl config asm -a
ASM home:/u01/app/11.2.0/grid
ASMlistener: LISTENER
ASM isenabled.
8、TNS监听器状态以及配置:
[grid@rac02~]$ srvctl status listener
ListenerLISTENER is enabled
ListenerLISTENER is running on node(s): rac01,rac02
[grid@rac02~]$ srvctl config listener -a
Name:LISTENER
Network:1, Owner: grid
Home:<CRS home>
/u01/app/11.2.0/grid on node(s) rac02,rac01
Endpoints: TCP:1521
4.7、SCAN状态以及配置:
[grid@rac02~]$ srvctl status scan
SCAN VIPscan1 is enabled
SCAN VIPscan1 is running on node rac02
[grid@rac02~]$ srvctl config scan
SCANname: rac-scan.xzxj.edu.cn, Network: 1/192.168.1.0/255.255.255.0/eth0
SCAN VIPname: scan1, IP: /rac-scan.xzxj.edu.cn/192.168.1.55
4.8、VIP各个节点的状态以及配置:
[grid@rac02~]$ srvctl status vip -n rac01
VIPrac01-vip is enabled
VIPrac01-vip is running on node: rac01
[grid@rac02~]$ srvctl status vip -n rac02
VIPrac02-vip is enabled
VIPrac02-vip is running on node: rac02
[grid@rac02~]$ srvctl config vip -n rac01
VIPexists.:rac01
VIPexists.: /rac01-vip/192.168.1.53/255.255.255.0/eth0
[grid@rac02~]$ srvctl config vip -n rac02
VIPexists.:rac02
VIPexists.: /rac02-vip/192.168.1.54/255.255.255.0/eth0
4.9、节点应用程序配置 —(VIP、GSD、ONS、监听器)
[grid@rac02~]$ srvctl config nodeapps -a -g -s -l
-l optionhas been deprecated and will be ignored.
VIPexists.:rac01
VIPexists.: /rac01-vip/192.168.1.53/255.255.255.0/eth0
VIPexists.:rac02
VIPexists.: /rac02-vip/192.168.1.54/255.255.255.0/eth0
GSDexists.
ONSdaemon exists. Local port 6100, remote port 6200
Name:LISTENER
Network:1, Owner: grid
Home:<CRS home>
/u01/app/11.2.0/grid on node(s) rac02,rac01
Endpoints: TCP:1521
4.10、验证所有集群节点间的时钟同步:
[grid@rac02~]$ cluvfy comp clocksync -verbose
VerifyingClock Synchronization across the cluster nodes
Checkingif Clusterware is installed on all nodes...
Check ofClusterware install passed
Checkingif CTSS Resource is running on all nodes...
Check:CTSS Resource running on all nodes
Node Name Status
------------------------------------ ------------------------
rac02 passed
Result:CTSS resource check passed
QueryingCTSS for time offset on all nodes...
Result:Query of CTSS for time offset passed
CheckCTSS state started...
Check:CTSS state
Node Name State
------------------------------------ ------------------------
rac02 Active
CTSS isin Active state. Proceeding with check of clock time offsets on all nodes...
ReferenceTime Offset Limit: 1000.0 msecs
Check:Reference Time Offset
Node Name Time Offset Status
------------ ------------------------ ------------------------
rac02 0.0 passed
Timeoffset is within the specified limits on the following set of nodes:
"[rac02]"
Result:Check of clock time offsets passed
OracleCluster Time Synchronization Services check passed
Verificationof Clock Synchronization across the cluster nodes was successful.
4.11、集群中所有正在运行的实例 — (SQL):
SELECTinst_id , instance_number inst_no , instance_name inst_name , parallel , status, database_status db_status , active_state state , host_name host FROMgv$instance ORDER BY inst_id;
4.12、所有数据库文件及它们所在的 ASM 磁盘组— (SQL):
16、启动和停止集群:
以下操作需用root用户执行。
(1)、在本地服务器上停止OracleClusterware 系统:
[root@rac01~]# /u01/app/11.2.0/grid/bin/crsctl stop cluster
CRS-2673:Attempting to stop 'ora.crsd' on 'rac01'
CRS-2790:Starting shutdown of Cluster Ready Services-managed resources on 'rac01'
CRS-2673:Attempting to stop 'ora.LISTENER.lsnr' on 'rac01'
CRS-2673:Attempting to stop 'ora.CRS.dg' on 'rac01'
CRS-2673:Attempting to stop 'ora.racdb.db' on 'rac01'
CRS-2673:Attempting to stop 'ora.registry.acfs' on 'rac01'
CRS-2677:Stop of 'ora.LISTENER.lsnr' on 'rac01' succeeded
CRS-2673:Attempting to stop 'ora.rac01.vip' on 'rac01'
CRS-2677:Stop of 'ora.rac01.vip' on 'rac01' succeeded
CRS-2672:Attempting to start 'ora.rac01.vip' on 'rac02'
CRS-2677:Stop of 'ora.registry.acfs' on 'rac01' succeeded
CRS-2676:Start of 'ora.rac01.vip' on 'rac02' succeeded
CRS-2677:Stop of 'ora.CRS.dg' on 'rac01' succeeded
CRS-2677:Stop of 'ora.racdb.db' on 'rac01' succeeded
CRS-2673:Attempting to stop 'ora.FRA.dg' on 'rac01'
CRS-2673:Attempting to stop 'ora.RACDB_DATA.dg' on 'rac01'
CRS-2677:Stop of 'ora.FRA.dg' on 'rac01' succeeded
CRS-2677:Stop of 'ora.RACDB_DATA.dg' on 'rac01' succeeded
CRS-2673:Attempting to stop 'ora.asm' on 'rac01'
CRS-2677:Stop of 'ora.asm' on 'rac01' succeeded
CRS-2673:Attempting to stop 'ora.ons' on 'rac01'
CRS-2673:Attempting to stop 'ora.eons' on 'rac01'
CRS-2677:Stop of 'ora.ons' on 'rac01' succeeded
CRS-2673:Attempting to stop 'ora.net1.network' on 'rac01'
CRS-2677:Stop of 'ora.net1.network' on 'rac01' succeeded
CRS-2677:Stop of 'ora.eons' on 'rac01' succeeded
CRS-2792:Shutdown of Cluster Ready Services-managed resources on 'rac01' has completed
CRS-2677:Stop of 'ora.crsd' on 'rac01' succeeded
CRS-2673:Attempting to stop 'ora.cssdmonitor' on 'rac01'
CRS-2673:Attempting to stop 'ora.ctssd' on 'rac01'
CRS-2673:Attempting to stop 'ora.evmd' on 'rac01'
CRS-2673:Attempting to stop 'ora.asm' on 'rac01'
CRS-2677:Stop of 'ora.cssdmonitor' on 'rac01' succeeded
CRS-2677:Stop of 'ora.evmd' on 'rac01' succeeded
CRS-2677:Stop of 'ora.ctssd' on 'rac01' succeeded
CRS-2677:Stop of 'ora.asm' on 'rac01' succeeded
CRS-2673:Attempting to stop 'ora.cssd' on 'rac01'
CRS-2677:Stop of 'ora.cssd' on 'rac01' succeeded
CRS-2673:Attempting to stop 'ora.diskmon' on 'rac01'
CRS-2677:Stop of 'ora.diskmon' on 'rac01' succeeded
注:在运行“crsctl stopcluster”命令之后,如果 Oracle Clusterware 管理的资源中有任何一个还在运行,则整个命令失败。使用 -f 选项无条件地停止所有资源并停止 Oracle Clusterware 系统。
另请注意,可通过指定 -all 选项在集群中所有服务器上停止 Oracle Clusterware 系统。如下所示,在rac01和rac02上停止oracle clusterware系统:
[root@rac02~]# /u01/app/11.2.0/grid/bin/crsctl stop cluster –all
在本地服务器上启动oralceclusterware系统:
[root@rac01~]# /u01/app/11.2.0/grid/bin/crsctl start cluster
注:可通过指定 -all 选项在集群中所有服务器上启动 Oracle Clusterware 系统。
[root@rac02~]# /u01/app/11.2.0/grid/bin/crsctl start cluster –all
还可以通过列出服务器(各服务器之间以空格分隔)在集群中一个或多个指定的服务器上启动 Oracle Clusterware 系统:
[root@rac01~]# /u01/app/11.2.0/grid/bin/crsctl start cluster -n rac01 rac02
使用 SRVCTL 启动/停止所有实例:
[oracle@rac01~]#srvctl stop database -d racdb
[oracle@rac01~]#srvctl start database -d racdb
安装的后置任务:
1.官方建议的两个安装后置任务
(1) 备份 root.sh 脚本
官方建议在完成安装后要备份root.sh脚本文件。如果在OracleHome目录中又安装其它的产品,安装时OUI会升级已存在的root.sh文件。如果需要root.sh内的原始信息,就可以在备份中找到。
cd$ORACLE_HOME;cp root.sh root.sh.bak
(2)重新编译无效对象
运行 utlrp.sql 脚本立即重新编译所有无效的PL/SQL 程序包,而不是在首次访问它们时再重新编译。这是个可选步骤,但建议您选择该步骤。
[oracle@racnode1~]$ sqlplus / as sysdba
SQL>@?/rdbms/admin/utlrp.sql2.
在 RAC 环境中启用存档日志
(1)、以 oracle 用户身份登录到一个节点(即racnode1),通过在当前实例中将 cluster_database 设置为 FALSE 来禁用集群实例参数:
[oracle@rac01~]$ sqlplus / as sysdba
SQL>alter system set cluster_database=false scope=spfile sid='racdb1';
Systemaltered.
(2)、以 oracle 用户身份关闭所有 访问集群化数据库的实例:
[oracle@rac01~]$ srvctl stop database -d racdb
(3)、使用本地实例,挂载数据库:
[oracle@rac01~]$ sqlplus / as sysdba
SQL*Plus:Release 11.2.0.1.0 Production on Sat Nov 21 19:26:47 2009 Copyright (c) 1982,2009, Oracle. All rights reserved. Connected to an idle instance.
SQL>startup mount
ORACLEinstance started.
TotalSystem Global Area 1653518336 bytes
FixedSize 2213896 bytes
VariableSize 1073743864 bytes
DatabaseBuffers 570425344 bytes
RedoBuffers 7135232 bytes
(4)、启用存档功能:
SQL>alter database archivelog;
Databasealtered.
(5)、通过在当前实例中将实例参数 cluster_database 修改为 TRUE,重新启用对集群的支持:
SQL>alter system set cluster_database=true scope=spfile sid='racdb1';
Systemaltered.
(6)、关闭本地实例:
SQL>shutdown immediate
ORA-01109:database not open
Databasedismounted.
ORACLEinstance shut down.
(7)、以 oracle 帐户身份使用 srvctl命令重启所有实例:
[oracle@rac01~]$ srvctl start database -d racdb
(8)、登录到本地实例,验证存档日志模式已启用:
[oracle@rac01~]$ sqlplus / as sysdba
SQL*Plus:Release 11.2.0.1.0 Production on Sat Nov 21 19:33:38 2009 Copyright (c) 1982,2009, Oracle. All rights reserved. Connected to: Oracle Database 11g EnterpriseEdition Release 11.2.0.1.0 - 64bit Production With the Partitioning, RealApplication Clusters, Automatic Storage Management, OLAP, Data Mining and RealApplication Testing options
SQL>archive log list
Databaselog mode Archive Mode
Automaticarchival Enabled
Archivedestination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 69
Next logsequence to archive 70
Currentlog sequence 703
在两个RAC节点都备份spfile初始化参数文件:创建一个备份目录:
[oracle@rac02~]$ mkdir $ORACLE_HOME/spfile_bak
[oracle@rac02~]$ sqlplus “/as sysdba”
==============================================
crsctl说明
crsctladd resource
crsctladd type
crsctlcheck css
crsctldelete resource
crsctldelete type
crsctlget hostname
crsctlgetperm resource
crsctl getpermtype
crsctlmodify resource
crsctlmodify type
crsctlsetperm resource
crsctlsetperm type
crsctlstart resource
crsctlstatus resource
crsctlstatus type
crsctlstop resource
集群启动和停止
./crsctlstop cluster
./crsctlstart cluster
./crsctl check cr