Oracle RAC 日常基本维护命令

列出配置的所有数据库

[root@node1 ~]# srvctl config database
NOVADB

所有实例和服务的状态

[root@node1 ~]# srvctl status database -d NOVADB
Instance NOVADB1 is running on node node1
Instance NOVADB2 is running on node node2

单个实例的状态

[root@node1 ~]# srvctl status instance -d NOVADB -i NOVADB1
Instance NOVADB1 is running on node node1

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

$ srvctl status service -d orcl -s orcltest
Service orcltest is running on instance(s) orcl2, orcl1

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

[root@node1 ~]# srvctl status nodeapps -n node1
VIP is running on node: node1
GSD is running on node: node1
Listener is running on node: node1
ONS daemon is running on node: node1

ASM 实例的状态

[root@node1 ~]# srvctl status asm -n node1
ASM instance +ASM1 is running on node node1.
[root@node1 ~]# srvctl status asm -n node2
ASM instance +ASM2 is running on node node2.

显示 RAC 数据库的配置

[root@node1 ~]# srvctl config database -d NOVADB
node1 NOVADB1 /opt/ora10g/product/10.2.0/db_1
node2 NOVADB2 /opt/ora10g/product/10.2.0/db_1

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

[root@node1 ~]# srvctl config service -d NOVADB
NOVADB PREF: NOVADB1 NOVADB2 AVAIL:

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

[root@node1 ~]# srvctl config nodeapps -n node1 -a -g -s -l
VIP exists.: /node1-vip/192.168.150.224/255.255.255.0/eth0
GSD exists.
ONS daemon exists.
Listener exists.

利用srvctl config命令可以看到现有数据库的配置信息:

[root@node1 ~]# srvctl config database -d NOVADB -a
node1 NOVADB1 /opt/ora10g/product/10.2.0/db_1
node2 NOVADB2 /opt/ora10g/product/10.2.0/db_1
DB_NAME: NOVADB
ORACLE_HOME: /opt/ora10g/product/10.2.0/db_1
SPFILE: +RAC_DISK/NOVADB/spfileNOVADB.ora
DOMAIN: null
DB_ROLE: null
START_OPTIONS: null
POLICY: AUTOMATIC
ENABLE FLAG: DB ENABLED

显示 ASM 实例的配置

[root@node1 ~]# srvctl config asm -n node1
+ASM1 /opt/ora10g/product/10.2.0/db_1
[root@node1 ~]# srvctl config asm -n node2
+ASM2 /opt/ora10g/product/10.2.0/db_1

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

SQL> r
1 SELECT
2 inst_id
3 , instance_number inst_no
4 , instance_name inst_name
5 , parallel
6 , status
7 , database_status db_status
8 , active_state state
9 , host_name host
10 FROM gv$instance
11* ORDER BY inst_id
rows will be truncated

INST_ID INST_NO INST_NAME PAR STATUS DB_STATUS STATE
———- ———- —————- — ———— —————– ——
1 1 NOVADB1 YES OPEN ACTIVE NORMAL
2 2 NOVADB2 YES OPEN ACTIVE NORMAL

SQL>

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

SQL> select name from v$datafile
union
select member from v$logfile
union
select name from v$controlfile
union
select name from v$tempfile;

NAME
——————————————————————————–
+RAC_DISK/novadb/controlfile/current.260.685491565
+RAC_DISK/novadb/datafile/nova_test.268.686337643
+RAC_DISK/novadb/datafile/sysaux.257.685491407
+RAC_DISK/novadb/datafile/system.256.685491401
+RAC_DISK/novadb/datafile/undotbs1.258.685491411
+RAC_DISK/novadb/datafile/undotbs2.264.685491733
+RAC_DISK/novadb/datafile/users.259.685491413
+RAC_DISK/novadb/onlinelog/group_1.261.685491571
+RAC_DISK/novadb/onlinelog/group_2.262.685491575
+RAC_DISK/novadb/onlinelog/group_3.265.685491915
+RAC_DISK/novadb/onlinelog/group_4.266.685491921

NAME
——————————————————————————–
+RAC_DISK/novadb/tempfile/temp.263.685491617

12 rows selected.

SQL>

属于“RAC_DISK”磁盘组的所有 ASM 磁盘

SQL> SELECT path FROM v$asm_disk WHERE group_number IN (select group_number from v$asm_diskgroup where name = ‘RAC_DISK’);

PATH
——————————————————————————–
/dev/raw/raw3
/dev/raw/raw4
ORCL:NOVA3

启动/停止RAC集群

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

# su – oracle

[oracle@node1 ~]$ hostname

node1

停止 Oracle RAC 10g 环境

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

[oracle@node1 ~]$ export ORACLE_SID=NOVADB1
[oracle@node1 ~]$ emctl stop dbconsole
[oracle@node1 ~]$ srvctl stop instance -d NOVADB -i NOVADB1
[oracle@node1 ~]$ srvctl stop asm -n node1
[oracle@node1 ~]$ srvctl stop nodeapps –n node1

 

启动 Oracle RAC 10g 环境

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

[oracle@node1 ~]$ export ORACLE_SID=NOVADB
[oracle@node1 ~]$ srvctl start nodeapps -n node1
[oracle@node1 ~]$ srvctl start asm -n node1
[oracle@node1 ~]$ srvctl start instance -d NOVADB -i NOVADB1
[oracle@node1 ~]$ emctl start dbconsole

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

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

[oracle@node1 ~]$ srvctl start database -d NOVADB
[oracle@node1 ~]$ srvctl stop database -d NOVADB

启停止监听
[oracle@node1 ~]$lsnrctl start listener_hostb
[oracle@node1 ~]$lsnrctl stop listener_hostb

以下没经过测试呢,等待测试,工作太忙了..

备份
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

还原 需要停掉所有的节点,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 //检验

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

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)