RAC集群的启动和关闭,貌似非常的简单,敲来敲去也就是那五六个命令。但是深入理解下去,非常有助于我们了解RAC的构架.
启动和关闭rac一般使用三种方式:sqlplus,srvctl以及dbconsole或者Oracle grid control,本节中简要介绍下使用srvctl启动和关闭rac数据库集群!
使用crs_stat命令可以查询当前rac各节点下的asm实例,监听器,global service daemon,oracle notification server,vip,数据库实例是否正常!
[root@rac1 ~]# su - oracle [oracle@rac1 ~]$ crs_stat -t -v Name Type R/RA F/FT Target State Host ----------------------------------------------------------------------ora....SM1.asm application 0/5 0/0 ONLINE ONLINE rac1 ora....C1.lsnr application 0/5 0/0 ONLINE ONLINE rac1 ora.rac1.gsd application 0/5 0/0 ONLINE ONLINE rac1 ora.rac1.ons application 0/3 0/0 ONLINE ONLINE rac1 ora.rac1.vip application 0/0 0/0 ONLINE ONLINE rac1 ora....SM2.asm application 0/5 0/0 ONLINE ONLINE rac2 ora....C2.lsnr application 0/5 0/0 ONLINE ONLINE rac2 ora.rac2.gsd application 0/5 0/0 ONLINE ONLINE rac2 ora.rac2.ons application 0/3 0/0 ONLINE ONLINE rac2 ora.rac2.vip application 0/0 0/0 ONLINE ONLINE rac2 ora.racdb.db application 0/1 0/1 ONLINE ONLINE rac1 ora....b1.inst application 0/5 0/0 ONLINE ONLINE rac1 ora....b2.inst application 0/5 0/0 ONLINE ONLINE rac2
srvctl命令的使用
srvctl是service control的缩写,基本的用法是srvctl <command>
<object>
[<options>],使用srvctl命令,可以对rac各个节点的数据库实例,asm实例和监听器等进行管理,挺方便的工具
oracle@rac2 ~]$ srvctl Usage: srvctl <command> <object> [<options>] command: enable|disable|start|stop|relocate|status|add|remove|modify|getenv|setenv|unsetenv|config objects: database|instance|service|nodeapps|asm|listener For detailed help on each command and object and its options use: srvctl <command> <object> -h 获取更详细的帮助 [oracle@rac2 ~]$ srvctl start asm -h Usage: srvctl start asm -n <node_name> [-i <asm_inst_name>] [-o <start_options>] [-c <connect_str> | -q] -n <node> Node name -i <asm_inst_name> ASM instance name -o <start_options> Options to startup command (e.g. open, mount, or nomount) -c <connstr> Connect string (default: / as sysdba) -q Query connect string from standard input -h Print usage
关闭RAC数据库
[oracle@rac2 ~]$ srvctl stop database -d racdb [oracle@rac2 ~]$ crs_stat -t -v Name Type R/RA F/FT Target State Host ----------------------------------------------------------------------ora....SM1.asm application 0/5 0/0 ONLINE ONLINE rac1 ora....C1.lsnr application 0/5 0/0 ONLINE ONLINE rac1 ora.rac1.gsd application 0/5 0/0 ONLINE ONLINE rac1 ora.rac1.ons application 0/3 0/0 ONLINE ONLINE rac1 ora.rac1.vip application 0/0 0/0 ONLINE ONLINE rac1 ora....SM2.asm application 0/5 0/0 ONLINE ONLINE rac2 ora....C2.lsnr application 0/5 0/0 ONLINE ONLINE rac2 ora.rac2.gsd application 0/5 0/0 ONLINE ONLINE rac2 ora.rac2.ons application 0/3 0/0 ONLINE ONLINE rac2 ora.rac2.vip application 0/0 0/0 ONLINE ONLINE rac2 ora.racdb.db application 0/1 0/1 OFFLINE OFFLINE ora....b1.inst application 0/5 0/0 OFFLINE OFFLINE ora....b2.inst application 0/5 0/0 OFFLINE OFFLINE
关闭各节点的ASM实例
[oracle@rac2 ~]$ srvctl stop asm -n rac1 [oracle@rac2 ~]$ srvctl stop asm -n rac2 [oracle@rac2 ~]$ crs_stat -t -v Name Type R/RA F/FT Target State Host ----------------------------------------------------------------------ora....SM1.asm application 0/5 0/0 OFFLINE OFFLINE ora....C1.lsnr application 0/5 0/0 ONLINE ONLINE rac1 ora.rac1.gsd application 0/5 0/0 ONLINE ONLINE rac1 ora.rac1.ons application 0/3 0/0 ONLINE ONLINE rac1 ora.rac1.vip application 0/0 0/0 ONLINE ONLINE rac1 ora....SM2.asm application 0/5 0/0 OFFLINE OFFLINE ora....C2.lsnr application 0/5 0/0 ONLINE ONLINE rac2 ora.rac2.gsd application 0/5 0/0 ONLINE ONLINE rac2 ora.rac2.ons application 0/3 0/0 ONLINE ONLINE rac2 ora.rac2.vip application 0/0 0/0 ONLINE ONLINE rac2 ora.racdb.db application 0/1 0/1 OFFLINE OFFLINE ora....b1.inst application 0/5 0/0 OFFLINE OFFLINE ora....b2.inst application 0/5 0/0 OFFLINE OFFLINE
关闭各节点的服务包括 gsd,ons,vip,lisener 监听器等
[oracle@rac2 ~]$ srvctl stop nodeapps -n rac1 [oracle@rac2 ~]$ srvctl stop nodeapps -n rac2 [oracle@rac2 ~]$ crs_stat -t -v Name Type R/RA F/FT Target State Host ----------------------------------------------------------------------ora....SM1.asm application 0/5 0/0 OFFLINE OFFLINE ora....C1.lsnr application 0/5 0/0 OFFLINE OFFLINE ora.rac1.gsd application 0/5 0/0 OFFLINE OFFLINE ora.rac1.ons application 0/3 0/0 OFFLINE OFFLINE ora.rac1.vip application 0/0 0/0 OFFLINE OFFLINE ora....SM2.asm application 0/5 0/0 OFFLINE OFFLINE ora....C2.lsnr application 0/5 0/0 OFFLINE OFFLINE ora.rac2.gsd application 0/5 0/0 OFFLINE OFFLINE ora.rac2.ons application 0/3 0/0 OFFLINE OFFLINE ora.rac2.vip application 0/0 0/0 OFFLINE OFFLINE ora.racdb.db application 0/1 0/1 OFFLINE OFFLINE ora....b1.inst application 0/5 0/0 OFFLINE OFFLINE ora....b2.inst application 0/5 0/0 OFFLINE OFFLINE
关闭数据库实例,关闭各节点的ASM实例,关闭各节点实例,启动的顺序反之。
[oracle@rac2 ~]$ srvctl start nodeapps -n rac1 [oracle@rac2 ~]$ srvctl start nodeapps -n rac2 [oracle@rac2 ~]$ srvctl start asm -n rac1 [oracle@rac2 ~]$ srvctl start asm -n rac2 [oracle@rac2 ~]$ srvctl start instance -d racdb -i racdb1 -o mount [oracle@rac2 ~]$ srvctl start instance -d racdb -i racdb2 -o open [oracle@rac2 ~]$ sqlplus sys/123456@racdb1 as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Sat Nov 26 12:15:57 2011Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production With the Partitioning, Real Application Clusters, OLAP and Data Mining options SQL> select open_mode,name from v$database; OPEN_MODE NAME------------------------------ ---------------------------MOUNTED RACDB SQL> conn sys/123456@racdb2 as sysdba Connected. SQL> select open_mode,name from v$database; OPEN_MODE NAME------------------------------ ---------------------------READ WRITE RACDB
关闭RAC节点的某个实例
[oracle@rac2 ~]$ srvctl start nodeapps -n rac1 [oracle@rac2 ~]$ srvctl start nodeapps -n rac2 [oracle@rac2 ~]$ srvctl start asm -n rac1 [oracle@rac2 ~]$ srvctl start asm -n rac2 [oracle@rac2 ~]$ srvctl start instance -d racdb -i racdb1 -o mount [oracle@rac2 ~]$ srvctl start instance -d racdb -i racdb2 -o open [oracle@rac2 ~]$ sqlplus sys/123456@racdb1 as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Sat Nov 26 12:15:57 2011 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production With the Partitioning, Real Application Clusters, OLAP and Data Mining options SQL> select open_mode,name from v$database; OPEN_MODE NAME ------------------------------ --------------------------- MOUNTED RACDB SQL> conn sys/123456@racdb2 as sysdba Connected. SQL> select open_mode,name from v$database; OPEN_MODE NAME ------------------------------ --------------------------- READ WRITE RACDB |
禁止ASM实例和RAC实例自启动
[oracle@rac2 ~]$ srvctl disable asm -n rac1
[oracle@rac2 ~]$ srvctl disable asm -n rac2
[oracle@rac2 ~]$ srvctl disable database -d racdb
[oracle@rac1 ~]$ uptime
21:46:45 up 2 min, 1 user, load average: 2.03, 0.78, 0.28
[oracle@rac1 ~]$ crs_stat -t -v
Name Type R/RA F/FT Target State Host
----------------------------------------------------------------------
ora....SM1.asm application 0/5 0/0 ONLINE OFFLINE
ora....C1.lsnr application 0/5 0/0 ONLINE ONLINE rac1
ora.rac1.gsd application 0/5 0/0 ONLINE ONLINE rac1
ora.rac1.ons application 0/3 0/0 ONLINE ONLINE rac1
ora.rac1.vip application 0/0 0/0 ONLINE ONLINE rac1
ora....SM2.asm application 0/5 0/0 ONLINE OFFLINE
ora....C2.lsnr application 0/5 0/0 ONLINE ONLINE rac2
ora.rac2.gsd application 0/5 0/0 ONLINE ONLINE rac2
ora.rac2.ons application 0/3 0/0 ONLINE ONLINE rac2
ora.rac2.vip application 0/0 0/0 ONLINE ONLINE rac2
ora.racdb.db application 0/1 0/1 OFFLINE OFFLINE
ora....b1.inst application 0/1 0/0 OFFLINE OFFLINE
ora....b2.inst application 0/1 0/0 OFFLINE OFFLINE