RAC---命令集

1

命令分类:

1.节点层:管理RAC环境下一些命令节点信息的相关命令

2.网络层:管理RAC环境下一些网络信息的相关命令

3.集群层:管理RAC环境下底层ClusterWare信息的相关命令

4.应用层:管理RAC环境下注册到RAC里的一些资源。

2

1.节点层

1

--------Olsnodes

命令格式:

Usage: olsnodes [ [-n] [-i] [-s] [-t] [ | -l [-p]] | [-c] ] [-g] [-v]

 where

  -n print node number with the node name

  -p print private interconnect address for the local node

  -i print virtual IP address with the node name

   print information for the specified node

  -l print information for the local node

  -s print node status - active or inactive

  -t print node type - pinned or unpinned

  -g turn on logging

  -v Run in debug mode; use at direction of Oracle Support only.

  -c print clusterware name

2

显示每个节点的ID:

[grid@rac1 ~]$ olsnodes -n

rac1        1

rac2        2

 

2

显示每个节点的VIP:

[grid@rac2 ~]$ olsnodes -i

rac1        rac1-vip

rac2        rac2-vip

3

用于显示Private  Interconnect网卡的名字:

3

2.网络层

 

1

--------Oifcfg

命令格式:

Name:

 oifcfg - Oracle Interface Configuration Tool.

Usage:  oifcfg iflist [-p [-n]]

 oifcfg setif {-node | -global} {/:}...

 oifcfg getif [-node | -global] [ -if [/] [-type ] ]

 oifcfg delif [-node | -global] [[/]]

 oifcfg [-help]

  - name of the host, as known to a communications network

   - name by which the interface is configured in the system

    - subnet address of the interface

   - type of the interface { cluster_interconnect | public | storage }

 

2

查看每个网卡的属性:

[grid@rac2 ~]$ oifcfg getif

eth0  192.168.70.0  global  public

eth1  192.168.71.0  global  cluster_interconnect

3

显示网卡列表:

[grid@rac2 ~]$ oifcfg iflist

eth0  192.168.70.0

eth1  192.168.71.0

eth1  169.254.0.0

 

4

查看public类型的网卡的配置:

[grid@rac2 ~]$ oifcfg getif  -type public

eth0  192.168.70.0  global  public

5

查看Cluster_interconnect类型的网卡的配置:

[grid@rac2 ~]$ oifcfg getif -type cluster_interconnect

eth1  192.168.71.0  global  cluster_interconnect

6

[grid@rac2 ~]$ oifcfg getif -global

eth0  192.168.70.0  global  public

eth1  192.168.71.0  global  cluster_interconnect

 

7

修改公网地址和内网地址:

[grid@rac2 ~]$ oifcfg setif -global eth0/192.168.0.1:public

[grid@rac2 ~]$ oifcfg setif -global eth1/192.168.0.0:cluster_interconnect

[grid@rac2 ~]$ oifcfg getif

eth0  192.168.0.1  global  public

eth1  192.168.0.0  global  cluster_interconnect

4

3.集群层

1

CrsctlOcrcheckOcrdumpOcrconfig

2

Crsctl 命令可以用来检查每个Crs 进程状态,管理Votedisk,具有跟踪Crs进程功能

 

Oracle10g-Crsctl

命令格式:

