recover 数据库
在执行restore的节点执行,因为备份文件在该节点上。
RMAN> recover database;
Starting recover at 21-JUN-14
using channel ORA_DISK_1
starting media recovery
unable to find archived log
archived log thread=1 sequence=11
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/21/2014 21:02:01
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 11 and starting SCN of 995895
RMAN> recover database until scn 995895;
Starting recover at 21-JUN-14
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 21-JUN-14
RMAN> restore archivelog all;
Starting restore at 21-JUN-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=5
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=6
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=7
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=8
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=9
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=10
channel ORA_DISK_1: reading from backup piece /dba/app/rmanbak/DOMINIC_arch_0ap9pjij_20140601
channel ORA_DISK_1: piece handle=/dba/app/rmanbak/DOMINIC_arch_0ap9pjij_20140601 tag=TAG20140601T232715
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 21-JUN-14
SQL> startup
ORACLE instance started.
Total System Global Area 1152450560 bytes
Fixed Size 2252584 bytes
Variable Size 855638232 bytes
Database Buffers 285212672 bytes
Redo Buffers 9347072 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
DOMINIC READ WRITE
SQL> select comp_name, version, status from sys.dba_registry;
COMP_NAME
--------------------------------------------------------------------------------
VERSION STATUS
------------------------------ --------------------------------------------
OWB
11.2.0.4.0 VALID
Oracle Application Express
3.2.1.00.12 VALID
Oracle Enterprise Manager
11.2.0.4.0 VALID
COMP_NAME
--------------------------------------------------------------------------------
VERSION STATUS
------------------------------ --------------------------------------------
OLAP Catalog
11.2.0.4.0 VALID
Spatial
11.2.0.4.0 VALID
Oracle Multimedia
11.2.0.4.0 VALID
COMP_NAME
--------------------------------------------------------------------------------
VERSION STATUS
------------------------------ --------------------------------------------
Oracle XML Database
11.2.0.4.0 VALID
Oracle Text
11.2.0.4.0 VALID
Oracle Expression Filter
11.2.0.4.0 VALID
COMP_NAME
--------------------------------------------------------------------------------
VERSION STATUS
------------------------------ --------------------------------------------
Oracle Rules Manager
11.2.0.4.0 VALID
Oracle Workspace Manager
11.2.0.4.0 VALID
Oracle Database Catalog Views
11.2.0.4.0 VALID
COMP_NAME
--------------------------------------------------------------------------------
VERSION STATUS
------------------------------ --------------------------------------------
Oracle Database Packages and Types
11.2.0.4.0 VALID
JServer JAVA Virtual Machine
11.2.0.4.0 VALID
Oracle XDK
11.2.0.4.0 VALID
COMP_NAME
--------------------------------------------------------------------------------
VERSION STATUS
------------------------------ --------------------------------------------
Oracle Database Java Packages
11.2.0.4.0 VALID
OLAP Analytic Workspace
11.2.0.4.0 VALID
Oracle OLAP API
11.2.0.4.0 VALID
18 rows selected.
SQL> select * from v$option where parameter = 'Real Application Clusters';
PARAMETER
----------------------------------------------------------------
VALUE
----------------------------------------------------------------
Real Application Clusters
TRUE
SQL> show parameter cluster
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cluster_database boolean TRUE
cluster_database_instances integer 2
cluster_interconnects string
SQL> show parameter thread;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
parallel_threads_per_cpu integer 2
thread integer 1
SQL> show parameter instance_number
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
instance_number integer 1
SQL> show parameter cluster_database;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cluster_database boolean TRUE
cluster_database_instances integer 2
SQL> show parameter cluster_database_instances
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cluster_database_instances integer 2
创建节点2的undo 表空间
SYS@anqing1(rac1)> show parameter undo_tablespace
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_tablespace string UNDOTBS1
这个是rac1上节点的信息,我们在之前的在spfile参数指定的rac2节点的undo 空间是UNDOTBS2.
所以这里我们创建该undo 表空间,并指定相关参数。
SYS@dominic(rac1)> create undo tablespace UNDOTBS2 datafile '+DATA/ANQING/datafile/undotbs02.dbf' size 500m;
SQL> create undo tablespace UNDOTBS2 datafile '+DATA_DISK/DOMINIC/datafile/undotbs02.dbf' size 500m;
Tablespace created.
SQL> show parameter undo
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS1
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DATA_DISK/dominic/datafile/system.263.850855443
+DATA_DISK/dominic/datafile/sysaux.262.850855443
+DATA_DISK/dominic/datafile/undotbs1.261.850855443
+DATA_DISK/dominic/datafile/users.265.850855443
+DATA_DISK/dominic/datafile/example.264.850855443
+DATA_DISK/dominic/datafile/dominic_tbs.260.850855443
+DATA_DISK/dominic/datafile/undotbs02.dbf
ASMCMD> pwd
+data_disk/dominic/datafile
ASMCMD> ls
DOMINIC_TBS.260.850855443
EXAMPLE.264.850855443
SYSAUX.262.850855443
SYSTEM.263.850855443
UNDOTBS1.261.850855443
UNDOTBS2.269.850858531
USERS.265.850855443
undotbs02.dbf
SQL> SELECT NAME FROM V$TABLESPACE;
NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
USERS
TEMP
EXAMPLE
DOMINIC_TBS
UNDOTBS2
添加rac2 节点的redo 文件
SQL> alter database add logfile thread 2 group 4 ('+DATA_DISK','+LOG_DISK') SIZE 50M ;
Database altered.
SQL> alter database add logfile thread 2 group 5('+DATA_DISK','+LOG_DISK') SIZE 50M ;
Database altered.
SQL> alter database add logfile thread 2 group 6('+DATA_DISK','+LOG_DISK') SIZE 50M;
Database altered.
=========================
=================================
SQL> alter database enable thread 2;
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down. ---- 重启节点1和节点2 上的实例,使相关参数生效
=====(一下在节点2 上)
查看节点二 参数,增加参数 export ORACLE_UNQNAME=dominic
[oracle@dominic2 ~]$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export ORACLE_SID=dominic2
export ORACLE_UNQNAME=dominic
export ORACLE_BASE=/dba/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
export LANG=C
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
umask 022
[oracle@dominic2 ~]$ sqlplus / as sysdba --启动节点2
SQL*Plus: Release 11.2.0.4.0 Production on Sat Jun 21 21:52:19 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 1152450560 bytes
Fixed Size 2252584 bytes
Variable Size 855638232 bytes
Database Buffers 285212672 bytes
Redo Buffers 9347072 bytes
Database mounted.
Database opened.
SQL> show parameter cluster
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cluster_database boolean TRUE
cluster_database_instances integer 2
cluster_interconnects string
SQL> select instance_number,instance_name,host_name from gv$instance; --最后确认是否起来了!
INSTANCE_NUMBER INSTANCE_NAME HOST_NAME
--------------- ---------------- ----------------------------------------------------------------
1 dominic1 dominic1.com
2 dominic2 dominic2.com
到现在已经是集群了,不过还有一些收尾的工作要做。
执行catclust.sql脚本来创建相关视图
SQL> @$ORACLE_HOME/rdbms/admin/catclust.sql
重建Temp 表空间
在恢复的时候,会自动创建TEMP 表空间。和一个前辈聊到过这个问题,他说这个temp 文件好像没有起到作用。 尤其是数据量大的时候,他建议重建添加temp 数据文件。 这个还是小心为好,反正重建一些也不费什么事。但是万一出问题,就是大麻烦。
SQL> select name from v$tempfile;
NAME
----------------------------------------------------------------------------------------------------
/dba/app/oracle/oradata/dominic/temp01.dbf --两个节点一样
SQL> alter tablespace temp add tempfile '+DATA_DISK' size 400m;
Tablespace altered.
SQL> select name from v$tempfile;
NAME
----------------------------------------------------------------------------------------------------
/dba/app/oracle/oradata/dominic/temp01.dbf
+DATA_DISK/dominic/tempfile/temp.273.850859907
SQL> alter database tempfile '/dba/app/oracle/oradata/dominic/temp01.dbf' offline;
Database altered.
SQL> alter database tempfile '/dba/app/oracle/oradata/dominic/temp01.dbf' drop including datafiles;
Database altered.
---现在两个节点查看,都是一样的,
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
+DATA_DISK/dominic/tempfile/temp.273.850859907
添加集群的监听:
之前需要确认:
[grid@dominic2 ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....DISK.dg ora....up.type ONLINE ONLINE dominic1
ora....ER.lsnr ora....er.type ONLINE ONLINE dominic1
ora....N1.lsnr ora....er.type ONLINE ONLINE dominic1
ora....DISK.dg ora....up.type ONLINE ONLINE dominic1
ora....DATA.dg ora....up.type ONLINE ONLINE dominic1
ora.asm ora.asm.type ONLINE ONLINE dominic1
ora.cvu ora.cvu.type ONLINE ONLINE dominic1
ora....SM1.asm application ONLINE ONLINE dominic1
ora....C1.lsnr application ONLINE ONLINE dominic1
ora....ic1.gsd application OFFLINE OFFLINE
ora....ic1.ons application ONLINE ONLINE dominic1
ora....ic1.vip ora....t1.type ONLINE ONLINE dominic1
ora....SM2.asm application ONLINE ONLINE dominic2
ora....C2.lsnr application ONLINE ONLINE dominic2
ora....ic2.gsd application OFFLINE OFFLINE
ora....ic2.ons application ONLINE ONLINE dominic2
ora....ic2.vip ora....t1.type ONLINE ONLINE dominic2
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type ONLINE ONLINE dominic1
ora.oc4j ora.oc4j.type ONLINE ONLINE dominic1
ora.ons ora.ons.type ONLINE ONLINE dominic1
ora....ry.acfs ora....fs.type ONLINE ONLINE dominic1
ora.scan1.vip ora....ip.type ONLINE ONLINE dominic1
[grid@dominic1 ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....DISK.dg ora....up.type ONLINE ONLINE dominic1
ora....ER.lsnr ora....er.type ONLINE ONLINE dominic1
ora....N1.lsnr ora....er.type ONLINE ONLINE dominic1
ora....DISK.dg ora....up.type ONLINE ONLINE dominic1
ora....DATA.dg ora....up.type ONLINE ONLINE dominic1
ora.asm ora.asm.type ONLINE ONLINE dominic1
ora.cvu ora.cvu.type ONLINE ONLINE dominic1
ora....SM1.asm application ONLINE ONLINE dominic1
ora....C1.lsnr application ONLINE ONLINE dominic1
ora....ic1.gsd application OFFLINE OFFLINE
ora....ic1.ons application ONLINE ONLINE dominic1
ora....ic1.vip ora....t1.type ONLINE ONLINE dominic1
ora....SM2.asm application ONLINE ONLINE dominic2
ora....C2.lsnr application ONLINE ONLINE dominic2
ora....ic2.gsd application OFFLINE OFFLINE
ora....ic2.ons application ONLINE ONLINE dominic2
ora....ic2.vip ora....t1.type ONLINE ONLINE dominic2
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type ONLINE ONLINE dominic1
ora.oc4j ora.oc4j.type ONLINE ONLINE dominic1
ora.ons ora.ons.type ONLINE ONLINE dominic1
ora....ry.acfs ora....fs.type ONLINE ONLINE dominic1
ora.scan1.vip ora....ip.type ONLINE ONLINE dominic1
将其他信息注册到CRS里
[grid@dominic1 ~]$ srvctl add database -d dominic -o $ORACLE_HOME
[grid@dominic1 ~]$ srvctl add instance -d dominic -i dominic1 -n dominic1 (-n 为hostname, oracle,grid 用户都可以)
[grid@dominic1 ~]$ srvctl add instance -d dominic -i dominic2 -n dominic2
修改instance 和 asm 之间的依赖关系:
srvctl modify instance -d <db_unique_name> -i <SID1> -s <+ASM1>
[oracle@dominic1 ~]$ srvctl modify instance -d dominic -i dominic1 -s +ASM1
Warning:-s option has been deprecated and will be ignored.
[oracle@dominic1 ~]$ srvctl modify instance -d dominic -i dominic2 -s +ASM2
Warning:-s option has been deprecated and will be ignored.
-----在这里算是可以完成了:
查询验证一下:
[grid@dominic1 ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....DISK.dg ora....up.type ONLINE ONLINE dominic1
ora....ER.lsnr ora....er.type ONLINE ONLINE dominic1
ora....N1.lsnr ora....er.type ONLINE ONLINE dominic1
ora....DISK.dg ora....up.type ONLINE ONLINE dominic1
ora....DATA.dg ora....up.type ONLINE ONLINE dominic1
ora.asm ora.asm.type ONLINE ONLINE dominic1
ora.cvu ora.cvu.type ONLINE ONLINE dominic1
ora.dominic.db ora....se.type OFFLINE OFFLINE
ora....SM1.asm application ONLINE ONLINE dominic1
ora....C1.lsnr application ONLINE ONLINE dominic1
ora....ic1.gsd application OFFLINE OFFLINE
ora....ic1.ons application ONLINE ONLINE dominic1
ora....ic1.vip ora....t1.type ONLINE ONLINE dominic1
ora....SM2.asm application ONLINE ONLINE dominic2
ora....C2.lsnr application ONLINE ONLINE dominic2
ora....ic2.gsd application OFFLINE OFFLINE
ora....ic2.ons application ONLINE ONLINE dominic2
ora....ic2.vip ora....t1.type ONLINE ONLINE dominic2
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type ONLINE ONLINE dominic1
ora.oc4j ora.oc4j.type ONLINE ONLINE dominic1
ora.ons ora.ons.type ONLINE ONLINE dominic1
ora....ry.acfs ora....fs.type ONLINE ONLINE dominic1
ora.scan1.vip ora....ip.type ONLINE ONLINE dominic1
---------------------
[grid@dominic1 ~]$ crsctl status resource -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA_DISK.dg
ONLINE ONLINE dominic1
ONLINE ONLINE dominic2
ora.LISTENER.lsnr
ONLINE ONLINE dominic1
ONLINE ONLINE dominic2
ora.LOG_DISK.dg
ONLINE ONLINE dominic1
ONLINE ONLINE dominic2
ora.OCR_DATA.dg
ONLINE ONLINE dominic1
ONLINE ONLINE dominic2
ora.asm
ONLINE ONLINE dominic1 Started
ONLINE ONLINE dominic2 Started
ora.gsd
OFFLINE OFFLINE dominic1
OFFLINE OFFLINE dominic2
ora.net1.network
ONLINE ONLINE dominic1
ONLINE ONLINE dominic2
ora.ons
ONLINE ONLINE dominic1
ONLINE ONLINE dominic2
ora.registry.acfs
ONLINE ONLINE dominic1
ONLINE ONLINE dominic2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE dominic1
ora.cvu
1 ONLINE ONLINE dominic1
ora.dominic.db
1 OFFLINE OFFLINE
2 OFFLINE OFFLINE
ora.dominic1.vip
1 ONLINE ONLINE dominic1
ora.dominic2.vip
1 ONLINE ONLINE dominic2
ora.oc4j
1 ONLINE ONLINE dominic1
ora.scan1.vip
1 ONLINE ONLINE dominic1
这里并没有启动,因为我们的服务是刚添加上来的,还没有同步。 我们启动一下就ok了
[grid@dominic1 ~]$ srvctl start database -d dominic
=========================(以上都在节点一操作)