Oracle RAC日常基本维护命令
[font=Tahoma,]所有实例和服务的状态
[font=Tahoma,]$ srvctl status database -d orcl
[font=Tahoma,]Instance orcl1 is running on node linux1
[font=Tahoma,]Instance orcl2 is running on node linux2
[font=Tahoma,]单个实例的状态
[font=Tahoma,]$ srvctl status instance -d orcl -i orcl2
[font=Tahoma,]Instance orcl2 is running on node linux2
[font=Tahoma,]在数据库全局命名服务的状态
[font=Tahoma,]$ srvctl status service -d orcl -s orcltest
[font=Tahoma,]Service orcltest is running on instance(s) orcl2, orcl1
[font=Tahoma,]特定节点上节点应用程序的状态
[font=Tahoma,]$ srvctl status nodeapps -n linux1
[font=Tahoma,]VIP is running on node: linux1
[font=Tahoma,]GSD is running on node: linux1
[font=Tahoma,]Listener is running on node: linux1
[font=Tahoma,]ONS daemon is running on node: linux1
[font=Tahoma,]ASM 实例的状态
[font=Tahoma,]$ srvctl status asm -n linux1
[font=Tahoma,]ASM instance +ASM1 is running on node linux1.
[font=Tahoma,]列出配置的所有数据库
[font=Tahoma,]$ srvctl config database
[font=Tahoma,]orcl
[font=Tahoma,]显示 RAC 数据库的配置
[font=Tahoma,]$ srvctl config database -d orcl
[font=Tahoma,]linux1 orcl1 /u01/app/oracle/product/10.2.0/db_1
[font=Tahoma,]linux2 orcl2 /u01/app/oracle/product/10.2.0/db_1
[font=Tahoma,]显示指定集群数据库的所有服务
[font=Tahoma,]$ srvctl config service -d orcl
[font=Tahoma,]orcltest PREF: orcl2 orcl1 AVAIL:
[font=Tahoma,]显示节点应用程序的配置 —(VIP、GSD、ONS、监听器)
[font=Tahoma,]$ srvctl config nodeapps -n linux1 -a -g -s -l
[font=Tahoma,]VIP exists.: /linux1-vip/192.168.1.200/255.255.255.0/eth0:eth1
[font=Tahoma,]GSD exists.
[font=Tahoma,]ONS daemon exists.
[font=Tahoma,]Listener exists.
[font=Tahoma,]显示 ASM 实例的配置
[font=Tahoma,]$ srvctl config asm -n linux1
[font=Tahoma,]+ASM1 /u01/app/oracle/product/10.2.0/db_1
[font=Tahoma,]集群中所有正在运行的实例
[font=Tahoma,]SELECT
[font=Tahoma,]inst_id
[font=Tahoma,], instance_number inst_no
[font=Tahoma,], instance_name inst_name
[font=Tahoma,], parallel
[font=Tahoma,], status
[font=Tahoma,], database_status db_status
[font=Tahoma,], active_state state
[font=Tahoma,], host_name host
[font=Tahoma,]FROM gv$instance
[font=Tahoma,]ORDER BY inst_id;
[font=Tahoma,]INST_ID INST_NO INST_NAME PAR STATUS DB_STATUS STATE HOST
[font=Tahoma,]-------- -------- ---------- --- ------- ------------ --------- -------
[font=Tahoma,]1 1 orcl1 YES OPEN ACTIVE NORMAL rac1
[font=Tahoma,]2 2 orcl2 YES OPEN ACTIVE NORMAL rac2
[font=Tahoma,]位于磁盘组中的所有数据文件
[font=Tahoma,]select name from v$datafile
[font=Tahoma,]union
[font=Tahoma,]select member from v$logfile
[font=Tahoma,]union
[font=Tahoma,]select name from v$controlfile
[font=Tahoma,]union
[font=Tahoma,]select name from v$tempfile;
[font=Tahoma,]NAME
[font=Tahoma,]-------------------------------------------
[font=Tahoma,]+FLASH_RECOVERY_AREA/orcl/controlfile/current.258.570913191
[font=Tahoma,]+FLASH_RECOVERY_AREA/orcl/onlinelog/group_1.257.570913201
[font=Tahoma,]+FLASH_RECOVERY_AREA/orcl/onlinelog/group_2.256.570913211
[font=Tahoma,]+FLASH_RECOVERY_AREA/orcl/onlinelog/group_3.259.570918285
[font=Tahoma,]+FLASH_RECOVERY_AREA/orcl/onlinelog/group_4.260.570918295
[font=Tahoma,]+ORCL_DATA1/orcl/controlfile/current.259.570913189
[font=Tahoma,]+ORCL_DATA1/orcl/datafile/example.257.570913311
[font=Tahoma,]+ORCL_DATA1/orcl/datafile/indx.270.570920045
[font=Tahoma,]+ORCL_DATA1/orcl/datafile/sysaux.260.570913287
[font=Tahoma,]+ORCL_DATA1/orcl/datafile/system.262.570913215
[font=Tahoma,]+ORCL_DATA1/orcl/datafile/undotbs1.261.570913263
[font=Tahoma,]+ORCL_DATA1/orcl/datafile/undotbs1.271.570920865
[font=Tahoma,]+ORCL_DATA1/orcl/datafile/undotbs2.265.570913331
[font=Tahoma,]+ORCL_DATA1/orcl/datafile/undotbs2.272.570921065
[font=Tahoma,]+ORCL_DATA1/orcl/datafile/users.264.570913355
[font=Tahoma,]+ORCL_DATA1/orcl/datafile/users.269.570919829
[font=Tahoma,]+ORCL_DATA1/orcl/onlinelog/group_1.256.570913195
[font=Tahoma,]+ORCL_DATA1/orcl/onlinelog/group_2.263.570913205
[font=Tahoma,]+ORCL_DATA1/orcl/onlinelog/group_3.266.570918279
[font=Tahoma,]+ORCL_DATA1/orcl/onlinelog/group_4.267.570918289
[font=Tahoma,]+ORCL_DATA1/orcl/tempfile/temp.258.570913303
[font=Tahoma,]21 rows selected.
[font=Tahoma,]属于“ORCL_DATA1”磁盘组的所有 ASM 磁盘
[font=Tahoma,]SELECT path
[font=Tahoma,]FROM v$asm_disk
[font=Tahoma,]WHERE group_number IN (select group_number
[font=Tahoma,]from v$asm_diskgroup
[font=Tahoma,]where name = 'ORCL_DATA1');
[font=Tahoma,]PATH
[font=Tahoma,]----------------------------------
[font=Tahoma,]ORCL:VOL1
[font=Tahoma,]ORCL:VOL2
[font=Tahoma,]启动/停止RAC集群
[font=Tahoma,]确保是以 oracle UNIX 用户登录的。我们将从rac1节点运行所有命令:
[font=Tahoma,]# su – oracle
[font=Tahoma,]$ hostname
[font=Tahoma,]Rac1
[font=Tahoma,]停止 Oracle RAC 10g 环境
[font=Tahoma,]第一步是停止 Oracle 实例。当此实例(和相关服务)关闭后,关闭 ASM 实例。最后,关闭节点应用程序(虚拟 IP、GSD、TNS 监听器和 ONS)。
[font=Tahoma,]$ export ORACLE_SID=orcl1
[font=Tahoma,]$ emctl stop dbconsole
[font=Tahoma,]$ srvctl stop instance -d orcl -i orcl1
[font=Tahoma,]$ srvctl stop asm -n rac1
[font=Tahoma,]$ srvctl stop nodeapps –n rac1
[font=Tahoma,]启动 Oracle RAC 10g 环境
[font=Tahoma,]第一步是启动节点应用程序(虚拟 IP、GSD、TNS 监听器和 ONS)。当成功启动节点应用程序后,启动 ASM 实例。最后,启动 Oracle 实例(和相关服务)以及企业管理器数据库控制台。
[font=Tahoma,]$ export ORACLE_SID=orcl1
[font=Tahoma,]$ srvctl start nodeapps -n rac1
[font=Tahoma,]$ srvctl start asm -n rac1
[font=Tahoma,]$ srvctl start instance -d orcl -i orcl1
[font=Tahoma,]$ emctl start dbconsole
[font=Tahoma,]使用 SRVCTL 启动/停止所有实例
[font=Tahoma,]启动/停止所有实例及其启用的服务。我只是觉得有意思就把此步骤作为关闭所有实例的一种方法加进来了!
[font=Tahoma,]$ srvctl start database -d orcl
[font=Tahoma,]$ srvctl stop database -d orcl
[font=Tahoma,]启停止监听
[font=Tahoma,]hostb$lsnrctl start listener_hostb
[font=Tahoma,]hostb$lsnrctl stop listener_hostb备份votning diskdd if=voting_disk_name of=backup_file_name
[font=Tahoma,]dd if=/dev/rdsk/c4t600C0FF000000000098ADE240330A000d0s4 of=votingdisk.bak# dd if=/dev/zero of=/dev/rdsk/c4t600C0FF000000000098ADE240330A000d0s4 bs=512 count=261120
[font=Tahoma,]测试
[font=Tahoma,]# dd if=/dev/rdsk/c4t600C0FF000000000098ADE240330A000d0s4 of=/data/backup/rac/vd_backup0420.bak
[font=Tahoma,]261120+0 记录进入
[font=Tahoma,]261120+0 记录调出
[font=Tahoma,]# cd /data/backup/rac
[font=Tahoma,]# ls
[font=Tahoma,]ocr0420.bak ocrdisk vd_backup0420.bak votingdisk.bak votingdisk0420.bak
[font=Tahoma,]# dd if=/data/backup/rac/vd_backup0420.bak of=/dev/rdsk/c4t600C0FF000000000098ADE240330A000d0s4
[font=Tahoma,]261120+0 记录进入
[font=Tahoma,]261120+0 记录调出备份OCR磁盘
[font=Tahoma,]查看备份
[font=Tahoma,]$ocrconfig -showbackup
[font=Tahoma,]备份
[font=Tahoma,]/data/oracle/crs/bin/ocrconfig -export /data/backup/rac/ocrdisk.bak
[font=Tahoma,]还原 需要停掉所有的节点,Stop the Oracle Clusterware software on all of the nodes
[font=Tahoma,]/data/oracle/crs/bin/ocrconfig -import file_name
[font=Tahoma,]自动备份的还原# /data/oracle/crs/bin/ocrconfig -showbackup
[font=Tahoma,]# /data/oracle/crs/bin/ocrconfig -restore /data/oracle/crs/cdata/db168crs/backup00.ocrhosta$cluvfy comp ocr -n all //检验
[font=Tahoma,]ocr 检查
[font=Tahoma,]#ocrcheck配置路径在
[font=Tahoma,]/var/opt/oracle/ocrconfig_loc文件里面 如果需要更改OCR磁盘的路径配置。
[font=Tahoma,]OCR磁盘空间检查
[font=Tahoma,]# /data/oracle/crs/bin/ocrcheck
[font=Tahoma,]Status of Oracle Cluster Registry is as follows :
[font=Tahoma,] Version : 2
[font=Tahoma,] Total space (kbytes) : 399752
[font=Tahoma,] Used space (kbytes) : 3784
[font=Tahoma,] Available space (kbytes) : 395968
[font=Tahoma,] ID : 148562961
[font=Tahoma,] Device/File Name : /dev/rdsk/c4t600C0FF000000000098ADE240330A000d0s5
[font=Tahoma,] Device/File integrity check succeeded Device/File not configured Cluster registry integrity check succeeded#
[font=Tahoma,]ASM 实例的状态
[font=Tahoma,]hosta$srvctl status asm -n hosta
[font=Tahoma,]ASM 实例 +ASM1 正在节点 hosta 上运行。
[font=Tahoma,]hosta$特定节点上节点应用程序的状态
[font=Tahoma,]hosta$srvctl status nodeapps -n hosta
[font=Tahoma,]VIP 正在运行的节点: hosta
[font=Tahoma,]GSD 正在运行的节点: hosta
[font=Tahoma,]监听程序未在节点上运行: hosta
[font=Tahoma,]ONS 守护程序正在节点上运行:hosta
[font=Tahoma,]hosta$所有实例和服务的状态
[font=Tahoma,]hosta$srvctl status database -d cole
[font=Tahoma,]实例 cole1 正在节点 hosta 上运行
[font=Tahoma,]实例 cole2 正在节点 hostb 上运行
[font=Tahoma,]hosta$列出配置的所有数据库
[font=Tahoma,]hosta$srvctl config database
[font=Tahoma,]cole
[font=Tahoma,]hosta$
[font=Tahoma,]显示 RAC 数据库的配置hosta$srvctl config database -d cole
[font=Tahoma,]hosta cole1 /data/oracle/OracleHome
[font=Tahoma,]hostb cole2 /data/oracle/OracleHome
[font=Tahoma,]hosta$显示 ASM 实例的配置
[font=Tahoma,]hosta$srvctl config asm -n hosta
[font=Tahoma,]+ASM1 /data/oracle/OracleHome显示节点应用程序的配置 -(VIP、GSD、ONS、监听器)
[font=Tahoma,]hosta$srvctl config nodeapps -n hosta -a -g -s -l
[font=Tahoma,]VIP 已存在。: /a1-vip/10.1.1.9/255.255.0.0/ce0
[font=Tahoma,]GSD 已存在。
[font=Tahoma,]ONS 守护程序已存在。
[font=Tahoma,]监听程序已存在。
[font=Tahoma,]hosta$
[font=Tahoma,]集群中所有正在运行的实例
[font=Tahoma,]SELECT
[font=Tahoma,]inst_id
[font=Tahoma,], instance_number inst_no
[font=Tahoma,], instance_name inst_name
[font=Tahoma,], parallel
[font=Tahoma,], status
[font=Tahoma,], database_status db_status
[font=Tahoma,], active_state state
[font=Tahoma,], host_name host
[font=Tahoma,]FROM gv$instance
[font=Tahoma,]ORDER BY inst_id; INST_ID INST_NO INST_NAME PAR STATUS DB_STATUS STATE HOST
[font=Tahoma,]---------- ---------- ---------------- --- ------------ -------------------------- -
[font=Tahoma,] 1 1 cole1 YES OPEN ACTIVE NORMAL hosta 2 2 cole2 YES OPEN ACTIVE NORMAL hostb
[font=Tahoma,]位于磁盘组中的所有数据文件
[font=Tahoma,]SQL> select name from v$datafile
[font=Tahoma,]union
[font=Tahoma,]select member from v$logfile
[font=Tahoma,]union
[font=Tahoma,]select name from v$controlfile
[font=Tahoma,]union
[font=Tahoma,]select name from v$tempfile;