Usage: crsctl check  crs          - checks the viability of the CRS stack

       crsctl check  cssd         - checks the viability of CSS

       crsctl check  crsd         - checks the viability of CRS

       crsctl check  evmd         - checks the viability of EVM

       crsctl set    css - sets a parameter override

       crsctl get    css - gets the value of a CSS parameter

       crsctl unset  css - sets CSS parameter to its default

       crsctl query  css votedisk    - lists the voting disks used by CSS

       crsctl add    css votedisk - adds a new voting disk

       crsctl delete css votedisk - removes a voting disk

       crsctl enable  crs    - enables startup for all CRS daemons

       crsctl disable crs    - disables startup for all CRS daemons

       crsctl start crs  - starts all CRS daemons.

       crsctl stop  crs  - stops all CRS daemons. Stops CRS resources in case of cluster.

       crsctl start resources  - starts CRS resources.

       crsctl stop resources  - stops  CRS resources.

       crsctl debug statedump evm  - dumps state info for evm objects

       crsctl debug statedump crs  - dumps state info for crs objects

       crsctl debug statedump css  - dumps state info for css objects

       crsctl debug log css [module:level]{,module:level} ...

                             - Turns on debugging for CSS

       crsctl debug trace css - dumps CSS in-memory tracing cache

       crsctl debug log crs [module:level]{,module:level} ...

                             - Turns on debugging for CRS

       crsctl debug trace crs - dumps CRS in-memory tracing cache

       crsctl debug log evm [module:level]{,module:level} ...

                             - Turns on debugging for EVM

       crsctl debug trace evm - dumps EVM in-memory tracing cache

       crsctl debug log res turns on debugging for resources

       crsctl query crs softwareversion [] - lists the version of CRS software installed

       crsctl query crs activeversion - lists the CRS software operating version

       crsctl lsmodules css - lists the CSS modules that can be used for debugging

       crsctl lsmodules crs - lists the CRS modules that can be used for debugging

       crsctl lsmodules evm - lists the EVM modules that can be used for debugging

 

3

Crsctl
 

1

检查CRS状态:

 [root@nw1-rac1 bin]# ./crsctl check crs

CSS appears healthy

CRS appears healthy

EVM appears healthy

 

2

关闭CRS服务:

[root@nw1-rac1 bin]# ./crsctl stop crs

等同命令--[root@nw1-rac1 init.d]# ./init.crs stop

Shutting down Oracle Cluster Ready Services (CRS):

Stopping resources.

Successfully stopped CRS resources

Stopping CSSD.

Shutting down CSS daemon.

Shutdown request successfully issued.

Shutdown has begun. The daemons should exit soon.

3

开启CRS服务:

[root@nw1-rac1 bin]# ./crsctl start crs

等同命令--[root@nw1-rac1 init.d]# ./init.crs start

Startup will be queued to init within 90 seconds.

 

4

设置开机自动启动CRS服务:

[root@nw1-rac1 bin]#./ crsctl enable crs

5

检查CRS版本信息:

[root@nw1-rac1 bin]# ./crsctl query crs softwareversion

CRS software version on node [nw1-rac1] is [10.2.0.1.0]

6

检查CSS Network Heartbeat

[root@nw1-rac1 bin]# ./crsctl get css misscount

60

[root@nw1-rac1 bin]# ./crsctl get css disktimeout

unrecognized parameter disktimeout specified.

[root@nw1-rac1 bin]# ./crsctl get css misscount

120

7

检查表决磁盘信息:

[root@nw1-rac1 bin]# ./crsctl query css votedisk

 0.     0    /dev/raw/raw5

 1.     0    /dev/raw/raw6

 2.     0    /dev/raw/raw7

located 3 votedisk(s).

 

8

 

添加表决磁盘:

[root@nw1-rac1 bin]# ./crsctl add css votedisk /dev/raw/raw8 -force

Now formatting voting disk: /dev/raw/raw8

successful addition of votedisk /dev/raw/raw8.

[root@nw1-rac1 bin]# ./crsctl query css votedisk

 0.     0    /dev/raw/raw5

 1.     0    /dev/raw/raw6

 2.     0    /dev/raw/raw7

 3.     0    /dev/raw/raw8

located 4 votedisk(s).

注意:即使在CRS 关闭后,也必须通过-force 参数来添加和删除Votedisk,并且-force 参数只有在CRS关闭的场合下使用才安全。否则会报:Cluter is not a ready state for online disk addition

9

删除表决磁盘:

[root@nw1-rac1 bin]# ./crsctl delete css votedisk /dev/raw/raw8 -force

successful deletion of votedisk /dev/raw/raw8.

