您在这里:首页 > 学员专区 > 技术文章
Oracle视频
Oracle
CUUG课程

Oracle RAC日常基本维护命令


1、所有实例和服务的状态

$ srvctl status database -d orcl

Instance orcl1 is running on node linux1

Instance orcl2 is running on node linux2

 

2、单个实例的状态

$ srvctl status instance -d orcl -i orcl2

Instance orcl2 is running on node linux2

 

3、在数据库全局命名服务的状态

$ srvctl status service -d orcl -s orcltest

Service orcltest is running on instance(s) orcl2, orcl1

 

4、特定节点上节点应用程序的状态

$ srvctl status nodeapps -n linux1

VIP is running on node: linux1

GSD is running on node: linux1

Listener is running on node: linux1

ONS daemon is running on node: linux1

 

5、ASM 实例的状态

$ srvctl status asm -n linux1

ASM instance +ASM1 is running on node linux1.

 

6、列出配置的所有数据库

$ srvctl config database

orcl

 

7、显示 RAC 数据库的配置

$ srvctl config database -d orcl

linux1 orcl1 /u01/app/oracle/product/10.2.0/db_1

linux2 orcl2 /u01/app/oracle/product/10.2.0/db_1

 

8、显示指定集群数据库的所有服务

$ srvctl config service -d orcl

orcltest PREF: orcl2 orcl1 AVAIL:

 

9、显示节点应用程序的配置 —(VIP、GSD、ONS、监听器)

$ srvctl config nodeapps -n linux1 -a -g -s -l

VIP exists.: /linux1-vip/192.168.1.200/255.255.255.0/eth0:eth1

GSD exists.

ONS daemon exists.

Listener exists.

 

10、显示 ASM 实例的配置

$ srvctl config asm -n linux1

+ASM1 /u01/app/oracle/product/10.2.0/db_1

 

11、集群中所有正在运行的实例

SELECT

inst_id

, instance_number inst_no

, instance_name inst_name

, parallel

, status

, database_status db_status

, active_state state

, host_name host

FROM gv$instance

ORDER BY inst_id;

INST_ID INST_NO INST_NAME PAR STATUS DB_STATUS STATE HOST

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

1 1 orcl1 YES OPEN ACTIVE NORMAL rac1

2 2 orcl2 YES OPEN ACTIVE NORMAL rac2

 

12、位于磁盘组中的所有数据文件

select name from v$datafile

union

select member from v$logfile

union

select name from v$controlfile

union

select name from v$tempfile;

NAME

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

+FLASH_RECOVERY_AREA/orcl/controlfile/current.258.570913191

+FLASH_RECOVERY_AREA/orcl/onlinelog/group_1.257.570913201

+FLASH_RECOVERY_AREA/orcl/onlinelog/group_2.256.570913211

+FLASH_RECOVERY_AREA/orcl/onlinelog/group_3.259.570918285

+FLASH_RECOVERY_AREA/orcl/onlinelog/group_4.260.570918295

+ORCL_DATA1/orcl/controlfile/current.259.570913189

+ORCL_DATA1/orcl/datafile/example.257.570913311

+ORCL_DATA1/orcl/datafile/indx.270.570920045

+ORCL_DATA1/orcl/datafile/sysaux.260.570913287

+ORCL_DATA1/orcl/datafile/system.262.570913215

+ORCL_DATA1/orcl/datafile/undotbs1.261.570913263

+ORCL_DATA1/orcl/datafile/undotbs1.271.570920865

+ORCL_DATA1/orcl/datafile/undotbs2.265.570913331

+ORCL_DATA1/orcl/datafile/undotbs2.272.570921065

+ORCL_DATA1/orcl/datafile/users.264.570913355

+ORCL_DATA1/orcl/datafile/users.269.570919829

+ORCL_DATA1/orcl/onlinelog/group_1.256.570913195

+ORCL_DATA1/orcl/onlinelog/group_2.263.570913205

+ORCL_DATA1/orcl/onlinelog/group_3.266.570918279

+ORCL_DATA1/orcl/onlinelog/group_4.267.570918289

+ORCL_DATA1/orcl/tempfile/temp.258.570913303

21 rows selected.

 

13、属于“ORCL_DATA1”磁盘组的所有 ASM 磁盘

SELECT path

FROM v$asm_disk

WHERE group_number IN (select group_number

from v$asm_diskgroup

where name = 'ORCL_DATA1');

PATH

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

ORCL:VOL1

