科隆数据库Tru64 Unix(81740)

 

 

 

 

 

 

科隆数据库Tru64 Unix(81740)

 

 

 

 

作者:张大鹏(Lunar

                           Email:  moonlunar@163.com

                            MSN:  lunar52@hotmail.com

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

制作测试数据.... 3

再开一个窗口,作checkpoint... 4

收集必要的系统信息,检查磁盘空间.... 5

做热备.... 6

查看热备日志... 6

查看备份文件... 10

科隆数据库.... 10

建立必要的目录... 10

设置实例名... 11

查看现在的SID.. 11

新建一个SID.. 12

修改监听文件(LISTENER.ORA... 12

重新启动监听... 13

修改客户端tnsnames文件... 14

修改备份的控制文件,以备后面创建数据库使用... 14

将参数文件拷贝到pfile目录中... 15

修改科隆数据库的参数文件... 15

创建口令文件... 16

创建口令文件和控制文件的注意事项... 16

使用新的sidnomount启动数据库... 19

创建控制文件... 19

恢复数据库... 20

使用 recover database using backup controlfile;恢复数据库... 20

使用 recover database until cancel using backup controlfile; 再次恢复数据库... 21

使用resetlogs打开数据库... 21

验证科隆的数据(实例名:clonedb,数据库名:clonedb... 22

和老数据库对比... 23

清除科隆数据库.... 25

确定是科隆的数据库... 25

shutdown 数据库(shutdown abort就可以)... 25

修改监听文件(LISTENER.ORA... 26

重新启动监听... 26

修改客户端tnsnames文件... 27

清除数据库文件... 28

检查磁盘空间... 29

 

 

制作测试数据

feptwo> uname -a

OSF1 feptwo V4.0 1229 alpha

feptwo>

feptwo>

feptwo> env | grep ORA

ORACLE_SID=o817

ORA_NLS33=/usr/oracle/app/oracle/product/8.1.7/ocommon/nls/admin/data

ORACLE_HOME=/usr/oracle/app/oracle/product/8.1.7

feptwo>

feptwo>

feptwo> sqlplus internal

 

SQL*Plus: Release 8.1.7.0.0 - Production on Thu Feb 13 12:52:34 2003

 

(c) Copyright 2000 Oracle Corporation.  All rights reserved.

 

 

Connected to:

Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production

JServer Release 8.1.7.4.0 - Production

 

SQL> conn lunar/lunarz

Connected.

SQL> select * from tab;

 

no rows selected

 

SQL> create table test(a number);

 

Table created.

 

SQL> insert into test values(10);

 

1 row created.

 

SQL> insert into test values(11);

 

1 row created.

 

SQL> c/11/12

  1* insert into test values(12)

SQL> /

 

1 row created.

 

SQL> commit;

 

Commit complete.

 

SQL> select * from test;

 

         A

----------

        10

        11

        12

 

SQL> insert  into test values(55);

 

1 row created.

 

SQL>    

 

 

再开一个窗口,作checkpoint

Digital UNIX (feptwo) (ttyp2)

 

login: oracle

Password:

Last login: Thu Feb 13 11:44:42 from 192.168.2.28

 

Digital UNIX V4.0F  (Rev. 1229); Wed May 16 14:57:14 CST 2001

 

The installation software has successfully installed your system.

 

There are logfiles that contain a record of your installation.

These are:

 

        /var/adm/smlogs/install.cdf     - configuration description file

        /var/adm/smlogs/install.log     - general log file

        /var/adm/smlogs/install.FS.log  - file system creation logs

        /var/adm/smlogs/setld.log       - log for the setld(8) utility

        /var/adm/smlogs/fverify.log     - verification log file

 

 

feptwo> sqlplus internal

 

SQL*Plus: Release 8.1.7.0.0 - Production on Thu Feb 13 13:38:33 2003

 

(c) Copyright 2000 Oracle Corporation.  All rights reserved.

 

 

Connected to:

Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production

JServer Release 8.1.7.4.0 - Production

 

SQL> alter system checkpoint;

 

System altered.

 

SQL>

 

 

收集必要的系统信息,检查磁盘空间

$ df -k

Filesystem       1024-blocks        Used   Available Capacity  Mounted on

root_domain#root      533664      249580      273608    48%    /

/proc                      0           0           0   100%    /proc

usr_domain#usr       6748128     6500991      566192    98%    /usr

$

 

SQL> select sum(bytes)/1024/1024 as "sum(M)" from dba_data_files;

 

 

    sum(M)

----------

     372.5

 

SQL> select name from v$controlfile;

 

NAME

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

/usr/oracle/data/oradata/cint208/control01.ctl

/usr/oracle/data/oradata/cint208/control02.ctl

/usr/oracle/data/oradata/cint208/control03.ctl

 

SQL>  column member format a50

SQL>  select * from v$logfile;

 

    GROUP# STATUS  MEMBER

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

         1         /usr/oracle/data/oradata/cint208/redo03.log

         2         /usr/oracle/data/oradata/cint208/redo02.log

         3         /usr/oracle/data/oradata/cint208/redo01.log

 

SQL>  select file_name from dba_data_files;

 

FILE_NAME

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

/usr/oracle/data/oradata/cint208/tools01.dbf

/usr/oracle/data/oradata/cint208/drsys01.dbf

/usr/oracle/data/oradata/cint208/users01.dbf

/usr/oracle/data/oradata/cint208/indx01.dbf

/usr/oracle/data/oradata/cint208/rbs01.dbf

/usr/oracle/data/oradata/cint208/temp01.dbf

/usr/oracle/data/oradata/cint208/system01.dbf

/usr/oracle/data/oradata/cint208/testspace1.dbf

 

8 rows selected.

 

SQL>

 

 

做热备

$ ./dobackup.sh > full20030213.log

$

 

 

查看热备日志

full20030213.log文件内容:

Thu Feb 13 13:42:00 CST 2003

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

 

SQL*Plus: Release 8.1.7.0.0 - Production on Thu Feb 13 13:42:00 2003

 

(c) Copyright 2000 Oracle Corporation.  All rights reserved.

 

 

Connected to:

Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production

JServer Release 8.1.7.4.0 - Production

 

Thu Feb 13 13:42:01 CST 2003

 

 

Connected.

BEGINING ARCHIVE LOG NUMBER IS :

     1      1         94     512000      1 NO  CURRENT

       786770 13-FEB-03

 

     2      1         92     512000      1 YES INACTIVE

       786734 13-FEB-03

 

     3      1         93     512000      1 YES INACTIVE

       786752 13-FEB-03

 

 

 

 

1. Begin Backup Tablespace TOOLS.tools01.dbf  ...

 

Successed End Backup This File .

 

 

 

1. Begin Backup Tablespace DRSYS.drsys01.dbf  ...

 

Successed End Backup This File .

 

 

 

1. Begin Backup Tablespace USERS.users01.dbf  ...

 

Successed End Backup This File .

 

 

 

1. Begin Backup Tablespace INDX.indx01.dbf  ...

 

Successed End Backup This File .

 

 

 

1. Begin Backup Tablespace RBS.rbs01.dbf  ...

 

Successed End Backup This File .

 

 

 

1. Begin Backup Tablespace TEMP.temp01.dbf  ...

 

Successed End Backup This File .

 

 

 

1. Begin Backup Tablespace SYSTEM.system01.dbf  ...

 

Successed End Backup This File .

 

 

 

1. Begin Backup Tablespace TESTSPACE.testspace1.dbf  ...

 

Successed End Backup This File .

 

 

 

2. Begin Backup CONTROLFILE to /usr/oracle/backup/CTL.ctl  ...

Successed End Backup The CONTROLFILE .

 

 

 

3. Begin Backup CONTROLFILE To Trace  ...

Successed End Backup The CONTROLFILE .

 

 

 

4. Before Switch Log, The Current Log is:

     1      1         94     512000      1 NO  CURRENT

       786770 13-FEB-03

 

     2      1         92     512000      1 YES INACTIVE

       786734 13-FEB-03

 

     3      1         93     512000      1 YES INACTIVE

       786752 13-FEB-03

 

 

 

 

5. Begin Backup Switch Current Log  ...

Successed End Switch Log .

 

 

 

6. After Switch Log, The Ending Archive Log Number Is :

     1      1         94     512000      1 YES ACTIVE

       786770 13-FEB-03

 

     2      1         95     512000      1 NO  CURRENT

       786805 13-FEB-03

 

     3      1         93     512000      1 YES INACTIVE

       786752 13-FEB-03

 

 

 

 

Thu Feb 13 13:43:43 CST 2003

 

 

 

 

SQL>

SQL> --set termout on;

SQL>

SQL> exit;

Disconnected from Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production

JServer Release 8.1.7.4.0 - Production

Thu Feb 13 13:43:45 CST 2003

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

Begin backup today archive log files.....

Successed in backup archive files

 

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

Begin create tar file and cp to tape, please wait........................

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

Thu Feb 13 13:43:45 CST 2003

Successed in copy to tape.

Today Oracle Hot full backup is finished.

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

 

 

查看备份文件

$ pwd

/usr/oracle/backup

$ ls

DRSYS_drsys01.dbf         TEMP_temp01.dbf           arch                      dobackup.sh

INDX_indx01.dbf           TESTSPACE_testspace1.dbf  controlfile01.ctl         dobackup.sql

RBS_rbs01.dbf             TOOLS_tools01.dbf         createbackup.sh           full20030213.log

SYSTEM_system01.dbf       USERS_users01.dbf         dobackup.log              ora_19526.trc

$ ls arch

arch_1_81.arc  arch_1_83.arc  arch_1_85.arc  arch_1_87.arc  arch_1_89.arc  arch_1_91.arc  arch_1_93.arc

arch_1_82.arc  arch_1_84.arc  arch_1_86.arc  arch_1_88.arc  arch_1_90.arc  arch_1_92.arc  arch_1_94.arc

$ df -k

Filesystem       1024-blocks        Used   Available Capacity  Mounted on

root_domain#root      533664      249580      273608    48%    /

/proc                      0           0           0   100%    /proc

usr_domain#usr       6748128     6500991      184752    98%    /usr

$

 

 

科隆数据库

建立必要的目录

$ pwd

/usr/oracle/backup

$ mkdir pfile bdump cdump udump

$ ls -l

total 382398

-rw-r--r--   1 oracle   dba        5251072 Feb 13 13:42 DRSYS_drsys01.dbf

-rw-r--r--   1 oracle   dba        5251072 Feb 13 13:42 INDX_indx01.dbf

-rw-r--r--   1 oracle   dba       57679872 Feb 13 13:42 RBS_rbs01.dbf

-rw-r--r--   1 oracle   dba      283123712 Feb 13 13:43 SYSTEM_system01.dbf

-rw-r--r--   1 oracle   dba        5251072 Feb 13 13:42 TEMP_temp01.dbf

-rw-r-----   1 oracle   dba        5251072 Feb 13 13:43 TESTSPACE_testspace1.dbf

-rw-r--r--   1 oracle   dba        5251072 Feb 13 13:42 TOOLS_tools01.dbf

-rw-r--r--   1 oracle   dba       23601152 Feb 13 13:42 USERS_users01.dbf

drwxr-xr-x   2 oracle   dba           8192 Feb 13 13:43 arch

drwxr-xr-x   2 oracle   dba           8192 Feb 13 13:59 bdump

drwxr-xr-x   2 oracle   dba           8192 Feb 13 13:59 cdump

-rw-r-----   1 oracle   dba         843776 Feb 13 13:43 controlfile01.ctl

-rwxrwxrwx   1 oracle   dba           3475 Feb 13 12:04 createbackup.sh

-rw-r--r--   1 oracle   dba           7164 Feb 13 13:43 dobackup.log

-rwxrwxrwx   1 oracle   dba           1319 Feb 13 12:22 dobackup.sh

-rwxrwxrwx   1 oracle   dba          11370 Feb 13 12:07 dobackup.sql

-rw-r--r--   1 oracle   dba           3049 Feb 13 13:43 full20030213.log

-rw-r-----   1 oracle   dba           1922 Feb 13 13:43 ora_19526.trc

drwxr-xr-x   2 oracle   dba           8192 Feb 13 13:59 pfile

drwxr-xr-x   2 oracle   dba           8192 Feb 13 13:59 udump

 

 

设置实例名

查看现在的SID

feptwo> env | grep ORA

ORACLE_SID=o817

ORA_NLS33=/usr/oracle/app/oracle/product/8.1.7/ocommon/nls/admin/data

ORACLE_HOME=/usr/oracle/app/oracle/product/8.1.7

feptwo>

 

 

新建一个SID

feptwo> export ORACLE_SID=clonedb

feptwo> env | grep ORA

ORACLE_SID=clonedb

ORA_NLS33=/usr/oracle/app/oracle/product/8.1.7/ocommon/nls/admin/data

ORACLE_HOME=/usr/oracle/app/oracle/product/8.1.7

feptwo>

 

 

修改监听文件LISTENER.ORA

# LISTENER.ORA Network Configuration File: /usr/oracle/app/oracle/product/8.1.7/network/admin/listener.ora

# Generated by Oracle configuration tools.

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS_LIST =

        (ADDRESS = (PROTOCOL = TCP)(HOST = feptwo)(PORT = 1521))

      )

      (ADDRESS_LIST =

        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))

      )

    )

  )

 

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = PLSExtProc)

      (ORACLE_HOME = /usr/oracle/app/oracle/product/8.1.7)

      (PROGRAM = extproc)

    )

    (SID_DESC =

      (GLOBAL_DBNAME = cint208)

      (ORACLE_HOME = /usr/oracle/app/oracle/product/8.1.7)

      (SID_NAME = o817)

    )

    (SID_DESC =

      (ORACLE_HOME = /usr/oracle/app/oracle/product/8.1.7)

      (SID_NAME = clonedb)

    )

  )

 

 

