Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6683668
  • 博文数量: 1005
  • 博客积分: 8199
  • 博客等级: 中将
  • 技术积分: 13071
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-25 20:19
个人简介

脚踏实地、勇往直前!

文章分类

全部博文(1005)

文章存档

2020年(2)

2019年(93)

2018年(208)

2017年(81)

2016年(49)

2015年(50)

2014年(170)

2013年(52)

2012年(177)

2011年(93)

2010年(30)

分类: Oracle

2012-03-22 19:53:57

使用srvctl管理RAC数据库
$./srvctl
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 -h
 
- i:实例名 如devdb1
- d:数据库名如devdb
- n:节点名如rac1
- s:服务名 如devdb
 
一、常用命令
1.crs_stat -t --查看各节点状态
2.srvctl status asm -n rac1-- 查看节点1上asm实例的状态
3.srvctl status asm -n rac2-- 查看节点2上asm实例的状态
4.export ORACLE_SID=+ASM2
  sqlplus /nolog
  connect / as sysdba
  startup                   -- 启动节点2上的ASM实例
 
5.停止 Oracle RAC 10g 环境
第一步是停止Oracle实例.当此实例(和相关服务)关闭后,关闭ASM实例.
最后,关闭节点应用程序(虚拟IP,GSD,TNS 监听器和 ONS).
  export ORACLE_SID=devdb1
  emctl stop dbconsole
  srvctl stop instance -d devdb -i devdb1
  srvctl stop asm -n rac1
  srvctl stop nodeapps -n rac1
 
关闭监听器
node1-> srvctl stop listener -n node1
node1-> srvctl stop listener -n node2
关闭数据库
node2-> srvctl stop database -d racdb
关闭asm
node1-> srvctl stop asm -n node1
node1-> srvctl stop asm -n node2
关闭资源
node1-> srvctl stop nodeapps -n node1
node1-> srvctl stop nodeapps -n node2
关闭crs
[root@node1 ~]# /etc/init.d/init.crs stop
[root@node2 ~]# /etc/init.d/init.crs stop

6.启动 Oracle RAC 10g 环境
第一步是启动节点应用程序(虚拟IP,GSD,TNS监听器和ONS)
当成功启动节点应用程序后,启动 ASM 实例.
最后,启动 Oracle 实例(和相关服务)以及企业管理器数据库控制台.
  export ORACLE_SID=devdb1
  srvctl start nodeapps -n rac1
  srvctl start asm -n rac1
  srvctl start instance -d devdb -i devdb1
  emctl start dbconsole
 
7.使用SRVCTL启动/停止所有实例
  srvctl start database -d devdb
  srvctl stop database -d devdb
 
8.单个实例的状态
  srvctl status instance -d devdb -i devdb1
 
9.在数据库全局命名服务的状态
 srvctl status service -d devdb -s orcltest
 
10.特定节点上节点应用程序的状态

[oracle@rac1 ~]$ srvctl status nodeapps -n rac1
VIP is running on node: rac1
GSD is running on node: rac1
Listener is running on node: rac1
ONS daemon is running on node: rac1
 
11.检查crs的健康情况
  crsctl check crs
 

12.显示所有节点的私有、VIP名及节点名

$olsnodes -n -p -i
rac1    1       rac1-priv       rac1-vip.mycorpdomain.com
rac2    2       rac2-priv       rac2-vip.mycorpdomain.com

13.查看节点应用程序(VIP、GSD、Listener、ONS)的配置

$./srvctl config nodeapps -h
Usage: srvctl config nodeapps -n [-a] [-g] [-o] [-s] [-l]
    -n            Node name
    -a                  Display VIP configuration
    -g                  Display GSD configuration
    -s                  Display ONS daemon configuration
    -l                  Display listener configuration
    -h                  Print usage

[oracle@rac1 srvm]$ srvctl config nodeapps -n rac1
rac1 devdb1 /u01/app/oracle/product/10.2.0/db_1

[oracle@rac1 srvm]$ srvctl config nodeapps -n rac1 -a -g -s -l
VIP exists.: /rac1-vip.mycorpdomain.com/192.168.2.31/255.255.255.0/eth0
GSD exists.
ONS daemon exists.
Listener exists.

14.Voting Disk(表决磁盘方面)
查看Voting Disk位置:
$crsctl query css votedisk
 0.     0    /ocfs/clusterware/votingdisk
located 1 votedisk(s).
 
[oracle@rac1 ~]$ ll /ocfs/clusterware/votingdisk
-rw-r--r-- 1 oracle oinstall 10240000 Mar 26 21:14 /ocfs/clusterware/votingdisk
 
如果需要更改Voting Disk的配置,对Voting Disk的更改必须以root用户进行修改。如:
添加一个Voting Disk成员:

