欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Oracle11g启动、停止实例和RAC数据库操作实例

程序员文章站 2022-06-23 16:03:30
管理RAC数据库的工具可以是OEM、SQL*Plus和SRVCTL。 1、查看集群的状态 [grid@node1 ~]$ crsctl stat res -t -----...

管理RAC数据库的工具可以是OEM、SQL*Plus和SRVCTL。

1、查看集群的状态

[grid@node1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       node1                                        
               ONLINE  ONLINE       node2                                        
ora.FRA.dg
               ONLINE  ONLINE       node1                                        
               ONLINE  ONLINE       node2                                        
ora.LISTENER.lsnr
               ONLINE  ONLINE       node1                                        
               ONLINE  ONLINE       node2                                        
ora.asm
               ONLINE  ONLINE       node1                    Started             --ASM实例处于启动状态
               ONLINE  ONLINE       node2                    Started             
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                                        
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       node1                                        
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       node2                                        
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       node1                                        
ora.cvu
      1        ONLINE  ONLINE       node2                                        
ora.node1.vip
      1        ONLINE  ONLINE       node1                                        
ora.node2.vip
      1        ONLINE  ONLINE       node2                                        
ora.oc4j
      1        ONLINE  ONLINE       node2                                        
ora.orcl.db
      1        ONLINE  ONLINE       node1                    Open                --数据库处于打开状态
      2        ONLINE  ONLINE       node2                    Open                
ora.scan1.vip
      1        ONLINE  ONLINE       node1                                        
ora.scan2.vip
      1        ONLINE  ONLINE       node2                                        
ora.scan3.vip
      1        ONLINE  ONLINE       node1                                        
[grid@node1 ~]$
[grid@node1 ~]$ srvctl status database -d orcl
Instance orcl1 is running on node node1
Instance orcl2 is running on node node2

2、关闭数据库 数据库关闭顺序为:关闭数据库——>卸载数据库——>关闭实例

[grid@node1 ~]$ srvctl stop database -d orcl
[grid@node1 ~]$ srvctl status database -d orcl
Instance orcl1 is not running on node node1
Instance orcl2 is not running on node node2

3、关闭ASM实例 ASM实例关闭顺序为:卸载磁盘——>关闭ASM实例

[grid@node1 ~]$ srvctl  status asm  --查看ASM状态
ASM is running on node2,node1
--停止磁盘组
[grid@node1 ~]$ srvctl stop diskgroup -g DATA -n node1,node2  
[grid@node1 ~]$ srvctl stop diskgroup -g FRA -n node1,node2
[grid@node1 ~]$ srvctl status diskgroup -g DATA -n node1,node2
Disk Group DATA is not running on node1,node2
[grid@node1 ~]$ srvctl status diskgroup -g FRA -n node1,node2 --查看磁盘组状态
Disk Group FRA is not running on node1,node2
--关闭ASM实例
[grid@node1 ~]$ srvctl stop asm 
--查看实例状态
[grid@node1 ~]$ srvctl status asm
ASM is not running.
[grid@node1 ~]$ srvctl status asm -n node1
ASM is not running on node1
[grid@node1 ~]$ srvctl status asm -n node2
ASM is not running on node2
--查看集群状态
[grid@node1 ~]$ crs_stat -t -v
Name           Type           R/RA   F/FT   Target    State     Host        
----------------------------------------------------------------------
ora.DATA.dg    ora....up.type 0/5    0/     OFFLINE   OFFLINE               
ora.FRA.dg     ora....up.type 0/5    0/     OFFLINE   OFFLINE               
ora....ER.lsnr ora....er.type 0/5    0/     ONLINE    ONLINE    node1       
ora....N1.lsnr ora....er.type 0/5    0/0    ONLINE    ONLINE    node1       
ora....N2.lsnr ora....er.type 0/5    0/0    ONLINE    ONLINE    node2       
ora....N3.lsnr ora....er.type 0/5    0/0    ONLINE    ONLINE    node1       
ora.asm        ora.asm.type   0/5    0/     OFFLINE   OFFLINE               
ora.cvu        ora.cvu.type   0/5    0/0    ONLINE    ONLINE    node2       
ora.gsd        ora.gsd.type   0/5    0/     OFFLINE   OFFLINE               
ora....network ora....rk.type 0/5    0/     ONLINE    ONLINE    node1       
ora....SM1.asm application    0/5    0/0    OFFLINE   OFFLINE               
ora....E1.lsnr application    0/5    0/0    ONLINE    ONLINE    node1       
ora.node1.gsd  application    0/5    0/0    OFFLINE   OFFLINE               
ora.node1.ons  application    0/3    0/0    ONLINE    ONLINE    node1       
ora.node1.vip  ora....t1.type 0/0    0/0    ONLINE    ONLINE    node1       
ora....SM2.asm application    0/5    0/0    OFFLINE   OFFLINE               
ora....E2.lsnr application    0/5    0/0    ONLINE    ONLINE    node2       
ora.node2.gsd  application    0/5    0/0    OFFLINE   OFFLINE               
ora.node2.ons  application    0/3    0/0    ONLINE    ONLINE    node2       
ora.node2.vip  ora....t1.type 0/0    0/0    ONLINE    ONLINE    node2       
ora.oc4j       ora.oc4j.type  0/1    0/2    ONLINE    ONLINE    node2       
ora.ons        ora.ons.type   0/3    0/     ONLINE    ONLINE    node1       
ora.orcl.db    ora....se.type 0/2    0/1    OFFLINE   OFFLINE               
ora.scan1.vip  ora....ip.type 0/0    0/0    ONLINE    ONLINE    node1       
ora.scan2.vip  ora....ip.type 0/0    0/0    ONLINE    ONLINE    node2       
ora.scan3.vip  ora....ip.type 0/0    0/0    ONLINE    ONLINE    node1       
[grid@node1 ~]$ 

4、启动ASM实例

[grid@node1 ~]$ sqlplus / as sysasm

SQL*Plus: Release 11.2.0.4.0 Production on Wed Apr 18 21:24:25 2018

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ASM instance started

Total System Global Area 1135747072 bytes
Fixed Size		    2260728 bytes
Variable Size		 1108320520 bytes
ASM Cache		   25165824 bytes
ASM diskgroups mounted
SQL> 
[grid@node1 ~]$ srvctl status asm
ASM is running on node2,node1

5、启动数据库

--查看数据库状态
[grid@node1 ~]$ srvctl status database -d orcl
Instance orcl1 is not running on node node1
Instance orcl2 is not running on node node2
--启动数据库
[grid@node1 ~]$ srvctl start database -d orcl
--查看数据库状态
[grid@node1 ~]$ srvctl status database -d orcl
Instance orcl1 is running on node node1
Instance orcl2 is running on node node2
[grid@node1 ~]$ 

6、查看监听器状态

[grid@node1 ~]$ srvctl status listener
Listener LISTENER is enabled
Listener LISTENER is running on node(s): node2,node1

7、查看集群状态

[grid@node1 ~]$ crs_stat -t -v
Name           Type           R/RA   F/FT   Target    State     Host        
----------------------------------------------------------------------
ora.DATA.dg    ora....up.type 0/5    0/     ONLINE    ONLINE    node1       
ora.FRA.dg     ora....up.type 0/5    0/     ONLINE    ONLINE    node1       
ora....ER.lsnr ora....er.type 0/5    0/     ONLINE    ONLINE    node1       
ora....N1.lsnr ora....er.type 0/5    0/0    ONLINE    ONLINE    node1       
ora....N2.lsnr ora....er.type 0/5    0/0    ONLINE    ONLINE    node2       
ora....N3.lsnr ora....er.type 0/5    0/0    ONLINE    ONLINE    node1       
ora.asm        ora.asm.type   0/5    0/     ONLINE    ONLINE    node1       
ora.cvu        ora.cvu.type   0/5    0/0    ONLINE    ONLINE    node2       
ora.gsd        ora.gsd.type   0/5    0/     OFFLINE   OFFLINE               
ora....network ora....rk.type 0/5    0/     ONLINE    ONLINE    node1       
ora....SM1.asm application    0/5    0/0    ONLINE    ONLINE    node1       
ora....E1.lsnr application    0/5    0/0    ONLINE    ONLINE    node1       
ora.node1.gsd  application    0/5    0/0    OFFLINE   OFFLINE               
ora.node1.ons  application    0/3    0/0    ONLINE    ONLINE    node1       
ora.node1.vip  ora....t1.type 0/0    0/0    ONLINE    ONLINE    node1       
ora....SM2.asm application    0/5    0/0    ONLINE    ONLINE    node2       
ora....E2.lsnr application    0/5    0/0    ONLINE    ONLINE    node2       
ora.node2.gsd  application    0/5    0/0    OFFLINE   OFFLINE               
ora.node2.ons  application    0/3    0/0    ONLINE    ONLINE    node2       
ora.node2.vip  ora....t1.type 0/0    0/0    ONLINE    ONLINE    node2       
ora.oc4j       ora.oc4j.type  0/1    0/2    ONLINE    ONLINE    node2       
ora.ons        ora.ons.type   0/3    0/     ONLINE    ONLINE    node1       
ora.orcl.db    ora....se.type 0/2    0/1    ONLINE    ONLINE    node1       
ora.scan1.vip  ora....ip.type 0/0    0/0    ONLINE    ONLINE    node1       
ora.scan2.vip  ora....ip.type 0/0    0/0    ONLINE    ONLINE    node2       
ora.scan3.vip  ora....ip.type 0/0    0/0    ONLINE    ONLINE    node1       
[grid@node1 ~]$