重新启动监听

feptwo> lsnrctl

 

LSNRCTL for DEC OSF/1 AXP: Version 8.1.7.4.0 - Production on 13-FEB-2003 14:07:18

 

(c) Copyright 1998 Oracle Corporation.  All rights reserved.

 

Welcome to LSNRCTL, type "help" for information.

 

LSNRCTL> reload

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=feptwo)(PORT=1521)))

The command completed successfully

LSNRCTL> status

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=feptwo)(PORT=1521)))

STATUS of the LISTENER

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

Alias                     LISTENER

Version                   TNSLSNR for DEC OSF/1 AXP: Version 8.1.7.4.0 - Production

Start Date                13-FEB-2003 14:06:19

Uptime                    0 days 0 hr. 1 min. 5 sec

Trace Level               off

Security                  OFF

SNMP                      OFF

Listener Parameter File   /usr/oracle/app/oracle/product/8.1.7/network/admin/listener.ora

Listener Log File         /usr/oracle/app/oracle/product/8.1.7/network/log/listener.log

Services Summary...

  PLSExtProc            has 1 service handler(s)

  o817          has 1 service handler(s)

  o817          has 2 service handler(s)

  clonedb               has 1 service handler(s)

The command completed successfully

LSNRCTL>

 

 

修改客户端tnsnames文件

