Oracle数据库数据恢复、性能优化

找回密码
注册
搜索
热搜: 活动 交友 discuz
发新帖

999

积分

1

好友

942

主题
1#
发表于 2013-11-17 16:52:58 | 查看: 2757| 回复: 1
如何在11.2集群中添加/删除资源?


    在11.2,数据库、监听、VIP、ASM、磁盘组等都属于GI所管理的资源,有的时候需要添加、删除、修改资源属性等,都是使用crsctl命令来操作的。
     注意在集群中添加和删除资源只是将它从OCR中注册或者移除,并不是真正的将这个资源删掉。比如diskgroup这个资源,用crsctl add/delete并不会把这个磁盘组删除。

       下面列出了GI所管理的资源:
-bash-3.00$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS      
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       rac1                                    
               ONLINE  ONLINE       rac2                                    
ora.LISTENER.lsnr
               ONLINE  ONLINE       rac1                                    
               ONLINE  OFFLINE      rac2                                    
ora.OCR_VOTE.dg
               ONLINE  ONLINE       rac1                                    
               ONLINE  ONLINE       rac2                                    
ora.RECO.dg
               ONLINE  ONLINE       rac1                                    
               ONLINE  ONLINE       rac2                                    
ora.asm
               ONLINE  ONLINE       rac1                 Started            
               ONLINE  ONLINE       rac2                 Started            
ora.gsd
               ONLINE  OFFLINE      rac1                                    
               ONLINE  OFFLINE      rac2                                    
ora.net1.network
               ONLINE  ONLINE       rac1                                    
               ONLINE  OFFLINE      rac2                                    
ora.ons
               ONLINE  ONLINE       rac1                                    
               ONLINE  OFFLINE      rac2                                    
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       rac1                                    
ora.cvu
      1        ONLINE  ONLINE       rac1                                    
ora.rac1.vip
      1        ONLINE  ONLINE       rac1                                    
ora.rac2.vip
      1        ONLINE  INTERMEDIATE rac1                 FAILED OVER         
ora.oc4j
      1        ONLINE  ONLINE       rac1                                    
ora.rac11g2.db
      1        ONLINE  ONLINE       rac1                 Open               
      2        ONLINE  ONLINE       rac2                 Open               
ora.scan1.vip
      1        ONLINE  ONLINE       rac1                          

官方文档中有添加、删除、修改资源的详细命令和解释:
http://docs.oracle.com/cd/E11882_01/rac.112/e16794/crsref.htm#CHDFEFBJ
Oracle Clusterware Administration and Deployment Guide
11g Release 2 (11.2)
E16794-17

