ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Oracle10g RAC管理 - CRS

Oracle10g RAC管理 - CRS

原创 Linux操作系统 作者:tolywang 时间:2009-02-17 10:32:59 0 删除 编辑


Oracle10g RAC管理 –第一部分: 使用CRS命令行控制集群 

 

在文章的开头,我们讨论一下管理RAC数据库。所谓管理意味着很多事情;如同Oracle DBA所做的――备份,恢复,导出,

导入,优化,制定基线等等。无论如何管理RAC都将是一项挑战。你需要的是可靠的工具。

CRS入门

让我们先对什么是CRS以及CRS做哪些工作了解一下。同样也介绍一下命令行参数以及如何正确使用它们。

Crs_getperm:用于核对相关资源的权限

语法:

crs_getperm resource_name [-u user|-g group]

Crs_profile:用于建立,验证,删除,更新 Oracle集群件档案文件(profile)

你可以使用crs_profile来建立一个脚本模版。在profile中,定义如何管理并监控集群。

当创建了一个应用程序profile并且使用crs_register命令向Oracle集群件注册了它,你就可以使用其他的Oracle 集群件

命令行(crs_stat,crs_start,crs_stop,crs_relocate, crs_unregister)来操作这个应用程序。这对方便的排除故障很有

用。在其他Oracle集群件命令行控制特定的应用程序之前,你必须使用crs_regiester命令行来注册它。

语法:

下面的步骤将创建一个profile:

crs_profile -create resource_name -t application [-a action_script]

[-B executable_pathname] [-dir directory] [-d description]

[-p placement_policy] [-h hosting_nodes] [-r required_resources]

[-l optional_resources]? [-o option,[...]]

[attribute_flag attribute_value] [...] [-f] [-q]

?

以下命令从模版中创建一个应用程序profile:

crs_profile -create resource_name -I template_file [-f] [-q]

验证profile:

crs_profile -validate resource_name [-q]

将应用程序profile列出:

crs_profile -print [resource_name [...]] [-q]

更新profile:

crs_profile -update resource_name [option [...]] [-q]

删除profile:

crs_profile -delete resource_name [-q]

crs_register:此命令将应用程序配置信息注册到OCR(译者注:Oracle Cluster Registry:一个关于集群的元数据数据库,

用于维护集群内的资源跟踪,并获知资源正在哪里运行以及它们能够并应该在哪里运行,运行crs_stat所得到的信息来于

此)中。

Crs_register命令行使用特定的资源名参数来注册每个应用程序。在使用starting,stopping 或其他的操作之前你必须先

注册这个应用程序。

CRS进程必须是在运行的,如果任何成员丢失那么这个profile将和默认模版合并(译者注:在你的$CRS_HOME/crs目录下你

可以找到上述的profile以及模版文件)

在注册时你要决定拥有者和权限问题。(执行注册动作的用户默认为拥有者)。

crs_profile和crs_register必须要有读写权限,之后可以使用crs_stat命令来检查注册成功与否。

语法:使用crs_register命令注册或更新应用程序。

crs_register resource_name [-dir directory_path] [...] [-u] [-f] [-q]

crs_relocate:将一个应用程序profile从一个节点重定位到另一个。

当然,重定位应用程序必须先注册。使用上面的crs_relocate命令,Oracle集群件通过先在源节点停止资源然后在目标节

点上开始运行资源来重定位。如果没有成功,在你重新试图重定位之前你必须先使用crs_stop –f命令关闭资源,然后运

行crs_start让资源重新处于online状态。

Syntax: ??语法:

crs_relocate resource_name [...] [-c cluster_node] [-f][-q]

crs_relocate resource_name [-c cluster_node] [-q]

crs_relocate [USR_attribute_name=value] [...] resource_name [-c cluster_node] [-q]

crs_relocate -s source_node [-c cluster_node] [-q]

Crs_setperm:用来设置和修改相关资源的权限

与UNIX/LINUX中的chmod命令起到相同的作用。

语法:

crs_setperm resource_name -u aclstring [-q]