# TNSNAMES.ORA Network Configuration File: /usr/oracle/app/oracle/product/8.1.7/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

clonedb =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = feptwo)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVICE_NAME = clonedb)

    )

  )

 

 

feptwo> tnsping clonedb

 

TNS Ping Utility for DEC OSF/1 AXP: Version 8.1.7.4.0 - Production on 13-FEB-2003 14:09:14

 

(c) Copyright 1997 Oracle Corporation.  All rights reserved.

 

Attempting to contact (ADDRESS=(PROTOCOL=TCP)(HOST=feptwo)(PORT=1521))

OK (170 msec)

feptwo>

 

 

修改备份的控制文件,以备后面创建数据库使用

CREATE CONTROLFILE set DATABASE "clonedb" RESETLOGS  ARCHIVELOG

    MAXLOGFILES 16

    MAXLOGMEMBERS 2

    MAXDATAFILES 30

    MAXINSTANCES 1

    MAXLOGHISTORY 226

LOGFILE

  GROUP 1 '/usr/oracle/backup/redo03.log'  SIZE 500K,

  GROUP 2 '/usr/oracle/backup/redo02.log'  SIZE 500K,

  GROUP 3 '/usr/oracle/backup/redo01.log'  SIZE 500K

DATAFILE

  '/usr/oracle/backup/SYSTEM_system01.dbf',

  '/usr/oracle/backup/TOOLS_tools01.dbf',

  '/usr/oracle/backup/RBS_rbs01.dbf',

  '/usr/oracle/backup/TEMP_temp01.dbf',

  '/usr/oracle/backup/USERS_users01.dbf',

  '/usr/oracle/backup/INDX_indx01.dbf',

  '/usr/oracle/backup/DRSYS_drsys01.dbf',

  '/usr/oracle/backup/TESTSPACE_testspace1.dbf'