添加资源:
crsctl add resource resource_name -type resource_type [-file file_path |

[-i] [-f]

resource_name A short, descriptive name for the resource. (
resource_name: 资源名)
-type resource_type The type of resource that you are adding preceded by the -type flag.(-type 资源类型)
-file file_path Path name (either absolute or relative) for a text file containing line-separated attribute name-value pairs that define the resource.
-attr "attribute_name= attribute_value (-attr: 资源属性以及对应的值,不同类型的资源对应的属性不同)
-i If you specify -i, then the command returns an error if processing this command requires waiting for Oracle Clusterware to unlock the resource or its dependents. Sometimes, Oracle Clusterware locks resources or other objects to prevent commands from interfering with each other.
-f Use the force option:(-f : 强制添加,忽略依赖性)
    To add a resource that has dependencies on other resources that do not yet exist. The force option overrides checks that would prevent a command from being completed.
    To add a resource if the resource has hard dependencies on other resources and the owner of the resources does not execute permissions on one or more of the dependencies. If you do not specify the force option in this case, an error displays.
    To add resources of application type because you may need to move servers into the Generic server pool. If the servers currently host resources that must be stopped, then the force option is required

删除资源:
crsctl delete resource resource_name [-i] [-f]

resource_name Specify the name of the resource you want to remove.
-i If you specify -i, then the command returns an error if processing this command requires waiting for Oracle Clusterware to unlock the resource or its dependents. Sometimes, Oracle Clusterware locks resources or other objects to prevent commands from interfering with each other.
-f Use the force option to remove either running resources, or remove this resource even though other resources have a hard dependency on it.(-f 强制删除,即使这个资源在运行或者有其他资源依赖于它)


下载专业ORACLE数据库恢复工具PRM-DUL  For Oracle http://www.parnassusdata.com/

如果自己搞不定可以找诗檀软件专业ORACLE数据库修复团队成员帮您恢复!

诗檀软件专业数据库修复团队

服务热线 : 13764045638  QQ: 47079569     邮箱:service@parnassusdata.com
2#
发表于 2013-11-17 16:53:14
修改资源:
crsctl modify resource resource_name -attr "attribute_name=attribute_value"
[-i] [-f] [-delete]

resource_name The name of the resource you want to modify.
-attr "attribute_name=attribute_value"
-i If you specify -i, then the command returns an error if processing this command requires waiting for Oracle Clusterware to unlock the resource or its dependents. Sometimes, Oracle Clusterware locks resources or other objects to prevent commands from interfering with each other.
-f Use the -f option when:
    The resource has a hard dependency on a non-existing resource
    The owner of the resource does not have execute permissions on one or more hard dependencies
    The modification results in servers being moved into the Generic pool and resources being stopped or relocated to accomplish the server move
-delete If you specify the -delete option, then Oracle Clusterware deletes the named attribute.

下面是在11.2.0.3上删除和添加diskgroup ora.RECO.dg的例子:

主要用到的命令:
su - grid

1. 停止依赖于磁盘组ora.RECO.dg的所有数据库:
$ srvctl stop database -d <db_name>

2. 查看ora.RECO.dg的配置信息:
-bash-3.00$ crsctl stat  res ora.RECO.dg -p   
NAME=ora.RECO.dg                                                         
TYPE=ora.diskgroup.type                                                   
ACL=owner:grid:rwx,pgrp:oinstall:rwx,other::r-- <===这个信息在添加资源的使用需要                           
...
VERSION=11.2.0.3.0   

3. 停止ora.RECO.dg:
-bash-3.00$ crsctl stop  res ora.RECO.dg -f                           

4. 从集群中移除ora.RECO.dg:
-bash-3.00$ crsctl delete  res ora.RECO.dg -f  

5. 将ora.RECO.dg添加到集群中:
-bash-3.00$ crsctl add  res ora.RECO.dg -type ora.diskgroup.type -attr "ACL='owner:grid:rwx,pgrp:oinstall:rwx,other::r-
-',AUTO_START=always,VERSION=11.2.0.3.0" -i

6. 检查资源的配置信息是正确的:
-bash-3.00$ crsctl stat  res ora.RECO.dg -p

7. 将这个资源启动:
-bash-3.00$ crsctl start  res ora.RECO.dg        
-bash-3.00$ crsctl stat  res -t

8. 启动所有依赖于这个磁盘组的数据库:
$ srvctl start database -d <db_name>

具体的测试过程及输出:

su - grid

1. 停止依赖于磁盘组ora.RECO.dg的所有数据库:
$ srvctl stop database -d RAC11G2

2. 查看ora.RECO.dg的配置信息:

-bash-3.00$ crsctl stat  res ora.RECO.dg -p                                
NAME=ora.RECO.dg                                                         
TYPE=ora.diskgroup.type                                                   
ACL=owner:grid:rwx,pgrp:oinstall:rwx,other::r--                           
ACTION_FAILURE_TEMPLATE=                                                  
ACTION_SCRIPT=                                                            
AGENT_FILENAME=%CRS_HOME%/bin/oraagent%CRS_EXE_SUFFIX%                    
ALIAS_NAME=                                                               
AUTO_START=always                                                         
CHECK_INTERVAL=300                                                        
CHECK_TIMEOUT=30                                                         
DEFAULT_TEMPLATE=                                                         
DEGREE=1                                                                  
DESCRIPTION=CRS resource type definition for ASM disk group resource      
ENABLED=1                                                                  
LOAD=1                                                                    
LOGGING_LEVEL=1                                                            
NLS_LANG=                                                                  
NOT_RESTARTING_TEMPLATE=                                                  
OFFLINE_CHECK_INTERVAL=0                                                  
PROFILE_CHANGE_TEMPLATE=                                                  
RESTART_ATTEMPTS=5                                                        
SCRIPT_TIMEOUT=60                                                         
START_DEPENDENCIES=hard(ora.asm) pullup(ora.asm)                          
START_TIMEOUT=900                                                         
STATE_CHANGE_TEMPLATE=                                                   
STOP_DEPENDENCIES=hard(intermediate:ora.asm)                              
STOP_TIMEOUT=180                                                         
TYPE_VERSION=1.2                                                         
UPTIME_THRESHOLD=1d                                                        
USR_ORA_ENV=                                                              
USR_ORA_OPI=false                                                         
USR_ORA_STOP_MODE=                                                        
VERSION=11.2.0.3.0                                                        

3. 停止ora.RECO.dg:
-bash-3.00$ crsctl stop  res ora.RECO.dg -f                           
CRS-2673: Attempting to stop 'ora.RECO.dg' on 'rac2'              
CRS-2673: Attempting to stop 'ora.RECO.dg' on 'rac1'              
CRS-2677: Stop of 'ora.RECO.dg' on 'rac2' succeeded               
CRS-2677: Stop of 'ora.RECO.dg' on 'rac1' succeeded               

4. 从集群中移除ora.RECO.dg:
-bash-3.00$ crsctl delete  res ora.RECO.dg   <==如果有不加-f, 当有资源依赖于这个磁盘组时会报错                          
CRS-2730: Resource 'ora.rac11g2.db' depends on resource 'ora.RECO.dg'   
CRS-4000: Command Delete failed, or completed with errors.            

-bash-3.00$ crsctl delete  res ora.RECO.dg -f      <=====需要使用-f来强制删除

5. 将ora.RECO.dg添加到集群中:
-bash-3.00$ crsctl add  res ora.RECO.dg -type ora.diskgroup.type -attr "ACL='owner:grid:rwx,pgrp:oinstall:rwx,other::r-

-',AUTO_START=always,VERSION=11.2.0.3.0" -i

6. 检查资源的配置信息是正确的:

-bash-3.00$ crsctl stat  res ora.RECO.dg -p
NAME=ora.RECO.dg
TYPE=ora.diskgroup.type
ACL=owner:grid:rwx,pgrp:oinstall:rwx,other::r--
ACTION_FAILURE_TEMPLATE=
ACTION_SCRIPT=
AGENT_FILENAME=%CRS_HOME%/bin/oraagent%CRS_EXE_SUFFIX%
ALIAS_NAME=
AUTO_START=always
CHECK_INTERVAL=300
CHECK_TIMEOUT=30
DEFAULT_TEMPLATE=
DEGREE=1
DESCRIPTION=CRS resource type definition for ASM disk group resource
ENABLED=1
LOAD=1
LOGGING_LEVEL=1
NLS_LANG=
NOT_RESTARTING_TEMPLATE=
OFFLINE_CHECK_INTERVAL=0
PROFILE_CHANGE_TEMPLATE=
RESTART_ATTEMPTS=5
SCRIPT_TIMEOUT=60
START_DEPENDENCIES=hard(ora.asm) pullup(ora.asm)
START_TIMEOUT=900
STATE_CHANGE_TEMPLATE=
STOP_DEPENDENCIES=hard(intermediate:ora.asm)
STOP_TIMEOUT=180
TYPE_VERSION=1.2
UPTIME_THRESHOLD=1d
USR_ORA_ENV=
USR_ORA_OPI=false
USR_ORA_STOP_MODE=
VERSION=11.2.0.3.0

7. 将这个资源启动:
-bash-3.00$ crsctl start  res ora.RECO.dg        
CRS-2672: Attempting to start 'ora.RECO.dg' on 'rac1'
CRS-2672: Attempting to start 'ora.RECO.dg' on 'rac2'
CRS-2676: Start of 'ora.RECO.dg' on 'rac1' succeeded
CRS-2676: Start of 'ora.RECO.dg' on 'rac2' succeeded

-bash-3.00$ crsctl stat  res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       Local Resources
--------------------------------------------------------------------------------
ora.RECO.dg
              ONLINE  ONLINE       rac1                                    
              ONLINE  ONLINE       rac2                                    

8.启动所有依赖于这个磁盘组的数据库:
$ srvctl start database -d RAC11G2

参与此主题的后续讨论,可以访问我们的中文社区,跟帖“如何在11.2集群中添加/删除资源?"。

回复 只看该作者 道具 举报

您需要登录后才可以回帖 登录 | 注册

QQ|手机版|Archiver|Oracle数据库数据恢复、性能优化

GMT+8, 2024-6-15 17:13 , Processed in 0.048789 second(s), 20 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部
TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569