和学操作系统一样,安装完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 获取更详细的帮助 |
关闭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以及监听器
[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 |
rac数据的关闭顺序是:关闭集群数据库实例--关闭各节点ASM实例--关闭各节点服务,启动的顺序则相反!
[oracle@rac2 ~]$ srvctl start nodeapps -n rac1 [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 Connected to: SQL> select open_mode,name from v$database; OPEN_MODE NAME SQL> conn sys/123456@racdb2 as sysdba OPEN_MODE NAME |
关闭rac节点中的某个实例
[oracle@rac2 ~]$ srvctl stop instance -d racdb -i racdb1 -o immediate [oracle@rac2 ~]$ srvctl stop asm -n rac1 [oracle@rac2 ~]$ srvctl stop nodeapps -n rac1 [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 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 rac2 ora....b1.inst application 0/5 0/0 OFFLINE OFFLINE ora....b2.inst application 0/5 0/0 ONLINE ONLINE rac2 |
禁止asm实例和数据库实例自启动
[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 |
本文出自 “斩月” 博客,谢绝转载!