CHARACTER SET ZHS16GBK

;

 

 

将参数文件拷贝到pfile目录中

feptwo> pwd

/usr/oracle/app/oracle/product/8.1.7/admin/cint208/pfile

feptwo> cp $ORACLE_HOME/admin/cint208/pfile/inito817.ora

/usr/oracle/backup/pfile/initclonedb.ora

feptwo> cd /usr/oracle/backup

feptwo> ls -l /usr/oracle/backup/pfile

total 7

-rw-r--r--   1 oracle   dba         7120 Feb 13 14:14 initclonedb.ora

feptwo>

 

 

修改科隆数据库的参数文件

db_name = "clonedb"

instance_name = clonedb

service_names = clonedb

 

control_files = ("/usr/oracle/backup/control01.ctl",

"/usr/oracle/backup/control02.ctl",

"/usr/oracle/backup/control03.ctl")

 

 

log_archive_dest_1 = "location=/usr/oracle/backup/arch"

background_dump_dest = /usr/oracle/backup/bdump

core_dump_dest = /usr/oracle/backup/cdump

user_dump_dest = /usr/oracle/backup/udump

 

 

注意:

如果 remote_login_passwordfile = exclusive ,则需要先建立口令文件;

如果 remote_login_passwordfile = none ,则可以在科隆成功后建立口令文件(即,现用os认证方式);

这里设置为remote_login_passwordfile = exclusive

 

 

 

创建口令文件

$ orapwd file=/usr/oracle/app/oracle/product/8.1.7/dbs/orapw password=oracle entries=15

$ ls -l /usr/oracle/app/oracle/product/8.1.7/dbs/orapw

-rwSr-----   1 oracle   dba         4096 Feb 13 14:39 /usr/oracle/app/oracle/product/8.1.7/dbs/orapw

$

 

创建口令文件和控制文件的注意事项

1.      如果参数中指定了: remote_login_passwordfile = exclusive ,那么一定要先有口令文件,然后才能创建控制文件,否则就会有下面的错误:

SQL> startup nomount pfile=/usr/oracle/backup/pfile/initclonedb.ora

ORACLE instance started.

 

Total System Global Area   81884132 bytes

Fixed Size                   103396 bytes

Variable Size              57401344 bytes

Database Buffers           24199168 bytes

Redo Buffers                 180224 bytes

SQL> CREATE CONTROLFILE set DATABASE "clonedb" RESETLOGS  ARCHIVELOG

  2      MAXLOGFILES 16

  3      MAXLOGMEMBERS 2

  4      MAXDATAFILES 30

  5      MAXINSTANCES 1

  6      MAXLOGHISTORY 226

  7  LOGFILE

  8    GROUP 1 '/usr/oracle/backup/redo03.log'  SIZE 500K,

  9    GROUP 2 '/usr/oracle/backup/redo02.log'  SIZE 500K,

 10    GROUP 3 '/usr/oracle/backup/redo01.log'  SIZE 500K

 11  DATAFILE

 12    '/usr/oracle/backup/SYSTEM_system01.dbf',

 13    '/usr/oracle/backup/TOOLS_tools01.dbf',

 14    '/usr/oracle/backup/RBS_rbs01.dbf',

 15    '/usr/oracle/backup/TEMP_temp01.dbf',

 16    '/usr/oracle/backup/USERS_users01.dbf',

 17    '/usr/oracle/backup/INDX_indx01.dbf',

 18    '/usr/oracle/backup/DRSYS_drsys01.dbf',

 19    '/usr/oracle/backup/TESTSPACE_testspace1.dbf'

 20  CHARACTER SET ZHS16GBK

 21  ;

 

