11.2.0.3重新配置OHAS(Oracle High Availability Services)服务.(单实例ASM)

11gR2要创建基于ASM的单实例数据库,首先需要安装Grid Infrastructure软件,只需要安装软件就行了,装完软件我们就可以使用ASMCA,ASMCMD等工具创建ASM卷组.接下来我们安装单机版的数据库,建库的时候选择ASM卷组就行.整个装完之后,我们可以登录到Grid用户下查看.如下所示:

[grid@asm ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       asm
ora.LISTENER.lsnr
               ONLINE  ONLINE       asm
ora.asm
               ONLINE  ONLINE       asm                      Started
ora.ons
               ONLINE  ONLINE       asm
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       asm
ora.diskmon
      1        OFFLINE OFFLINE
ora.evmd
      1        ONLINE  ONLINE       asm
ora.orcl.db
      1        ONLINE  ONLINE       asm                      Open

可以看到有以下resource.这里需要说明的是ora.diskmon这个resource,这个资源在11.2.0.3的非Exadata环境下,已经不在需要了.因为这个进程是Exadata负责I/O防护的进程.那么接下就写一下把OHAS删除后怎么重新进行配置.

1.停止OHAS服务.

[grid@asm ~]$ crsctl check has
CRS-4638: Oracle High Availability Services is online
[grid@asm ~]$ crsctl stop has
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'asm'
CRS-2673: Attempting to stop 'ora.orcl.db' on 'asm'
CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'asm'
CRS-2677: Stop of 'ora.LISTENER.lsnr' on 'asm' succeeded
CRS-2677: Stop of 'ora.orcl.db' on 'asm' succeeded
CRS-2673: Attempting to stop 'ora.DATA.dg' on 'asm'
CRS-2677: Stop of 'ora.DATA.dg' on 'asm' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'asm'
CRS-2677: Stop of 'ora.asm' on 'asm' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'asm'
CRS-2677: Stop of 'ora.cssd' on 'asm' succeeded
CRS-2673: Attempting to stop 'ora.ons' on 'asm'
CRS-2673: Attempting to stop 'ora.evmd' on 'asm'
CRS-2677: Stop of 'ora.ons' on 'asm' succeeded
CRS-2677: Stop of 'ora.evmd' on 'asm' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'asm' has completed
CRS-4133: Oracle High Availability Services has been stopped.
[grid@asm ~]$ crsctl check has
CRS-4639: Could not contact Oracle High Availability Services

2.登录到root用户移除OHAS配置.这里我们需要到Grid用户的$ORACLE_HOME下去运行roothas.pl脚本.

[root@asm ~]# /oracle/app/11.2.0/grid/crs/install/roothas.pl -deconfig -force
Using configuration parameter file: /oracle/app/11.2.0/grid/crs/install/crsconfig_params
CRS-4639: Could not contact Oracle High Availability Services
CRS-4000: Command Stop failed, or completed with errors.
CRS-4639: Could not contact Oracle High Availability Services
CRS-4000: Command Delete failed, or completed with errors.
CRS-4544: Unable to connect to OHAS
CRS-4000: Command Stop failed, or completed with errors.
Successfully deconfigured Oracle Restart stack

3.登录到root用户运行roothas.pl重新进行配置.同样该脚本位于Grid用户的$ORACLE_HOME下.

[grid@asm ~]$ crsctl check has
CRS-4047: No Oracle Clusterware components configured.
CRS-4000: Command Check failed, or completed with errors.
[root@asm ~]# cd /oracle/app/11.2.0/grid/crs/install
[root@asm install]# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
[root@asm install]# ./roothas.pl
Using configuration parameter file: ./crsconfig_params
LOCAL ADD MODE
Creating OCR keys for user 'grid', privgrp 'oinstall'..
Operation successful.
LOCAL ONLY MODE
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
CRS-4664: Node asm successfully pinned.
Adding Clusterware entries to inittab

asm 2012/03/15 04:47:55 /oracle/app/11.2.0/grid/cdata/asm/backup_20120315_044755.olr
Successfully configured Oracle Grid Infrastructure for a Standalone Server

4. 进入Grid用户下查看resource状态,把资源状态设置成AUTOSTART

[grid@asm ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ons
               OFFLINE OFFLINE      asm
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        OFFLINE OFFLINE
ora.diskmon
      1        OFFLINE OFFLINE
ora.evmd
      1        ONLINE  ONLINE       asm    [/java]
这里可以看到除了ora.diskmon资源我们不需要处理外,ora.cssd和ora.ons都是offine的.我们进行下列修改,让这些服务能够自动启动起来. [java][/java][grid@asm ~]$ crsctl modify resource "ora.cssd" -attr "AUTO_START=1" [grid@asm ~]$ srvctl enable ons

重启OHAS,再次查询,这些服务已经是自动启动了.

[grid@asm ~]$ crsctl stop has
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'asm'
CRS-2673: Attempting to stop 'ora.evmd' on 'asm'
CRS-2677: Stop of 'ora.evmd' on 'asm' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'asm' has completed
CRS-4133: Oracle High Availability Services has been stopped.
[grid@asm ~]$ crsctl start has
CRS-4123: Oracle High Availability Services has been started.
[grid@asm ~]$ crsctl status res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ons
               ONLINE  ONLINE       asm
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       asm
ora.diskmon
      1        OFFLINE OFFLINE
ora.evmd
      1        ONLINE  ONLINE       asm

5.添加ora.asm服务.提供对asm实例的管理.
在这里我们需要找到我们asm实例的spfile文件,此时ASM实例是关闭的,我们没有办法看到我们的spfile文件存放的位置,于此同时我们的asmcmd命令也不可以使用,我只能通过asm的alter日志来寻找spfile文件存放的路径.

[grid@asm trace]$ pwd
/oracle/app/grid/diag/asm/+asm/+ASM/trace
[grid@asm trace]$ cat alert_+ASM.log | grep spfile
Using parameter settings in server-side spfile +DATA/asm/asmparameterfile/registry.253.777951757
Diskgroup with spfile:DATA

这里我找到了我的spfile文件的路径,于是我手动进行asm资源的添加.

[grid@asm trace]$ srvctl add asm -p +DATA/asm/asmparameterfile/registry.253.777951757
[grid@asm trace]$ srvctl start asm
[grid@asm trace]$ crsctl status res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.asm
               ONLINE  ONLINE       asm                      Started
ora.ons
               ONLINE  ONLINE       asm
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       asm
ora.diskmon
      1        OFFLINE OFFLINE
ora.evmd
      1        ONLINE  ONLINE       asm

6.手动mount卷组.
此时我们可以发现卷组资源ora.DATA.dg是不存在的,此时我们用asmcmd命令进去是看不到任何东西的.我们需要手动mount卷组,mount完成之后,会自动加载卷组资源.

[grid@asm dbs]$ asmcmd
ASMCMD> ls
ASMCMD> exit
[grid@asm dbs]$ sqlplus / as sysasm

SQL*Plus: Release 11.2.0.3.0 Production on Thu Mar 15 05:38:47 2012

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Automatic Storage Management option

SQL> select name,state from v$asm_diskgroup;
NAME STATE
----------- --------------------
DATA DISMOUNTED
SQL> alter diskgroup data mount;
Diskgroup altered.
[grid@asm dbs]$ crsctl stop has
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'asm'
CRS-2673: Attempting to stop 'ora.DATA.dg' on 'asm'
CRS-2677: Stop of 'ora.DATA.dg' on 'asm' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'asm'
CRS-2677: Stop of 'ora.asm' on 'asm' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'asm'
CRS-2677: Stop of 'ora.cssd' on 'asm' succeeded
CRS-2673: Attempting to stop 'ora.ons' on 'asm'
CRS-2673: Attempting to stop 'ora.evmd' on 'asm'
CRS-2677: Stop of 'ora.ons' on 'asm' succeeded
CRS-2677: Stop of 'ora.evmd' on 'asm' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'asm' has completed
CRS-4133: Oracle High Availability Services has been stopped.
[grid@asm dbs]$ crsctl start has
CRS-4123: Oracle High Availability Services has been started.
[grid@asm dbs]$ crsctl status res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       asm
ora.asm
               ONLINE  ONLINE       asm                      Started
ora.ons
               ONLINE  ONLINE       asm
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       asm
ora.diskmon
      1        OFFLINE OFFLINE
ora.evmd
      1        ONLINE  ONLINE       asm

7.添加数据库到集群

在添加之前,我们首要要找到数据库的spfile文件.

[grid@asm ~]$ asmcmd
ASMCMD> ls
DATA/
ASMCMD> cd DATA
ASMCMD> ls
ASM/
ORCL/
ASMCMD> cd ORCL
ASMCMD> pwd
+DATA/ORCL
ASMCMD> ls -l spfileorcl.ora
Type Redund Striped Time Sys Name
N spfileorcl.ora => +DATA/ORCL/PARAMETERFILE/spfile.267.777943741

路径是+DATA/ORCL/spfileorcl.ora,这里要注意大小写.添加数据库需要切换到oracle用户下面运行.

[root@asm ~]# su - oracle
[oracle@asm ~]$ srvctl add database -h
Adds a database configuration to be managed by Oracle Restart.
Usage: srvctl add database -d <db_unique_name> -o <oracle_home> [-m <domain_name>] [-p <spfile>] [-r {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY | SNAPSHOT_STANDBY}] [-s <start_options>] [-t <stop_options>] [-n <db_name>] [-i <inst_name>] [-y {AUTOMATIC | MANUAL | NORESTART}] [-a "<diskgroup_list>"]
-d <db_unique_name> Unique name for the database
-o <oracle_home> ORACLE_HOME path
-m <domain> Domain for database. Must be set if database has DB_DOMAIN set.
-p <spfile> Server parameter file path
-r <role> Role of the database (primary, physical_standby, logical_standby, snapshot_standby)
-s <start_options> Startup options for the database. Examples of startup options are OPEN, MOUNT, or 'READ ONLY'.
-t <stop_options> Stop options for the database. Examples of shutdown options are NORMAL, TRANSACTIONAL, IMMEDIATE, or ABORT.
-n <db_name> Database name (DB_NAME), if different from the unique name given by the -d option
-i <inst_name> Instance name
-y <dbpolicy> Management policy for the database (AUTOMATIC, MANUAL, or NORESTART)
-a "<diskgroup_list>" Comma separated list of disk groups
-h Print usage
[oracle@asm ~]$ srvctl add database -d orcl -n orcl -o /oracle/app/oracle/product/11.2.0/db_1/ -p +DATA/ORCL/spfileorcl.ora -s OPEN -y AUTOMATIC -a "DATA" -t IMMEDIATE

添加完成之后,我们可以修改属性让数据库跟随集群启动自动启动.

[oracle@asm ~]$ crsctl status res ora.orcl.db -p | grep AUTO_START
AUTO_START=restore
[oracle@asm ~]$ crsctl modify resource "ora.orcl.db" -attr "AUTO_START=1"

8.添加监听.
这里切换到grid用户下面,然后添加了一个监听.

[root@asm ~]# su - grid
[grid@asm ~]$ srvctl add listener -h
Adds a listener configuration to be managed by Oracle Restart.
Usage: srvctl add listener [-l <lsnr_name>] [-s] [-p "[TCP:]<port>[, ...][/IPC:<key>][/NMP:<pipe_name>][/TCPS:<s_port>] [/SDP:<port>]"] [-o <oracle_home>]
-l <lsnr_name> Listener name (default name is LISTENER)
-o <oracle_home> ORACLE_HOME path (default value is CRS_HOME)
-s Skip the checking of ports
-p "[TCP:]<port>[, ...][/IPC:<key>][/NMP:<pipe_name>][/TCPS:<s_port>] [/SDP:<port>]" Comma separated tcp ports or listener endpoints
-h Print usage
[grid@asm ~]$ srvctl add listener -l LISTENER -p TCP:1521 -o /oracle/app/11.2.0/grid/

至此,所有资源添加都已经结束.可以尝试停止OHAS,然后在重启OHAS,查看各个资源是否正常启动.

[grid@asm ~]$ crsctl stop has
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'asm'
CRS-2673: Attempting to stop 'ora.DATA.dg' on 'asm'
CRS-2677: Stop of 'ora.DATA.dg' on 'asm' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'asm'
CRS-2677: Stop of 'ora.asm' on 'asm' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'asm'
CRS-2677: Stop of 'ora.cssd' on 'asm' succeeded
CRS-2673: Attempting to stop 'ora.evmd' on 'asm'
CRS-2673: Attempting to stop 'ora.ons' on 'asm'
CRS-2677: Stop of 'ora.ons' on 'asm' succeeded
CRS-2677: Stop of 'ora.evmd' on 'asm' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'asm' has completed
CRS-4133: Oracle High Availability Services has been stopped.
[grid@asm ~]$ crsctl start has
CRS-4123: Oracle High Availability Services has been started.
[grid@asm ~]$ crsctl status res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       asm
ora.LISTENER.lsnr
               ONLINE  ONLINE       asm
ora.asm
               ONLINE  ONLINE       asm                      Started
ora.ons
               ONLINE  ONLINE       asm
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       asm
ora.diskmon
      1        OFFLINE OFFLINE
ora.evmd
      1        ONLINE  ONLINE       asm
ora.orcl.db
      1        ONLINE  ONLINE       asm                      Open

分享到: 更多

Post a Comment

Your email is never published nor shared. Required fields are marked *