[root@nw1-rac1 bin]# ./crsctl query css votedisk

 0.     0    /dev/raw/raw5

 1.     0    /dev/raw/raw6

 2.     0    /dev/raw/raw7

located 3 votedisk(s).

需要注意的是,Votedisk使用的是一种“多数可用算法”,如果有多个Votedisk,,则必须一半以上的Votedisk同时使用,Clusterware才能正常使用。比如配置了4Votedisk,坏一个Votedisk,集群可以正常工作,如果坏了2个,则不能满足半数以上,集群会立即宕掉,所有节点立即重启,所以如果添加Votedisk,尽量不要只添加一个,而应该添加2个。这点和OCR 不一样。OCR 只需配置一个。

10

检查CSS,CRS,EVM功能模块信息:

[root@nw1-rac1 bin]#  ./crsctl lsmodules css

The following are the CSS modules ::

    CSSD

    COMMCRS

    COMMNS

[root@nw1-rac1 bin]#  ./crsctl lsmodules crs

The following are the CRS modules ::

    CRSUI

    CRSCOMM

    CRSRTI

    CRSMAIN

    CRSPLACE

    CRSAPP

    CRSRES

    CRSCOMM

    CRSOCR

    CRSTIMER

    CRSEVT

    CRSD

    CLUCLS

    CSSCLNT

    COMMCRS

    COMMNS

[root@nw1-rac1 bin]#  ./crsctl lsmodules evm

The following are the EVM modules ::

   EVMD

   EVMDMAIN

   EVMCOMM

   EVMEVT

   EVMAPP

   EVMAGENT

   CRSOCR

   CLUCLS

   CSSCLNT

   COMMCRS

   COMMNS

11

Trace一下CSS进程信息、并查看:

[root@nw1-rac1 bin]# ./crsctl debug log css "CSSD:1"

Configuration parameter trace is now set to 1.

Set CRSD Debug Module: CSSD  Level: 1

[root@nw1-rac1 cssd]# tail -5f ocssd.log

[    CSSD]2015-02-09 04:17:09.861 [1177389376] >TRACE:   clssgmClientConnectMsg: Connect from con(0x4b70bd0) proc(0x4b655e0) pid() proto(10:2:1:1)

[    CSSD]2015-02-09 04:17:46.434 [1086224704] >TRACE:   clssscSetDebugLevel: The logging level is set to 1 ,the cache level is set to 2

[    CSSD]2015-02-09 04:18:10.096 [1177389376] >TRACE:   clssgmClientConnectMsg: Connect from con(0x4baca70) proc(0x4b72a60) pid() proto(10:2:1:1)

[    CSSD]2015-02-09 04:19:10.451 [1177389376] >TRACE:   clssgmClientConnectMsg: Connect from con(0x4baca70) proc(0x4ba2e10) pid() proto(10:2:1:1)

[    CSSD]2015-02-09 04:20:10.761 [1177389376] >TRACE:   clssgmClientConnectMsg: Connect from con(0x4baca70) proc(0x4b72a60) pid() proto(10:2:1:1)

 

12

Oracle11g-Crsctl

命令格式:

Usage: crsctl[]

    command: enable|disable|config|start|stop|relocate|replace|status|add|delete|modify|getperm|setperm|check|set|get|unset|debug|lsmodules|query|pin|unpin|discover|release|request

For complete usage, use:

    crsctl [-h | --help]

For detailed help on each command and object and its options use:

5

应用层

1

Crs_stat、Crs_start、Crs_stop、Onsctl、Srvctl

应用层就是指集群上的真正的应用资源了,这一层的管理和维护都是围绕这些资源进行的。

2

 Crs_statCrs_startCrs_stop