CREATE CONTROLFILE set DATABASE "clonedb" RESETLOGS  ARCHIVELOG

*

ERROR at line 1:

ORA-01503: CREATE CONTROLFILE failed

ORA-01990: error opening password file

'/usr/oracle/app/oracle/product/8.1.7/dbs/orapw'

 

 

SQL>

 

2.      如果出现类似上面的错误,一定要先删除这些创建失败的控制文件,否则就会有如下的错误:

SQL> startup nomount pfile=/usr/oracle/backup/pfile/initclonedb.ora

ORACLE instance started.

 

Total System Global Area   81884132 bytes

Fixed Size                   103396 bytes

Variable Size              57401344 bytes

Database Buffers           24199168 bytes

Redo Buffers                 180224 bytes

SQL> CREATE CONTROLFILE set DATABASE "clonedb" RESETLOGS  ARCHIVELOG

  2      MAXLOGFILES 16

  3      MAXLOGMEMBERS 2

  4      MAXDATAFILES 30

  5      MAXINSTANCES 1

  6      MAXLOGHISTORY 226

  7  LOGFILE

  8    GROUP 1 '/usr/oracle/backup/redo03.log'  SIZE 500K,

  9    GROUP 2 '/usr/oracle/backup/redo02.log'  SIZE 500K,

 10    GROUP 3 '/usr/oracle/backup/redo01.log'  SIZE 500K

 11  DATAFILE

 12    '/usr/oracle/backup/SYSTEM_system01.dbf',

 13    '/usr/oracle/backup/TOOLS_tools01.dbf',

 14    '/usr/oracle/backup/RBS_rbs01.dbf',

 15    '/usr/oracle/backup/TEMP_temp01.dbf',

 16    '/usr/oracle/backup/USERS_users01.dbf',

 17    '/usr/oracle/backup/INDX_indx01.dbf',

 18    '/usr/oracle/backup/DRSYS_drsys01.dbf',

 19    '/usr/oracle/backup/TESTSPACE_testspace1.dbf'

 20  CHARACTER SET ZHS16GBK

 21  ;

CREATE CONTROLFILE set DATABASE "clonedb" RESETLOGS  ARCHIVELOG

*

ERROR at line 1:

ORA-01503: CREATE CONTROLFILE failed

ORA-00200: controlfile could not be created

ORA-00202: controlfile: '/usr/oracle/backup/control01.ctl'

ORA-27038: skgfrcre: file exists

 

 

SQL>

 

3.      解决办法:删除这些创建失败的控制文件

$ ls

DRSYS_drsys01.dbf         TOOLS_tools01.dbf         control02.ctl             full20030213.log

INDX_indx01.dbf           USERS_users01.dbf         control03.ctl             ora_19526.trc

RBS_rbs01.dbf             arch                      createbackup.sh           orapw_clonedb.ora

SYSTEM_system01.dbf       bdump                     dobackup.log              pfile

TEMP_temp01.dbf           cdump                     dobackup.sh               udump

TESTSPACE_testspace1.dbf  control01.ctl             dobackup.sql

$ rm control*

$ ls

DRSYS_drsys01.dbf         TESTSPACE_testspace1.dbf  cdump                     full20030213.log

INDX_indx01.dbf           TOOLS_tools01.dbf         createbackup.sh           ora_19526.trc

RBS_rbs01.dbf             USERS_users01.dbf         dobackup.log              orapw_clonedb.ora

SYSTEM_system01.dbf       arch                      dobackup.sh               pfile

TEMP_temp01.dbf           bdump                     dobackup.sql              udump

$ exit

 

 

 

使用新的sidnomount启动数据库

feptwo> env | grep ORA

ORACLE_SID=clonedb

ORA_NLS33=/usr/oracle/app/oracle/product/8.1.7/ocommon/nls/admin/data

ORACLE_HOME=/usr/oracle/app/oracle/product/8.1.7

feptwo> sqlplus internal

 

SQL*Plus: Release 8.1.7.0.0 - Production on Thu Feb 13 14:23:10 2003

 

(c) Copyright 2000 Oracle Corporation.  All rights reserved.

 

Connected to an idle instance.

 

SQL> startup nomount pfile=/usr/oracle/backup/pfile/initclonedb.ora

ORACLE instance started.

 

Total System Global Area   81884132 bytes

Fixed Size                   103396 bytes

Variable Size              57401344 bytes

Database Buffers           24199168 bytes

Redo Buffers                 180224 bytes

SQL>

 

 

 

创建控制文件