crs_setperm resource_name -x aclstring [-q]

crs_setperm resource_name -o user_name [-q]

crs_setperm resource_name -g group_name [-q]

crs_stat:用来列出应用程序profile的状态。以上提到的资源需要有读和执行权限,也可以

使用-g参数。

在state属性栏中资源可以是online或offline状态。如果资源为online但集群节点失败了集群件会在另一个节点上重新启

动应用程序。所有的资源状态都应该是online的,如果资源失败的计数器高于所定义的失败阀值(译者注:这些值都在

profile中定义,profile的位置为$CRS_HOME/crs/public/*.cap)将会导致资源处在offline的状态。你必须使用

crs_start命令来使能所有的资源。

我还喜欢使用-v参数来显示更详细的信息。RESTART_COUNT值表明资源在一个节点上已经重启的多少次。FAILURE_COUNT值

表明在FAILURE_INTERVAL值中资源失败的次数(以上及以下值都在profile中),一旦超过了FAILURE_THRESHOLD参数就会

导致资源停止。在详细模式中显示的FAILOVER_STATUS值表明在资源重定向时等待的时间(因为节点失败所导致的重定向)

FAILOVER_DELAY属性标明在重定向之前等待的时间。

语法:

crs_stat [resource_name [...]] [-v] [-l] [-q] [-c cluster_node]

crs_stat [resource_name [...]] -t [-v] [-q] [-c cluster_node]

crs_stat -p [resource_name [...]] [-q]

crs_stat [-a] resource_name -g

crs_stat [-a] resource_name -r [-c cluster_node]

crs_stat -f [resource_name [...]] [-q] [-c cluster_node]

crs_stat -ls resource_name

小节:

Crs_commands在管理和排错时很有效。下一节为将继续讨论如何使用crs_stop、crs_start等其他命令来把所有应用带回到

online状态下。

 

 

 

 

 

 

 

 

 

 

 

RAC管理 -第二部分:crs命令

在上一篇文章里,讨论了几个crs的命令和行语法,并且看了一下集群突然运行不正常时发生了什么。下面继续讨论其余的

cs命令:

介绍CRS

crs_start:
此命令将使所有应用程序或指定的应用程序进入到ONLINE状态,并且试图使能指定的已注册应用程序或应用程序资源。(

需要完全的管理权限)。

语法:
crs_start resource_name [...] [-c cluster_node] [-q] [-f]

crs_start -all [-q]

crs_start [USR_attribute_name=value] [...]
resource_name [-c node_name] [-q]

crs_stop:
此命令将停止指定节点上的资源。可以使用crs_stat来查看应用程序或资源列表。

语法:
crs_stop resource_name [...] [-f] [-q]

crs_stop -c cluster_node [...] [-q]

crs_stop -all [-q]

crs_stop [USR_attribute_name=value] [...] resource_name [-q]
-c cluster_node [...]

crs_unregister:
此命令将移除Oracle集群件资源的注册信息。

语法:
crs_unregister resource_name [...] [-q]

纠正RAC的问题:
上面我们看了一下关于crs的命令和语法,接着我们看一下它们的具体应用。
当运行我的构建在RHEL4上的RAC时出现了问题(我想主要的原因是虚拟机内存不足导致的),运行crs_stat来查看RAC状态

oracle@vmora01rh4 ~]$ cd /u01/app/oracle/product/10.2.0/crs/bin
[oracle@vmora01rh4 bin]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.fokerac.db application ONLINE ONLINE vmora02rh4
ora....c1.inst application ONLINE ONLINE vmora01rh4
ora....c2.inst application OFFLINE UNKNOWN vmora02rh4
ora....serv.cs application ONLINE ONLINE vmora02rh4
ora....ac1.srv application ONLINE ONLINE vmora01rh4
ora....ac2.srv application ONLINE OFFLINE
ora....SM1.asm application ONLINE ONLINE vmora01rh4
ora....H4.lsnr application ONLINE ONLINE vmora01rh4
ora....rh4.gsd application ONLINE UNKNOWN vmora01rh4
ora....rh4.ons application ONLINE UNKNOWN vmora01rh4
ora....rh4.vip application ONLINE ONLINE vmora01rh4
ora....SM2.asm application OFFLINE UNKNOWN vmora02rh4
ora....H4.lsnr application OFFLINE UNKNOWN vmora02rh4
ora....rh4.gsd application ONLINE UNKNOWN vmora02rh4
ora....rh4.ons application OFFLINE UNKNOWN vmora02rh4
ora....rh4.vip application ONLINE ONLINE vmora02rh4

可以看见有一些应用程序的状态为UNKNOW或OFFLINE,这样是非正常的。

在手工关闭应用程序时可以使用crs_stat命令列出的应用程序名。

[oracle@vmora01rh4 bin]$ crs_stat
NAME=ora.fokerac.db
TYPE=application
TARGET=ONLINE
STATE=ONLINE on vmora02rh4

NAME=ora.fokerac.fokerac1.inst
TYPE=application
TARGET=ONLINE
STATE=ONLINE on vmora01rh4

NAME=ora.fokerac.fokerac2.inst
TYPE=application
TARGET=OFFLINE
STATE=OFFLINE

NAME=ora.fokerac.fokeserv.cs
TYPE=application
TARGET=ONLINE
STATE=ONLINE on vmora02rh4

NAME=ora.fokerac.fokeserv.fokerac1.srv
TYPE=application
TARGET=ONLINE
STATE=ONLINE on vmora01rh4

NAME=ora.fokerac.fokeserv.fokerac2.srv
TYPE=application
TARGET=ONLINE
STATE=OFFLINE

NAME=ora.vmora01rh4.ASM1.asm
TYPE=application
TARGET=ONLINE
STATE=ONLINE on vmora01rh4

NAME=ora.vmora01rh4.LISTENER_VMORA01RH4.lsnr
TYPE=application
TARGET=ONLINE
STATE=ONLINE on vmora01rh4

NAME=ora.vmora01rh4.gsd
TYPE=application
TARGET=ONLINE
STATE=UNKNOWN on vmora01rh4

NAME=ora.vmora01rh4.ons
TYPE=application
TARGET=ONLINE
STATE=UNKNOWN on vmora01rh4

NAME=ora.vmora01rh4.vip
TYPE=application
TARGET=ONLINE
STATE=ONLINE on vmora01rh4

NAME=ora.vmora02rh4.ASM2.asm
TYPE=application
TARGET=OFFLINE
STATE=UNKNOWN on vmora02rh4

NAME=ora.vmora02rh4.LISTENER_VMORA02RH4.lsnr
TYPE=application
TARGET=OFFLINE
STATE=UNKNOWN on vmora02rh4

NAME=ora.vmora02rh4.gsd
TYPE=application
TARGET=ONLINE
STATE=UNKNOWN on vmora02rh4

NAME=ora.vmora02rh4.ons
TYPE=application
TARGET=OFFLINE
STATE=UNKNOWN on vmora02rh4

NAME=ora.vmora02rh4.vip
TYPE=application
TARGET=ONLINE
STATE=ONLINE on vmora02rh4

可以使用crs_stop -all命令来一次性把它们全部停止掉,但通常会报一些错误,所以你可以手工的一个一个关闭它们。
oracle@vmora01rh4 bin]$ crs_stop -all
Attempting to stop `ora.vmora01rh4.ons` on member `vmora01rh4`
Attempting to stop `ora.vmora02rh4.ons` on member `vmora02rh4`
`ora.vmora02rh4.ons` on member `vmora02rh4` has experienced an unrecoverable failure.
Human intervention required to resume its availability.
Stop of `ora.vmora01rh4.ons` on member `vmora01rh4` succeeded.
Attempting to stop `ora.vmora01rh4.ASM1.asm` on member `vmora01rh4`
Attempting to stop `ora.fokerac.fokerac2.inst` on member `vmora02rh4`
`ora.fokerac.fokerac2.inst` on member `vmora02rh4` has experienced an unrecoverable failure.
Human intervention required to resume its availability.
Attempting to stop `ora.vmora02rh4.ASM2.asm` on member `vmora02rh4`
`ora.vmora02rh4.ASM2.asm` on member `vmora02rh4` has experienced an unrecoverable failure.
Human intervention required to resume its availability.
Attempting to stop `ora.vmora02rh4.LISTENER_VMORA02RH4.lsnr` on member `vmora02rh4`
`ora.vmora02rh4.LISTENER_VMORA02RH4.lsnr` on member `vmora02rh4` has experienced an unrecoverable failure.
Human intervention required to resume its availability.
Attempting to stop `ora.fokerac.fokerac2.inst` on member `vmora02rh4`
`ora.fokerac.fokerac2.inst` on member `vmora02rh4` has experienced an unrecoverable failure.
Human intervention required to resume its availability.
Attempting to stop `ora.vmora02rh4.ASM2.asm` on member `vmora02rh4`
`ora.vmora02rh4.ASM2.asm` on member `vmora02rh4` has experienced an unrecoverable failure.
Human intervention required to resume its availability.
Attempting to stop `ora.vmora02rh4.vip` on member `vmora02rh4`
Stop of `ora.vmora02rh4.vip` on member `vmora02rh4` succeeded.
Stop of `ora.vmora01rh4.ASM1.asm` on member `vmora01rh4` succeeded.
Attempting to stop `ora.vmora01rh4.LISTENER_VMORA01RH4.lsnr` on member `vmora01rh4`
Stop of `ora.vmora01rh4.LISTENER_VMORA01RH4.lsnr` on member `vmora01rh4` succeeded.
Attempting to stop `ora.vmora01rh4.vip` on member `vmora01rh4`
Stop of `ora.vmora01rh4.vip` on member `vmora01rh4` succeeded.
CRS-0216: Could not stop resource 'ora.vmora02rh4.ASM2.asm'.

CRS-0216: Could not stop resource 'ora.vmora02rh4.ons'.

CRS-0216: Could not stop resource 'ora.vmora02rh4.vip'.

看见了吗,报错了,所以我们还是要自己来。首先先停止实列。
[oracle@vmora01rh4 bin]$ srvctl stop instance -d fokerac -i fokerac1
[oracle@vmora01rh4 bin]$ srvctl stop instance -d fokerac -i fokerac2

再看一下状态:
[oracle@vmora01rh4 bin]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.fokerac.db application OFFLINE OFFLINE
ora....c1.inst application OFFLINE OFFLINE
ora....c2.inst application OFFLINE OFFLINE
ora....serv.cs application ONLINE UNKNOWN vmora02rh4
ora....ac1.srv application OFFLINE OFFLINE
ora....ac2.srv application OFFLINE OFFLINE
ora....SM1.asm application OFFLINE OFFLINE
ora....H4.lsnr application OFFLINE OFFLINE
ora....rh4.gsd application ONLINE UNKNOWN vmora01rh4
ora....rh4.ons application OFFLINE OFFLINE
ora....rh4.vip application OFFLINE OFFLINE
ora....SM2.asm application OFFLINE UNKNOWN vmora02rh4
ora....H4.lsnr application OFFLINE UNKNOWN vmora02rh4
ora....rh4.gsd application ONLINE UNKNOWN vmora02rh4
ora....rh4.ons application OFFLINE UNKNOWN vmora02rh4
ora....rh4.vip application OFFLINE OFFLINE

停止服务:
[oracle@vmora01rh4 bin]$ srvctl stop service -d fokerac -s fokeserv

再看一下状态:
[oracle@vmora01rh4 bin]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.fokerac.db application OFFLINE OFFLINE
ora....c1.inst application OFFLINE OFFLINE
ora....c2.inst application OFFLINE OFFLINE
ora....serv.cs application OFFLINE OFFLINE
ora....ac1.srv application OFFLINE OFFLINE
ora....ac2.srv application OFFLINE OFFLINE
ora....SM1.asm application OFFLINE OFFLINE
ora....H4.lsnr application OFFLINE OFFLINE
ora....rh4.gsd application ONLINE UNKNOWN vmora01rh4
ora....rh4.ons application OFFLINE OFFLINE
ora....rh4.vip application OFFLINE OFFLINE
ora....SM2.asm application OFFLINE UNKNOWN vmora02rh4
ora....H4.lsnr application OFFLINE UNKNOWN vmora02rh4
ora....rh4.gsd application ONLINE UNKNOWN vmora02rh4
ora....rh4.ons application OFFLINE UNKNOWN vmora02rh4
ora....rh4.vip application OFFLINE OFFLINE

好,现在停止这些应用程序。
[oracle@vmora01rh4 bin]$ crs_stop ora.vmora01rh4.gsd
Attempting to stop `ora.vmora01rh4.gsd` on member `vmora01rh4`
Stop of `ora.vmora01rh4.gsd` on member `vmora01rh4` succeeded.

[oracle@vmora01rh4 bin]$ crs_stop ora.vmora02rh4.ASM2.asm
Attempting to stop `ora.vmora02rh4.ASM2.asm` on member `vmora02rh4`
Stop of `ora.vmora02rh4.ASM2.asm` on member `vmora02rh4` succeeded.

[oracle@vmora01rh4 bin]$ crs_stop ora.vmora02rh4.LISTENER_VMORA02RH4.lsnr
Attempting to stop `ora.vmora02rh4.LISTENER_VMORA02RH4.lsnr` on member `vmora02rh4`
Stop of `ora.vmora02rh4.LISTENER_VMORA02RH4.lsnr` on member `vmora02rh4` succeeded.

[oracle@vmora01rh4 bin]$ crs_stop ora.vmora02rh4.gsd
Attempting to stop `ora.vmora02rh4.gsd` on member `vmora02rh4`
Stop of `ora.vmora02rh4.gsd` on member `vmora02rh4` succeeded.

[oracle@vmora01rh4 bin]$ crs_stop ora.vmora02rh4.ons
Attempting to stop `ora.vmora02rh4.ons` on member `vmora02rh4`
Stop of `ora.vmora02rh4.ons` on member `vmora02rh4` succeeded.

看一下状态:
[oracle@vmora01rh4 bin]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.fokerac.db application OFFLINE OFFLINE
ora....c1.inst application OFFLINE OFFLINE
ora....c2.inst application OFFLINE OFFLINE
ora....serv.cs application OFFLINE OFFLINE
ora....ac1.srv application OFFLINE OFFLINE
ora....ac2.srv application OFFLINE OFFLINE
ora....SM1.asm application OFFLINE OFFLINE
ora....H4.lsnr application OFFLINE OFFLINE
ora....rh4.gsd application OFFLINE OFFLINE
ora....rh4.ons application OFFLINE OFFLINE
ora....rh4.vip application OFFLINE OFFLINE
ora....SM2.asm application OFFLINE OFFLINE
ora....H4.lsnr application OFFLINE OFFLINE
ora....rh4.gsd application OFFLINE OFFLINE
ora....rh4.ons application OFFLINE OFFLINE
ora....rh4.vip application OFFLINE OFFLINE

好了。 现在再把它们全部online.
[oracle@vmora01rh4 bin]$ crs_start -all
Attempting to start `ora.vmora02rh4.vip` on member `vmora02rh4`
Attempting to start `ora.vmora01rh4.vip` on member `vmora01rh4`
Start of `ora.vmora02rh4.vip` on member `vmora02rh4` succeeded.
Start of `ora.vmora01rh4.vip` on member `vmora01rh4` succeeded.
Attempting to start `ora.vmora01rh4.ASM1.asm` on member `vmora01rh4`
Attempting to start `ora.vmora02rh4.ASM2.asm` on member `vmora02rh4`
Start of `ora.vmora02rh4.ASM2.asm` on member `vmora02rh4` succeeded.
Attempting to start `ora.fokerac.fokerac2.inst` on member `vmora02rh4`
Start of `ora.vmora01rh4.ASM1.asm` on member `vmora01rh4` succeeded.
Attempting to start `ora.fokerac.fokerac1.inst` on member `vmora01rh4`
Start of `ora.fokerac.fokerac2.inst` on member `vmora02rh4` succeeded.
Attempting to start `ora.vmora02rh4.LISTENER_VMORA02RH4.lsnr` on member `vmora02rh4`
Start of `ora.fokerac.fokerac1.inst` on member `vmora01rh4` succeeded.
Attempting to start `ora.vmora01rh4.LISTENER_VMORA01RH4.lsnr` on member `vmora01rh4`
Start of `ora.vmora02rh4.LISTENER_VMORA02RH4.lsnr` on member `vmora02rh4` succeeded.
Start of `ora.vmora01rh4.LISTENER_VMORA01RH4.lsnr` on member `vmora01rh4` succeeded.
CRS-1002: Resource 'ora.vmora02rh4.ons' is already running on member 'vmora02rh4'

CRS-1002: Resource 'ora.vmora01rh4.ons' is already running on member 'vmora01rh4'

Attempting to start `ora.fokerac.fokeserv.fokerac1.srv` on member `vmora01rh4`
Attempting to start `ora.vmora01rh4.gsd` on member `vmora01rh4`
Attempting to start `ora.fokerac.db` on member `vmora01rh4`
Attempting to start `ora.fokerac.fokeserv.fokerac2.srv` on member `vmora02rh4`
Attempting to start `ora.fokerac.fokeserv.cs` on member `vmora02rh4`
Attempting to start `ora.vmora02rh4.gsd` on member `vmora02rh4`
Start of `ora.fokerac.fokeserv.fokerac2.srv` on member `vmora02rh4` succeeded.
Start of `ora.fokerac.fokeserv.cs` on member `vmora02rh4` succeeded.
Start of `ora.fokerac.db` on member `vmora01rh4` succeeded.
Start of `ora.vmora02rh4.gsd` on member `vmora02rh4` succeeded.
Start of `ora.vmora01rh4.gsd` on member `vmora01rh4` succeeded.
Start of `ora.fokerac.fokeserv.fokerac1.srv` on member `vmora01rh4` succeeded.
*CRS-0223: Resource 'ora.vmora01rh4.ons' has placement error.

CRS-0223: Resource 'ora.vmora02rh4.ons' has placement error.

那些错误可以忽略,集群件会把它们一个个按顺序启动的。
再看一下:
[oracle@vmora01rh4 bin]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.fokerac.db application ONLINE ONLINE vmora01rh4
ora....c1.inst application ONLINE ONLINE vmora01rh4
ora....c2.inst application ONLINE ONLINE vmora02rh4
ora....serv.cs application ONLINE ONLINE vmora02rh4
ora....ac1.srv application ONLINE ONLINE vmora01rh4
ora....ac2.srv application ONLINE ONLINE vmora02rh4
ora....SM1.asm application ONLINE ONLINE vmora01rh4
ora....H4.lsnr application ONLINE ONLINE vmora01rh4
ora....rh4.gsd application ONLINE ONLINE vmora01rh4
ora....rh4.ons application ONLINE ONLINE vmora01rh4
ora....rh4.vip application ONLINE ONLINE vmora01rh4
ora....SM2.asm application ONLINE ONLINE vmora02rh4
ora....H4.lsnr application ONLINE ONLINE vmora02rh4
ora....rh4.gsd application ONLINE ONLINE vmora02rh4
ora....rh4.ons application ONLINE ONLINE vmora02rh4
ora....rh4.vip application ONLINE ONLINE vmora02rh4
好了。都online了。

 

 

 

http://joelau.spaces.live.com/blog/cns!19b1d65418d95a1b!378.entry

 

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

请登录后发表评论 登录
全部评论
Oracle , MySQL, SAP IQ, SAP HANA, PostgreSQL, Tableau 技术讨论,希望在这里一起分享知识,讨论技术,畅谈人生 。

注册时间:2007-12-10

  • 博文量
    5595
  • 访问量
    13267443