Crs_stat 这个命令用于查看CRS维护的所有资源的运行状态参数(-t -v -ls

 

[oracle@nw1-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....ac1.gsd application    0/5    0/0    OFFLINE   OFFLINE              

ora....ac1.ons application    0/3    0/0    OFFLINE   OFFLINE              

ora....ac1.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....ac2.gsd application    0/5    0/0    OFFLINE   OFFLINE              

ora....ac2.ons application    0/3    0/0    OFFLINE   OFFLINE              

ora....ac2.vip application    0/0    0/0    OFFLINE   OFFLINE              

ora.orcl.db    application    0/1    0/1    OFFLINE   OFFLINE              

ora....l1.inst application    0/5    0/0    OFFLINE   OFFLINE              

ora....l2.inst application    3/5    0/0    OFFLINE   OFFLINE             

3

使用-ls 选项,可以查看每个资源的权限定义,权限定义格式和Linux 一样。

[oracle@nw1-rac2 ~]$ crs_stat -ls

Name           Owner          Primary PrivGrp          Permission 

-----------------------------------------------------------------

ora....SM1.asm oracle         oinstall                 rwxrwxr--

ora....C1.lsnr oracle         oinstall                 rwxrwxr--

ora....ac1.gsd oracle         oinstall                 rwxr-xr--

ora....ac1.ons oracle         oinstall                 rwxr-xr--

ora....ac1.vip root           oinstall                 rwxr-xr--

ora....SM2.asm oracle         oinstall                 rwxrwxr--

ora....C2.lsnr oracle         oinstall                 rwxrwxr--

ora....ac2.gsd oracle         oinstall                 rwxr-xr--

ora....ac2.ons oracle         oinstall                 rwxr-xr--

ora....ac2.vip root           oinstall                 rwxr-xr--

ora.orcl.db    oracle         oinstall                 rwxrwxr--

ora....l1.inst oracle         oinstall                 rwxrwxr--

ora....l2.inst oracle         oinstall                 rwxrwxr--

4

启动所有节点集群平台上的所有资源。

[oracle@nw1-rac2 ~]$ crs_start -all

 

关闭所有节点集群平台上的所有资源。

[oracle@nw1-rac2 ~]$ crs_stop -all

5

Onsctl

1

使用onsctl命令可以启动,停止,调试ONS,并重新载入配置文件。

命令格式:

usage: /u01/app/oracle/product/11.2.0/db_1/bin/onsctl start|stop|ping|reconfig|debug

start                            - Start opmn only.

stop                             - Stop ons daemon

ping                             - Test to see if ons daemon is running

debug                            - Display debug information for the ons daemon

reconfig                         - Reload the ons configuration

help                             - Print a short syntax description (this).

detailed                         - Print a verbose syntax description.

这个命令用于管理配置ONS(Oracle Notification Service). ONS 是Oracle Clusterware 实现FAN Event Push模型的基础。

在传统模型中,客户端需要定期检查服务器来判断服务端状态,本质上是一个pull模型,Oracle 10g 引入了一个全新的PUSH 机制--FAN(Fast Application Notification),当服务端发生某些事件时,服务器会主动的通知客户端这种变化,这样客户端就能尽早得知服务端的变化。而引入这种机制就是依赖ONS实现,在使用onsctl命令之前,需要先配置ONS服务。

2

ONS 配置内容

在RAC 环境中,需要使用$CRS_HOME下的ONS,而不是$ORACLE_HOME下面的ONS,这点需要注意。配置文件在$CRS_HOME/opmn/conf/ons.config

[oracle@nw1-rac2 conf]$ pwd

/u01/app/crs/opmn/conf

[oracle@nw1-rac2 conf]$ cat ons.config

localport=6113

remoteport=6200

loglevel=3

useocr=on

3

参数说明:

Localport: 这个参数代表本地监听端口,这里本地特指:127.0.0.1 这个回环地址,用来和运行在本地的客户端进行通信

Remoteport:这个参数代表的是远程监听端口,也就是除了127.0.0.1 以外的所有本地IP地址,用来和远程的客户端进行通信。

Loglevel: Oracle 允许跟踪ONS进程的运行,并把日志记录到本地文件中,这个参数用来定义ONS进程要记录的日志级别,从1-9,缺省值是3.

Logfile: 这个参数和loglevel参数一起使用,用于定义ONS进程日志文件的位置,缺省值是$CRS_HOME/opmn/logs/opmn.log

nodes和useocr: 这两个参数共同决定饿了本地的ONS daemon要和哪些远程节点上的ONS daemon进行通信。

4

Nodes 参数值格式如下:Hostname/IP:port[hostname/ip:port]

如:useoce=off

Nodes=rac1:6200,rac2:6200

而useocr 参数值为on/off, 如果useocr ON,说明信息保存在OCR中,如果是OFF,说明信息取nodes中的配置。对于单实例而言,要把useocr设置为off

配置ONS

可以直接编译ONS的配置文件来修改配置,如果使用了OCR,则可以通过racgons命令进行配置,但必须以root用户来执行,如果用Oracle用户来执行,不会提示任何错误,但也不会更改任何配置。

若要添加配置,可以使用下面命令:

Racgons add_config nw1-rac1:6200 rac2:6200

若要删除配置,可以用下面命令:

Racgons remove_config nw1-rac1:6200 rac2:6200

 

ONS 进程运行,并不一定代表ONS 正常工作,需要使用ping命令来确认。

 

-在OS级别查看进程状态

[oracle@nw1-rac2 conf]$ ps -aef|grep ons|grep -v grep

oracle   15584     1  0 10:47 ?        00:00:00 /u01/app/crs/opmn/bin/ons -d

oracle   15585 15584  0 10:47 ?        00:00:00 /u01/app/crs/opmn/bin/ons -d

 

-确认ONS服务的状态

[oracle@nw1-rac2 bin]$ ./onsctl ping

Number of onsconfiguration retrieved, numcfg = 2

onscfg[0]

   {node = nw1-rac1.ht8888.ht3, port = 6200}

Adding remote host nw1-rac1.ht8888.ht3:6200

onscfg[1]

   {node = nw1-rac2.ht8888.ht3, port = 6200}

Adding remote host nw1-rac2.ht8888.ht3:6200

ons is running ...

 

-启动ONS服务

[oracle@nw1-rac2 bin]$ ./onsctl start

 

使用debug 选项,可以查看详细信息,其中最有意义的就是能显示所有连接。

[oracle@nw1-rac2 bin]$ ./onsctl debug

Number of onsconfiguration retrieved, numcfg = 2

onscfg[0]

   {node = nw1-rac1.ht8888.ht3, port = 6200}

Adding remote host nw1-rac1.ht8888.ht3:6200

onscfg[1]

   {node = nw1-rac2.ht8888.ht3, port = 6200}

Adding remote host nw1-rac2.ht8888.ht3:6200

HTTP/1.1 200 OK

Content-Length: 1359

Content-Type: text/html

Response:

 

======== ONS ========

Listeners:

 NAME    BIND ADDRESS   PORT   FLAGS   SOCKET

------- --------------- ----- -------- ------

Local   127.000.000.001  6113 00000142      7

Remote  192.168.000.183  6200 00000101      8

6

 srvctl

该命令是RAC维护中最常用的命令,也是最复杂的命令。这个工具可以操作下面的几种资源:Database,Instance,ASM,Service,Listener Node Application,其中Node application又包括GSDONSVIP。这些资源除了使用srvctl工具统一管理外,某些资源还有自己独立的管理工具,比如ONS可以使用onsctl命令进行管理;Listener 可以通过lsnrctl 管理。

Usage: srvctl[]

    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

1

所有oracle实例-----(数据库状态)

[grid@rac1 ~]$ srvctl status database -d PROD
 

[grid@rac1 ~]$ srvctl start database -d PROD

 

 

[grid@rac1 ~]$ srvctl stop database -d PROD

2

检查单个实例的状态:

[grid@rac1 ~]$ srvctl status instance -d PROD -i prod1

PRKO-3032 : Invalid instance name(s): prod1

 

开启单个实例:

[grid@rac1 ~]$ srvctl start instance -d PROD -i prod1

Invalid instance name(s): prod1

 

关闭单个实例:

[grid@rac1 ~]$ srvctl stop instance -d PROD -i prod1

Invalid instance name(s): prod1

 

3

节点应用程序状态:

[grid@rac1 ~]$ srvctl status nodeapps -n rac1

VIP rac1-vip is enabled

VIP rac1-vip is running on node: rac1

Network is enabled

Network is running on node: rac1

GSD is disabled

GSD is not running on node: rac1

ONS is enabled

ONS daemon is running on node: rac1

 

[grid@rac1 ~]$ srvctl status nodeapps -n rac2

VIP rac2-vip is enabled

VIP rac2-vip is running on node: rac2

Network is enabled

Network is running on node: rac2

GSD is disabled

GSD is not running on node: rac2

ONS is enabled

ONS daemon is running on node: rac2

 

4

列出所有的配置数据库:

[grid@rac1 ~]$ srvctl config database

PROD

 

5

ASM状态及配置:

[grid@rac1 ~]$ srvctl status asm

ASM is running on rac2,rac1

 

[grid@rac1 ~]$ srvctl config asm

ASM home: /u01/app/11.2.0/grid

ASM listener: LISTENER

 

6

TNS监听器状态以及配置:

[grid@rac1 ~]$ srvctl status listener

Listener LISTENER is enabled

Listener LISTENER is running on node(s): rac2,rac1

 

[grid@rac1 ~]$ srvctl config listener

Name: LISTENER

Network: 1, Owner: grid

Home: <CRS home>

End points: TCP:1521

 

10

SCAN状态以及配置

[grid@rac1 ~]$ srvctl status scan

SCAN VIP scan1 is enabled

SCAN VIP scan1 is running on node rac1

 

[grid@rac1 ~]$ srvctl config scan

SCAN name: rac-scan.us.oracle.com, Network: 1/192.168.70.0/255.255.255.0/eth0

SCAN VIP name: scan1, IP: /rac-scan.us.oracle.com/192.168.70.33

 

 

11

VIP各个节点的状态及配置

[grid@rac1 ~]$ srvctl status vip -n rac1

VIP rac1-vip is enabled

VIP rac1-vip is not running

VIP rac2-vip is enabled

VIP rac2-vip is running on node: rac2

 

[grid@rac1 ~]$ srvctl config vip -n rac1

VIP exists: /rac1-vip/192.168.70.21/192.168.70.0/255.255.255.0/eth0, hosting node rac1

[grid@rac1 ~]$ srvctl config vip -n rac2

VIP exists: /rac2-vip/192.168.70.22/192.168.70.0/255.255.255.0/eth0, hosting node rac2

 

 

12

节点应用程序配置

[grid@rac1 ~]$ srvctl config nodeapps -a -s -l

Warning:-l option has been deprecated and will be ignored.

Network exists: 1/192.168.70.0/255.255.255.0/eth0, type static

VIP exists: /rac1-vip/192.168.70.21/192.168.70.0/255.255.255.0/eth0, hosting node rac1

VIP exists: /rac2-vip/192.168.70.22/192.168.70.0/255.255.255.0/eth0, hosting node rac2

ONS exists: Local port 6100, remote port 6200, EM port 2016

Name: LISTENER

Network: 1, Owner: grid

Home: <CRS home>

  /u01/app/11.2.0/grid on node(s) rac1,rac2

End points: TCP:1521

 

13

启动/停止所有实例

[grid@rac1 ~]$ srvctl stop database -d PROD

PRCC-1016 : PROD was already stopped

[grid@rac1 ~]$ srvctl start database -d PROD

14

启动和停止某个节点上的listener

[grid@rac1 ~]$ srvctl start listener -n rac1

PRCC-1015 : LISTENER was already running on rac1

PRCR-1004 : Resource ora.LISTENER.lsnr is already running

[grid@rac1 ~]$ srvctl stop listener -n rac1

 

 

 

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30606702/viewspace-1981205/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30606702/viewspace-1981205/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值