SQL> CREATE CONTROLFILE set DATABASE "clonedb" RESETLOGS  ARCHIVELOG

  2      MAXLOGFILES 16

  3      MAXLOGMEMBERS 2

  4      MAXDATAFILES 30

  5      MAXINSTANCES 1

  6      MAXLOGHISTORY 226

  7  LOGFILE

  8    GROUP 1 '/usr/oracle/backup/redo03.log'  SIZE 500K,

  9    GROUP 2 '/usr/oracle/backup/redo02.log'  SIZE 500K,

 10    GROUP 3 '/usr/oracle/backup/redo01.log'  SIZE 500K

 11  DATAFILE

 12    '/usr/oracle/backup/SYSTEM_system01.dbf',

 13    '/usr/oracle/backup/TOOLS_tools01.dbf',

 14    '/usr/oracle/backup/RBS_rbs01.dbf',

 15    '/usr/oracle/backup/TEMP_temp01.dbf',

 16    '/usr/oracle/backup/USERS_users01.dbf',

 17    '/usr/oracle/backup/INDX_indx01.dbf',

 18    '/usr/oracle/backup/DRSYS_drsys01.dbf',

 19    '/usr/oracle/backup/TESTSPACE_testspace1.dbf'

 20  CHARACTER SET ZHS16GBK

 21  ;

 

Control file created.

 

SQL>

 

 

恢复数据库

使用 recover database using backup controlfile;恢复数据库

SQL>

SQL> recover database using backup controlfile;

ORA-00279: change 786788 generated at 02/13/2003 13:42:01 needed for thread 1

ORA-00289: suggestion : /usr/oracle/backup/arch/arch_1_94.arc

ORA-00280: change 786788 for thread 1 is in sequence #94

 

 

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

auto

ORA-00279: change 786805 generated at 02/13/2003 13:43:42 needed for thread 1

ORA-00289: suggestion : /usr/oracle/backup/arch/arch_1_95.arc

ORA-00280: change 786805 for thread 1 is in sequence #95

ORA-00278: log file '/usr/oracle/backup/arch/arch_1_94.arc' no longer needed

for this recovery

 

 

ORA-00308: cannot open archived log '/usr/oracle/backup/arch/arch_1_95.arc'

ORA-27037: unable to obtain file status

Compaq Tru64 UNIX Error: 2: No such file or directory

Additional information: 3

 

 

SQL>

 

 

 

使用 recover database until cancel using backup controlfile; 再次恢复数据库

SQL> recover database until cancel using backup controlfile;

ORA-00279: change 786805 generated at 02/13/2003 13:43:42 needed for thread 1

ORA-00289: suggestion : /usr/oracle/backup/arch/arch_1_95.arc

ORA-00280: change 786805 for thread 1 is in sequence #95

 

 

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

cancel

Media recovery cancelled.

SQL>

 

 

 

使用resetlogs打开数据库

SQL> alter database open resetlogs;

 

Database altered.

 

SQL> host

$ cd /usr/oracle/backup

$ ls -l

total 385990

-rw-r--r--   1 oracle   dba        5251072 Feb 13 14:50 DRSYS_drsys01.dbf

-rw-r--r--   1 oracle   dba        5251072 Feb 13 14:50 INDX_indx01.dbf

-rw-r--r--   1 oracle   dba       57679872 Feb 13 14:50 RBS_rbs01.dbf

-rw-r--r--   1 oracle   dba      283123712 Feb 13 14:50 SYSTEM_system01.dbf

-rw-r--r--   1 oracle   dba        5251072 Feb 13 14:50 TEMP_temp01.dbf

-rw-r-----   1 oracle   dba        5251072 Feb 13 14:50 TESTSPACE_testspace1.dbf

-rw-r--r--   1 oracle   dba        5251072 Feb 13 14:50 TOOLS_tools01.dbf

-rw-r--r--   1 oracle   dba       23601152 Feb 13 14:50 USERS_users01.dbf

drwxr-xr-x   2 oracle   dba           8192 Feb 13 13:43 arch

drwxr-xr-x   2 oracle   dba           8192 Feb 13 14:23 bdump

drwxr-xr-x   2 oracle   dba           8192 Feb 13 13:59 cdump

-rw-r-----   1 oracle   dba         991232 Feb 13 15:02 control01.ctl

-rw-r-----   1 oracle   dba         991232 Feb 13 15:02 control02.ctl

-rw-r-----   1 oracle   dba         991232 Feb 13 15:02 control03.ctl

-rwxrwxrwx   1 oracle   dba           3475 Feb 13 12:04 createbackup.sh

-rw-r--r--   1 oracle   dba           7164 Feb 13 13:43 dobackup.log

-rwxrwxrwx   1 oracle   dba           1319 Feb 13 12:22 dobackup.sh

-rwxrwxrwx   1 oracle   dba          11370 Feb 13 12:07 dobackup.sql

-rw-r--r--   1 oracle   dba           3049 Feb 13 13:43 full20030213.log

-rw-r-----   1 oracle   dba           1922 Feb 13 13:43 ora_19526.trc

drwxr-xr-x   2 oracle   dba           8192 Feb 13 14:14 pfile

-rw-r-----   1 oracle   dba         513024 Feb 13 14:54 redo01.log

-rw-r-----   1 oracle   dba         513024 Feb 13 14:50 redo02.log

-rw-r-----   1 oracle   dba         513024 Feb 13 14:50 redo03.log

drwxr-xr-x   2 oracle   dba           8192 Feb 13 14:50 udump

$

 

 

 