ORCL:VOL2

 

14、启动/停止RAC集群

确保是以 oracle UNIX 用户登录的。我们将从rac1节点运行所有命令:

# su – oracle

$ hostname

Rac1

 

15、停止 Oracle RAC 10g 环境

第一步是停止 Oracle 实例。当此实例(和相关服务)关闭后,关闭 ASM 实例。最后,关闭节点应用程序(虚拟 IP、GSD、TNS 监听器和 ONS)。

$ export ORACLE_SID=orcl1

$ emctl stop dbconsole

$ srvctl stop instance -d orcl -i orcl1

$ srvctl stop asm -n rac1

$ srvctl stop nodeapps –n rac1

 

16、启动 Oracle RAC 10g 环境

第一步是启动节点应用程序(虚拟 IP、GSD、TNS 监听器和 ONS)。当成功启动节点应用程序后,启动 ASM 实例。最后,启动 Oracle 实例(和相关服务)以及企业管理器数据库控制台。

$ export ORACLE_SID=orcl1

$ srvctl start nodeapps -n rac1

$ srvctl start asm -n rac1

$ srvctl start instance -d orcl -i orcl1

$ emctl start dbconsole

 

17、使用 SRVCTL 启动/停止所有实例

启动/停止所有实例及其启用的服务。我只是觉得有意思就把此步骤作为关闭所有实例的一种方法加进来了!

$ srvctl start database -d orcl

$ srvctl stop database -d orcl

 

18、启停止监听

hostb$lsnrctl start listener_hostb

hostb$lsnrctl stop listener_hostb

 

19、备份

votning diskdd if=voting_disk_name of=backup_file_name

dd if=/dev/rdsk/c4t600C0FF000000000098ADE240330A000d0s4 of=votingdisk.bak# dd if=/dev/zero of=/dev/rdsk/c4t600C0FF000000000098ADE240330A000d0s4 bs=512 count=261120

测试

# dd if=/dev/rdsk/c4t600C0FF000000000098ADE240330A000d0s4 of=/data/backup/rac/vd_backup0420.bak

261120+0 记录进入

261120+0 记录调出

# cd /data/backup/rac

# ls

ocr0420.bak         ocrdisk             vd_backup0420.bak   votingdisk.bak      votingdisk0420.bak

# dd if=/data/backup/rac/vd_backup0420.bak of=/dev/rdsk/c4t600C0FF000000000098ADE240330A000d0s4

261120+0 记录进入

261120+0 记录调出备份OCR磁盘

查看备份

$ocrconfig -showbackup

备份

/data/oracle/crs/bin/ocrconfig -export /data/backup/rac/ocrdisk.bak

 

20、还原

需要停掉所有的节点,Stop the Oracle Clusterware software on all of the nodes

/data/oracle/crs/bin/ocrconfig -import file_name

自动备份的还原

# /data/oracle/crs/bin/ocrconfig -showbackup

# /data/oracle/crs/bin/ocrconfig -restore /data/oracle/crs/cdata/db168crs/backup00.ocrhosta$cluvfy comp ocr -n all //检验

 

21、ocr 检查

#ocrcheck配置路径在

/var/opt/oracle/ocrconfig_loc文件里面 如果需要更改OCR磁盘的路径配置。

 

22、OCR磁盘空间检查

# /data/oracle/crs/bin/ocrcheck

Status of Oracle Cluster Registry is as follows :

Version                  :          2

Total space (kbytes)     :     399752

Used space (kbytes)      :       3784

Available space (kbytes) :     395968

ID                       : 148562961

Device/File Name         : /dev/rdsk/c4t600C0FF000000000098ADE240330A000d0s5

Device/File integrity check succeeded                                    Device/File not configured         Cluster registry integrity check succeeded#


(文章来自网络,如有侵权请来信告知,本站将在第一时间删除。)

相关文章 [上一篇] 如何高效删除Oracle数据库中的重复数据
010-88589926(88587026)
CUUG热门培训课程
Oracle DBA就业培训
CUUG名师
网络课程
技术沙龙
最新动态

总机:(010)-88589926,88589826,88587026 QQ讨论群:243729577 182441349 邮箱:cuug_bj@cuug.com
通信地址:北京市海淀区紫竹院路98号北京化工大学科技园609室(CUUG)邮政编码:100089 
中国UNIX用户协会 Copyright 2010  ALL Rights Reserved 北京神脑资讯技术有限公司
京ICP备11008061号  京公网安备110108006275号