#crsctl add css votedisk '/dev/raw/raw3'
 
删除一个Voting Disk成员:

#crsctl delete css votedisk '/dev/raw/raw3'
 
Voting Disk的备份与恢复可以通过dd命令来操作。
备份Voting Disk:
dd if=/dev/rhdisk3 of=/tmp/votedisk.bak

恢复Voting Disk:
dd if=/tmp/votedisk.bak of=/dev/rhdisk3

15. 查看数据库上的service运行情况
node2-> srvctl status service -d racdb
Service s1 is running on instance(s) racdb1
Service s2 is running on instance(s) racdb2

16.添加service_name
node1>srvctl add service -d racdb -s s11 -r "racdb1" -a "racdb2"
在节点1上创建service_name=s11
-d : 数据库名称
-r : 首选节点列表
-a : 备用节点列表

srvctl add service -d db_unique_name -s service_name {-r "preferred_list"
   [-a "available_list"] [-P {BASIC | NONE | PRECONNECT}] | -g server_pool
   [-c {UNIFORM | SINGLETON]} [-k network_number]
   [-l [PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY | SNAPSHOT_STANDBY]
   [-y {AUTOMATIC | MANUAL}] [-q {TRUE | FALSE}] [-x {TRUE | FALSE}]
   [-j {SHORT | LONG}][-B {NONE | SERVICE_TIME | THROUGHPUT}]
   [-e {NONE | SESSION | SELECT}] [-m {NONE | BASIC}] [-z failover_retries]
   [-w failover_delay]

修改服务属性
Declare
Begin
  Dbms_Service.Modify_Service(Service_Name    => 's11',
                              Failover_Method => Dbms_Service.Failover_Type_None,
                              Failover_Type   => Dbms_Service.Failover_Type_Select,
                              failover_retries => 180,
                              failover_delay => 20);
End;


17.服务切换
node1-> srvctl relocate service -d racdb -s s11 -i racdb2 -t racdb1
将服务从节点2切换到节点1
-d db_unique_name Unique name for the database
-s service_name Service name
-c source_node Name of the node where the service is currently running
-n target_node Name of node where the service should be relocated
-i old_instance_name Old instance name
-t new_instance_name New instance name
-f Disconnect all sessions during stop or relocate service operations

18.手工启动服务
查看offline的服务
node2-> crs_stat -v
具体指定某个服务启动
node2-> crs_start ora.racdb.s1.racdb1.srv
手工创建的service_name,记得有一次手工启动数据库的时候没有自动启动,后来逐个进行启动。
或是
node1-> srvctl start service -d racdb -s s1
node1-> srvctl start service -d racdb -s s2
node1-> srvctl start service -d racdb -s s11

19.查看数据库上的服务情况
node1-> srvctl config service -d racdb
s1 PREF: racdb1 AVAIL:
s2 PREF: racdb2 AVAIL:
s11 PREF: racdb1 AVAIL: racdb2

 ---------------------------------------------------------OCR部分-----------------------------------------------------
1.检查ocr备份情况
$ocrconfig -showbackup
 

node02     2008/12/19 03:38:17     /orac/crs/cdata/crs
node02     2008/12/18 20:23:45     /orac/crs/cdata/crs
node01     2008/12/18 04:15:47     /orac/crs/cdata/crs
node01     2008/12/18 04:15:47     /orac/crs/cdata/crs
node01     2008/12/14 04:21:00     /orac/crs/cdata/crs


 

$ll /orac/crs/cdata/crs/

total 15696

-rw-r--r-- 1 root root 4014080 Dec 18 04:15 backup00.ocr

-rw-r--r-- 1 root root 4014080 Dec 14 04:21 backup01.ocr

 

2.检查所有节点的ocr情况

[grid@node1 ocrbak]$ cluvfy comp ocr -n all

Verifying OCR integrity

Checking OCR integrity...

Checking the absence of a non-clustered configuration...
All nodes free of non-clustered, local-only configurations


ASM Running check passed. ASM is running on all cluster nodes

Checking OCR config file "/etc/oracle/ocr.loc"...

OCR config file "/etc/oracle/ocr.loc" check successful


Disk group for ocr location "+crs" available on all the nodes


Checking size of the OCR location "+crs" ...

Size check for OCR location "+crs" successful...
Size check for OCR location "+crs" successful...

WARNING:
This check does not verify the integrity of the OCR contents. Execute 'ocrcheck' as a privileged user to verify the contents of OCR.

OCR integrity check passed

Verification of OCR integrity was successful.
[grid@node1 ocrbak]$ more /etc/oracle/ocr.loc
ocrconfig_loc=+crs
local_only=FALSE

3.添加ocr镜像
[root@node1 bin]#/u01/app/oracle/product/10.2.0/crs_1/bin/ocrconfig -replace ocrmirror /dev/raw/raw3

[root@node1 bin]# /u01/app/oracle/product/10.2.0/crs_1/bin/ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :    1043916
         Used space (kbytes)      :       4860
         Available space (kbytes) :    1039056
         ID                       : 1781838267
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded
         Device/File Name         : /dev/raw/raw3
                                    Device/File integrity check succeeded

         Cluster registry integrity check succeeded

[root@node1 oracle]# more /etc/oracle/ocr.loc
#Device/file  getting replaced by device /dev/raw/raw3
ocrconfig_loc=/dev/raw/raw1
ocrmirrorconfig_loc=/dev/raw/raw3
local_only=false


删除ocr镜像
[root@node1 oracle]# /u01/app/oracle/product/10.2.0/crs_1/bin/ocrconfig -replace ocrmirror

[root@node1 oracle]# more /etc/oracle/ocr.loc
#Device/file /dev/raw/raw3 being deleted
ocrconfig_loc=/dev/raw/raw1
local_only=false
[root@node1 oracle]#



4.删除ocr
删除ocr后,ocr镜像会自动转换为ocr.

node1-> /u01/app/oracle/product/10.2.0/crs_1/bin/ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :    1043916
         Used space (kbytes)      :       4868
         Available space (kbytes) :    1039048
         ID                       : 1781838267
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded
         Device/File Name         : /dev/raw/raw3
                                    Device/File integrity check succeeded

         Cluster registry integrity check succeeded

[root@node1 ~]# /u01/app/oracle/product/10.2.0/crs_1/bin/ocrconfig -replace ocr
[root@node1 ~]# /u01/app/oracle/product/10.2.0/crs_1/bin/ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :    1043916
         Used space (kbytes)      :       4868
         Available space (kbytes) :    1039048
         ID                       : 1781838267
         Device/File Name         : /dev/raw/raw3
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded




5.添加vote磁盘
最好先关闭crs
[root@node1 oracle]# /etc/init.d/init.crs stop
[root@node2 oracle]# /etc/init.d/init.crs stop
[root@node1 oracle]# /u01/app/oracle/product/10.2.0/crs_1/bin/crsctl add css votedisk /dev/raw/raw21
Cluster is not in a ready state for online disk addition
需要添加force参数
[root@node1 oracle]# /u01/app/oracle/product/10.2.0/crs_1/bin/crsctl add css votedisk /dev/raw/raw21 -force

Now formatting voting disk: /dev/raw/raw21
successful addition of votedisk /dev/raw/raw21.
[root@node1 oracle]# /u01/app/oracle/product/10.2.0/crs_1/bin/crsctl add css votedisk /dev/raw/raw22 -force
Now formatting voting disk: /dev/raw/raw22
successful addition of votedisk /dev/raw/raw22.
 

 6. 获取css相关设置
node1-> crsctl get css misscount
60
node1-> crsctl get css disktimeout
200
node1-> crsctl get css reboottime
3



 


16.停止启动具体某个资源

[oracle@node2 ~]$ crs_stat -t
Name           Type           Target    State     Host       
------------------------------------------------------------
ora.node1.gsd  application    ONLINE    UNKNOWN   node1      
ora.node1.ons  application    ONLINE    UNKNOWN   node1      
ora.node1.vip  application    ONLINE    ONLINE    node1      
ora.node2.gsd  application    ONLINE    UNKNOWN   node2      
ora.node2.ons  application    ONLINE    UNKNOWN   node2      
ora.node2.vip  application    ONLINE    ONLINE    node2

----------stop-----------------

crs_stop ora.node1.gsd
crs_stop ora.node1.ons
crs_stop ora.node2.gsd
crs_stop ora.node2.ons

 

--------start------------------

crs_start ora.node1.gsd
crs_start ora.node1.ons
crs_start ora.node2.gsd
crs_start ora.node2.ons

 

 

17.重启动CRS(各节点上root用户下执行)

#/etc/init.d/init.crs stop
#/etc/init.d/init.crs start

#/etc/init.d/init.crs enable //随系统启动而自启动,默认选项

#/etc/init.d/init.crs disenable//系统启动后不自动启动

 
18.监听相关
srvctl start listener -n rac1  //启动几点1上的监听
srvctl start listener -n rac2  //启动节点2上的监听
srvctl stop listener -n rac1
srvctl stop listener -n rac2

二、Oracle RAC常用的日志文件

1.db的alertlog文件:
$ORACLE_BASE/admin/orcl/bdump/
$ORACLE_BASE/admin/ams/bdump/
 
2.oracle crs日志文件:

$ORACLE_CRS_HOME/crs/log
$ORACLE_CRS_HOME/css/log
$ORACLE_CRS_HOME/evm/log
$ORACLE_CRS_HOME/srvm/log
阅读(3683) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~