验证科隆的数据(实例名:clonedb,数据库名:clonedb

SQL> host

$ env | grep ORA

ORACLE_SID=clonedb

ORA_NLS33=/usr/oracle/app/oracle/product/8.1.7/ocommon/nls/admin/data

ORACLE_HOME=/usr/oracle/app/oracle/product/8.1.7

$ exit

 

SQL> select instance_name from v$instance;

 

INSTANCE_NAME

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

clonedb

 

SQL> select dbid,name , created from v$database;

 

      DBID NAME      CREATED

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

2205384091 CLONEDB   13-FEB-03

 

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /usr/oracle/backup/arch

Oldest online log sequence     0

Next log sequence to archive   1

Current log sequence           1

SQL> conn lunar/lunarz

Connected.

SQL> select * from tab;

 

TNAME                          TABTYPE  CLUSTERID

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

TEST                           TABLE

 

SQL> select * from test;

 

         A

----------

        10

        11

        12

 

SQL>

 

 

和老数据库对比

Digital UNIX (feptwo) (ttyp2)

 

login: oracle

Password:

Last login: Thu Feb 13 14:06:56 from 192.168.2.28

 

Digital UNIX V4.0F  (Rev. 1229); Wed May 16 14:57:14 CST 2001

 

The installation software has successfully installed your system.

 

There are logfiles that contain a record of your installation.

These are:

 

        /var/adm/smlogs/install.cdf     - configuration description file

        /var/adm/smlogs/install.log     - general log file

        /var/adm/smlogs/install.FS.log  - file system creation logs

        /var/adm/smlogs/setld.log       - log for the setld(8) utility

        /var/adm/smlogs/fverify.log     - verification log file

 

 

feptwo> env | grep ORA

ORACLE_SID=o817

ORA_NLS33=/usr/oracle/app/oracle/product/8.1.7/ocommon/nls/admin/data

ORACLE_HOME=/usr/oracle/app/oracle/product/8.1.7

feptwo> sqlplus internal

 

SQL*Plus: Release 8.1.7.0.0 - Production on Thu Feb 13 14:57:28 2003

 

(c) Copyright 2000 Oracle Corporation.  All rights reserved.

 

 

Connected to:

Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production

JServer Release 8.1.7.4.0 - Production

 

SQL> archive log list

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /usr/oracle/app/oracle/product/8.1.7/admin/cint208/arch

Oldest online log sequence     93

Next log sequence to archive   95

Current log sequence           95

SQL> select instance_name from v$instance;

 

INSTANCE_NAME

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

o817

 

SQL> select dbid,name , created from v$database;

 

      DBID NAME      CREATED

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

2205384091 CINT208   12-JUL-02

 

SQL> conn lunar/lunarz

Connected.

SQL> select * from tab;

 

TNAME                          TABTYPE  CLUSTERID

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

TEST                           TABLE

 

SQL> select * from test;

 

         A

----------

        10

        11

        12

        55  (这条数据在科隆前还没有归档,所以在科隆数据库中是没有的,也就是说它在redo log 中)

 

SQL>

 

 

清除科隆数据库

确定是科隆的数据库

SQL> host   

$ env | grep ORA

ORACLE_SID=clonedb

ORA_NLS33=/usr/oracle/app/oracle/product/8.1.7/ocommon/nls/admin/data

ORACLE_HOME=/usr/oracle/app/oracle/product/8.1.7

$ exit

 

 

shutdown 数据库(shutdown abort就可以)

SQL> conn internal

Connected.

SQL> shutdown abort

ORACLE instance shut down.

SQL> exit

Disconnected from Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production

JServer Release 8.1.7.4.0 - Production

feptwo>

 

 

修改监听文件(LISTENER.ORA

去掉刚才加上的那一段:

    (SID_DESC =

      (ORACLE_HOME = /usr/oracle/app/oracle/product/8.1.7)

      (SID_NAME = clonedb)

    )

 

 

重新启动监听

feptwo> lsnrctl

 

LSNRCTL for DEC OSF/1 AXP: Version 8.1.7.4.0 - Production on 13-FEB-2003 15:12:10

 

(c) Copyright 1998 Oracle Corporation.  All rights reserved.

 

Welcome to LSNRCTL, type "help" for information.

 

LSNRCTL> reload

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=feptwo)(PORT=1521)))

The command completed successfully

LSNRCTL> status

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=feptwo)(PORT=1521)))

STATUS of the LISTENER

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

Alias                     LISTENER

Version                   TNSLSNR for DEC OSF/1 AXP: Version 8.1.7.4.0 - Production

Start Date                13-FEB-2003 14:06:19

Uptime                    0 days 1 hr. 5 min. 58 sec

Trace Level               off

Security                  OFF

SNMP                      OFF

Listener Parameter File   /usr/oracle/app/oracle/product/8.1.7/network/admin/listener.ora

Listener Log File         /usr/oracle/app/oracle/product/8.1.7/network/log/listener.log

Services Summary...

  PLSExtProc            has 1 service handler(s)

  o817          has 1 service handler(s)

  o817          has 2 service handler(s)

The command completed successfully

LSNRCTL> exit

feptwo>

 

 

修改客户端tnsnames文件

# TNSNAMES.ORA Network Configuration File: /usr/oracle/app/oracle/product/8.1.7/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

 

