Digital UNIX (sce) (ttyp2)
login: oracle
Password:
Last login: Tue Oct 22 12:03:19 from 172.31.8.6
Digital UNIX V4.0F (Rev. 1229); Wed Aug 22 13:04:08 CST 2001
oracle@sce> ORACLE_SID=SCEDB;export ORACLE_SID
oracle@sce> sqlplus internal
SQL*Plus: Release 8.1.7.0.0 - Production on Tue Oct 22 12:32:36 2002
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to:
Oracle8i Release 8.1.7.0.0 - Production
JServer Release 8.1.7.0.0 - Production
SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle8i Release 8.1.7.0.0 - Production
JServer Release 8.1.7.0.0 - Production
oracle@sce> df -k
Filesystem 1024-blocks Used Available Capacity Mounted on
root_domain#root 262144 92876 169268 36% /
/proc 0 0 0 100% /proc
usr_domain#usr 2097152 1347333 692072 67% /usr
oracle_domain#u01 4954600 4138102 782080 85% /u01
oracle@sce> ORACLE_SID=NEW;export ORACLE_SID
oracle@sce> sqlplus internal
SQL*Plus: Release 8.1.7.0.0 - Production on Tue Oct 22 12:33:45 2002
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to:
Oracle8i Release 8.1.7.0.0 - Production
JServer Release 8.1.7.0.0 - Production
SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle8i Release 8.1.7.0.0 - Production
JServer Release 8.1.7.0.0 - Production
oracle@sce>
启动数据库SCEDB,然后做下面的操作
oracle@sce> ORACLE_SID=SCEDB;export ORACLE_SID
oracle@sce> env | grep ORACLE
ORACLE_BASE=/u01/oracle
ORACLE_HOME=/u01/oracle/OraHome1
ORACLE_SID=SCEDB
oracle@sce> sqlplus internal
SQL*Plus: Release 8.1.7.0.0 - Production on Tue Oct 22 12:36:51 2002
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 241939428 bytes
Fixed Size 103396 bytes
Variable Size 82542592 bytes
Database Buffers 159113216 bytes
Redo Buffers 180224 bytes
Database mounted.
Database opened.
SQL> exit
Disconnected
oracle@sce>
准备工作:
检查空间是否够用,然后做下面的操作
准备一些测试数据
oracle@sce> ORACLE_SID=SCEDB;export ORACLE_SID
oracle@sce> env | grep ORACLE
ORACLE_BASE=/u01/oracle
ORACLE_HOME=/u01/oracle/OraHome1
ORACLE_SID=SCEDB
oracle@sce>
oracle@sce> sqlplus internal
SQL*Plus: Release 8.1.7.0.0 - Production on Tue Oct 22 08:05:03 2002
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to:
Oracle8i Release 8.1.7.0.0 - Production
JServer Release 8.1.7.0.0 - Production
SQL> select * from dba_data_files;
FILE_NAME FILE_ID TABLESPACE_NAME BYTES BLOCKS STATUS RELATIVE_FNO AUTOEXTENSIBLE MAXBYTES MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS
-------------------------------------------------------------------------------- ---------- ------------------------------ ---------- ---------- --------- ------------ -------------- ---------- ---------- ------------ ---------- -----------
/u01/oracle/oradata/SCEDB/system01.dbf 1 SYSTEM 283115520 34560 AVAILABLE 1 YES 3435972198 4194302 1280 283107328 34559
/u01/oracle/oradata/SCEDB/tools01.dbf 2 TOOLS 8388608 1024 AVAILABLE 2 YES 3435972198 4194302 40 8380416 1023
/u01/oracle/oradata/SCEDB/rbs01.dbf 3 RBS 104857600 12800 AVAILABLE 3 YES 3435972198 4194302 640 104849408 12799
/u01/oracle/oradata/SCEDB/temp01.dbf 4 TEMP 71303168 8704 AVAILABLE 4 YES 3435972198 4194302 80 71294976 8703
/u01/oracle/oradata/SCEDB/users01.dbf 5 USERS 52428800 6400 AVAILABLE 5 YES 3435972198 4194302 160 52420608 6399
/u01/oracle/oradata/SCEDB/indx01.dbf 6 INDX 20971520 2560 AVAILABLE 6 YES 3435972198 4194302 160 20963328 2559
/u01/oracle/oradata/SCEDB/drsys01.dbf 7 DRSYS 88080384 10752 AVAILABLE 7 YES 3435972198 4194302 80 88072192 10751
/u01/oracle/oradata/SCEDB/lunar01.dbf 8 LUNAR 10485760 1280 AVAILABLE 8 NO 0 0 0 10477568 1279
8 rows selected
SQL> select * from v$controlfile;
STATUS NAME
------- --------------------------------------------------------------------------------
/u01/oracle/oradata/SCEDB/control01.ctl
/u01/oracle/oradata/SCEDB/control02.ctl
/u01/oracle/oradata/SCEDB/control03.ctl
SQL> select * from v$logfile;
GROUP# STATUS MEMBER
---------- ------- --------------------------------------------------------------------------------
1 /u01/oracle/oradata/SCEDB/redo01.log
2 /u01/oracle/oradata/SCEDB/redo02.log
3 STALE /u01/oracle/oradata/SCEDB/redo03.log
SQL> select sum(bytes) from dba_data_files;
SUM(BYTES)
----------
639631360
SQL>
SQL> select file_name Datafile_name
2 , tablespace_name
3 , to_char(bytes/1024/1024) || 'M' mbytes
4 from dba_data_files
5 order by file_name
6 , tablespace_name
7 /
DATAFILE_NAME TABLESPACE_NAME MBYTES
-------------------------------------------------------------------------------- ------------------------------ -----------------------------------------
/u01/oracle/oradata/SCEDB/drsys01.dbf DRSYS 84M
/u01/oracle/oradata/SCEDB/indx01.dbf INDX 20M
/u01/oracle/oradata/SCEDB/lunar01.dbf LUNAR 10M
/u01/oracle/oradata/SCEDB/rbs01.dbf RBS 100M
/u01/oracle/oradata/SCEDB/system01.dbf SYSTEM 270M
/u01/oracle/oradata/SCEDB/temp01.dbf TEMP 68M
/u01/oracle/oradata/SCEDB/tools01.dbf TOOLS 8M
/u01/oracle/oradata/SCEDB/users01.dbf USERS 50M
8 rows selected
SQL>
SQL> select b.file_id file_ID,
2 b.tablespace_name tablespace_name,
3 b.bytes Bytes,
4 (b.bytes-sum(nvl(a.bytes,0))) used,
5 sum(nvl(a.bytes,0)) free,
6 sum(nvl(a.bytes,0))/(b.bytes)*100 Percent
7 from dba_free_space a,dba_data_files b
8 where a.file_id=b.file_id
9 group by b.tablespace_name,b.file_id,b.bytes
10 order by b.file_id
11 /
FILE_ID TABLESPACE_NAME BYTES USED FREE PERCENT
---------- ------------------------------ ---------- ---------- ---------- ----------
1 SYSTEM 283115520 269959168 13156352 4.64699074
2 TOOLS 8388608 40960 8347648 99.5117187
3 RBS 104857600 20979712 83877888 79.9921875
4 TEMP 71303168 8192 71294976 99.9885110
5 USERS 52428800 8192 52420608 99.984375
6 INDX 20971520 8192 20963328 99.9609375
7 DRSYS 88080384 4333568 83746816 95.0799851
8 LUNAR 10485760 49152 10436608 99.53125
8 rows selected
SQL> conn lunar/lunar
Connected.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
TEST TABLE
SQL> select * from test;
A
----------
1
SQL> insert into test values(2);
1 row created.
SQL> commit;
Commit complete.
SQL> insert into test values(3);
1 row created.
SQL> select * from test;
A
----------
1
2
3
SQL>
注意 3 是没提交的,2已经提交,但是2还没有被归档
也就是这两条数据都在redo中,但是状态不同
新开一个窗口作switch log:
Digital UNIX (sce) (ttyp1)
login: oracle
Password:
Last login: Tue Oct 22 12:32:18 from 172.31.8.6
Digital UNIX V4.0F (Rev. 1229); Wed Aug 22 13:04:08 CST 2001
oracle@sce> ORACLE_SID=SCEDB;export ORACLE_SID
oracle@sce> sqlplus internal
SQL*Plus: Release 8.1.7.0.0 - Production on Tue Oct 22 12:50:11 2002
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to:
Oracle8i Release 8.1.7.0.0 - Production
JServer Release 8.1.7.0.0 - Production
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/oracle/admin/SCEDB/arch
Oldest online log sequence 2774
Next log sequence to archive 2776
Current log sequence 2776
SQL> alter system switch logfile;
System altered.
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/oracle/admin/SCEDB/arch
Oldest online log sequence 2775
Next log sequence to archive 2777
Current log sequence 2777
SQL>
SQL> exit
Disconnected from Oracle8i Release 8.1.7.0.0 - Production
JServer Release 8.1.7.0.0 - Production
到现在为止,用户lunar的表test中有2条被归档,即 1 和 2
还有一条没有提交的在redo 中,即3;
现在在新窗口(sqlplus internal)中做热备,当前的archive log为2777,
注意观察热备结束后的archive log,并记录下来,以便对照数据回复的情况。
一、确定ORACLE_SID
oracle@sce> ORACLE_SID=SCEDB;export ORACLE_SID
oracle@sce> sqlplus internal
SQL*Plus: Release 8.1.7.0.0 - Production on Tue Oct 22 08:05:03 2002
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to:
Oracle8i Release 8.1.7.0.0 - Production
JServer Release 8.1.7.0.0 - Production
SQL> exit
Disconnected from Oracle8i Release 8.1.7.0.0 - Production
JServer Release 8.1.7.0.0 - Production
二、如果下列目录不存在,先创建下列目录
oracle@sce> cd /u01/oracle/backup2
在/u01/oracle/backup2建立科隆数据库需要的目录
mkdir adhoc
mkdir bdump
mkdir cdump
mkdir arch
mkdir create
mkdir exp
mkdir udump
mkdir pfile
oracle@sce> ls
oracle@sce>
三、检查磁盘空间,如果够用,就创建热备
oracle@sce> df -k
Filesystem 1024-blocks Used Available Capacity Mounted on
root_domain#root 262144 92876 169268 36% /
/proc 0 0 0 100% /proc
usr_domain#usr 2097152 1347469 691936 67% /usr
oracle_domain#u01 4954600 4138277 781928 85% /u01
oracle@sce>
oracle@sce> cd /u01/oracle/back_script
oracle@sce> ls hotback2.sh
hotback2.sh
oracle@sce> hotback2.sh
Tue Oct 22 13:27:13 GMT+0700 2002
SQL*Plus: Release 8.1.7.0.0 - Production on Tue Oct 22 13:27:13 2002
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to:
Oracle8i Release 8.1.7.0.0 - Production
JServer Release 8.1.7.0.0 - Production
Tue Oct 22 13:27:13 GMT+0700 2002
Connected.
BEGINING ARCHIVE LOG NUMBER IS :
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/oracle/admin/SCEDB/arch
Oldest online log sequence 2776
Next log sequence to archive 2778
Current log sequence 2778
Begin Backup Tablespace SYSTEM ...
Successed End Backup This File .
Begin Backup Tablespace TOOLS ...
Successed End Backup This File .
Begin Backup Tablespace RBS ...
Successed End Backup This File .
Begin Backup Tablespace TEMP ...
Successed End Backup This File .
Begin Backup Tablespace USERS ...
Successed End Backup This File .
Begin Backup Tablespace INDX ...
Successed End Backup This File .
Begin Backup Tablespace DRSYS ...
Successed End Backup This File .
Begin Backup Tablespace LUNAR ...
Successed End Backup This File .
Begin Backup CONTROLFILE to /u01/oracle/backup2/controlfile01.ctl ...
Successed End Backup The CONTROLFILE .
Begin Backup CONTROLFILE To Trace ...
Successed End Backup The CONTROLFILE .
Before Switch Log, The Current Log is:
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/oracle/admin/SCEDB/arch
Oldest online log sequence 2776
Next log sequence to archive 2778
Current log sequence 2778
Begin Backup Switch Current Log ...
Successed End Switch Log .
After Switch Log, The Ending Archive Log Number Is :
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/oracle/admin/SCEDB/arch
Oldest online log sequence 2777
Next log sequence to archive 2779
Current log sequence 2779
Tue Oct 22 13:29:35 GMT+0700 2002
Start Backup Archive log (arch1) ...
End Backup Archive log (arch1) ...
Tue Oct 22 13:29:35 GMT+0700 2002
Tue Oct 22 13:29:35 GMT+0700 2002
SQL>
SQL> --set termout on;
SQL>
SQL> exit;
Disconnected from Oracle8i Release 8.1.7.0.0 - Production
JServer Release 8.1.7.0.0 - Production
Tue Oct 22 13:29:38 GMT+0700 2002
oracle@sce>
四、确认热备正确(包括检查热备的日志)
oracle@sce> cd /u01/oracle/backup2
oracle@sce> ls -l
total 629293
drwxr-xr-x 2 oracle dba 8192 Oct 22 13:03 adhoc
drwxr-xr-x 2 oracle dba 8192 Oct 22 13:29 arch
drwxr-xr-x 2 oracle dba 8192 Oct 22 13:03 bdump
drwxr-xr-x 2 oracle dba 8192 Oct 22 13:03 cdump
-rw-r----- 1 oracle dba 4628480 Oct 22 13:29 controlfile01.ctl
drwxr-xr-x 2 oracle dba 8192 Oct 22 13:03 create
-rw-r----- 1 oracle dba 88088576 Oct 22 13:29 drsys01.dbf
drwxr-xr-x 2 oracle dba 8192 Oct 22 13:03 exp
-rw-r----- 1 oracle dba 20979712 Oct 22 13:29 indx01.dbf