本文共 7652 字,大约阅读时间需要 25 分钟。
和学操作系统一样,安装完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以及监听器
[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 ~]$ 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 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 as sysdba Connected. SQL> select open_mode,name from v$database; OPEN_MODE NAME ------------------------------ --------------------------- READ WRITE RACDB |
关闭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 |
转载地址:http://iiidx.baihongyu.com/