去掉clonedb这个连接串:

clonedb =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = feptwo)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVICE_NAME = clonedb)

    )

  )

 

feptwo> tnsping clonedb

 

TNS Ping Utility for DEC OSF/1 AXP: Version 8.1.7.4.0 - Production on 13-FEB-2003 15:14:00

 

(c) Copyright 1997 Oracle Corporation.  All rights reserved.

 

TNS-03505: Failed to resolve name

feptwo>

 

 

清除数据库文件

feptwo> cd /usr/oracle/backup

feptwo> ls -l

total 385990

-rw-r--r--   1 oracle   dba        5251072 Feb 13 14:50 DRSYS_drsys01.dbf

-rw-r--r--   1 oracle   dba        5251072 Feb 13 14:50 INDX_indx01.dbf

-rw-r--r--   1 oracle   dba       57679872 Feb 13 14:50 RBS_rbs01.dbf

-rw-r--r--   1 oracle   dba      283123712 Feb 13 14:50 SYSTEM_system01.dbf

-rw-r--r--   1 oracle   dba        5251072 Feb 13 14:50 TEMP_temp01.dbf

-rw-r-----   1 oracle   dba        5251072 Feb 13 14:50 TESTSPACE_testspace1.dbf

-rw-r--r--   1 oracle   dba        5251072 Feb 13 14:50 TOOLS_tools01.dbf

-rw-r--r--   1 oracle   dba       23601152 Feb 13 14:50 USERS_users01.dbf

drwxr-xr-x   2 oracle   dba           8192 Feb 13 13:43 arch

drwxr-xr-x   2 oracle   dba           8192 Feb 13 14:23 bdump

drwxr-xr-x   2 oracle   dba           8192 Feb 13 13:59 cdump

-rw-r-----   1 oracle   dba         991232 Feb 13 15:08 control01.ctl

-rw-r-----   1 oracle   dba         991232 Feb 13 15:08 control02.ctl

-rw-r-----   1 oracle   dba         991232 Feb 13 15:08 control03.ctl

-rwxrwxrwx   1 oracle   dba           3475 Feb 13 12:04 createbackup.sh

-rw-r--r--   1 oracle   dba           7164 Feb 13 13:43 dobackup.log

-rwxrwxrwx   1 oracle   dba           1319 Feb 13 12:22 dobackup.sh

-rwxrwxrwx   1 oracle   dba          11370 Feb 13 12:07 dobackup.sql

-rw-r--r--   1 oracle   dba           3049 Feb 13 13:43 full20030213.log

-rw-r-----   1 oracle   dba           1922 Feb 13 13:43 ora_19526.trc

drwxr-xr-x   2 oracle   dba           8192 Feb 13 14:14 pfile

-rw-r-----   1 oracle   dba         513024 Feb 13 14:54 redo01.log

-rw-r-----   1 oracle   dba         513024 Feb 13 14:50 redo02.log

-rw-r-----   1 oracle   dba         513024 Feb 13 14:50 redo03.log

drwxr-xr-x   2 oracle   dba           8192 Feb 13 14:50 udump

feptwo> rm control* *trc redo* *dbf 

feptwo> ls -l

total 68

drwxr-xr-x   2 oracle   dba         8192 Feb 13 13:43 arch

drwxr-xr-x   2 oracle   dba         8192 Feb 13 14:23 bdump

drwxr-xr-x   2 oracle   dba         8192 Feb 13 13:59 cdump

-rwxrwxrwx   1 oracle   dba         3475 Feb 13 12:04 createbackup.sh

-rw-r--r--   1 oracle   dba         7164 Feb 13 13:43 dobackup.log

-rwxrwxrwx   1 oracle   dba         1319 Feb 13 12:22 dobackup.sh

-rwxrwxrwx   1 oracle   dba        11370 Feb 13 12:07 dobackup.sql

-rw-r--r--   1 oracle   dba         3049 Feb 13 13:43 full20030213.log

drwxr-xr-x   2 oracle   dba         8192 Feb 13 14:14 pfile

drwxr-xr-x   2 oracle   dba         8192 Feb 13 14:50 udump

feptwo> rm arch/* 

feptwo> ls arch

feptwo> rm -rf bdump cdump pfile udump

feptwo> ls -l

total 36

drwxr-xr-x   2 oracle   dba         8192 Feb 13 15:16 arch

-rwxrwxrwx   1 oracle   dba         3475 Feb 13 12:04 createbackup.sh

-rw-r--r--   1 oracle   dba         7164 Feb 13 13:43 dobackup.log

-rwxrwxrwx   1 oracle   dba         1319 Feb 13 12:22 dobackup.sh

-rwxrwxrwx   1 oracle   dba        11370 Feb 13 12:07 dobackup.sql

-rw-r--r--   1 oracle   dba         3049 Feb 13 13:43 full20030213.log

 

 

检查磁盘空间

feptwo> df -k

Filesystem       1024-blocks        Used   Available Capacity  Mounted on

root_domain#root      533664      249580      273608    48%    /

/proc                      0           0           0   100%    /proc

usr_domain#usr       6748128     6118494      567240    92%    /usr

feptwo>

 

好了,一切又恢复了,呵呵

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值