oracle實驗記錄 (oracle 10G rman transport database)

fufuh2o發表於2009-11-10

C:\>sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 11月 2 14:19:54 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> create table t1 (a int);

表已建立。

 

SQL> insert into t1 values(1);

已建立 1 行。

SQL> commit;

提交完成。

SQL> shutdown immediate;
SQL> startup mount
ORACLE 例程已經啟動。

Total System Global Area  289406976 bytes
Fixed Size                  1248576 bytes
Variable Size              83886784 bytes
Database Buffers          197132288 bytes
Redo Buffers                7139328 bytes
資料庫裝載完畢。

SQL> alter database open read only;

資料庫已更改。

SQL> set serveroutput on
SQL> ed
已寫入 file afiedt.buf

  1  declare
  2   db_ready boolean;
  3   begin
  4   db_ready := dbms_tdb.check_db('Linux IA (32-bit)');
  5*  end;
SQL> /

PL/SQL 過程已成功完成。

SQL> ed
已寫入 file afiedt.buf

  1  declare
  2   external boolean;
  3  begin
  4   external := dbms_tdb.check_external;
  5* end;
SQL> /
The following external tables exist in the database:
SH.SALES_TRANSACTIONS_EXT
The following directories exist in the database:
SYS.DATA_PUMP_DIR, SYS.ADMIN_DIR, SYS.WORK_DIR, SYS.DATA_FILE_DIR,
SYS.LOG_FILE_DIR, SYS.MEDIA_DIR, SYS.XMLDIR, SYS.SUBDIR
The following BFILEs exist in the database:
PM.PRINT_MEDIA

PL/SQL 過程已成功完成。

 


RMAN> convert database new database 'xhtr'
2> transport script. 'e:\datafile\t.sql'
3> to platform. 'Linux IA (32-bit)'
4> db_file_name_convert 'G:\oracle\product\10.2.0\oradata\xh' 'e:\datafile'
5> ;

啟動 convert 於 02-11月-09
使用通道 ORA_DISK_1

在資料庫中找到外部表 SH.SALES_TRANSACTIONS_EXT

在資料庫中找到目錄 SYS.DATA_PUMP_DIR
在資料庫中找到目錄 SYS.ADMIN_DIR
在資料庫中找到目錄 SYS.WORK_DIR
在資料庫中找到目錄 SYS.DATA_FILE_DIR
在資料庫中找到目錄 SYS.LOG_FILE_DIR
在資料庫中找到目錄 SYS.MEDIA_DIR
在資料庫中找到目錄 SYS.XMLDIR
在資料庫中找到目錄 SYS.SUBDIR

在資料庫中找到 BFILE PM.PRINT_MEDIA

在口令檔案中找到使用者 SYS (具有 SYSDBA and SYSOPER 許可權)
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案 fno=00001 name=G:\ORACLE\PRODUCT\10.2.0\ORADATA\XH\SYSTEM01.DBF
已轉換的資料檔案 = E:\DATAFILE\SYSTEM01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:55
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案 fno=00003 name=G:\ORACLE\PRODUCT\10.2.0\ORADATA\XH\SYSAUX01.DBF
已轉換的資料檔案 = E:\DATAFILE\SYSAUX01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:25
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案 fno=00005 name=G:\ORACLE\PRODUCT\10.2.0\ORADATA\XH\EXAMPLE01.DBF
已轉換的資料檔案 = E:\DATAFILE\EXAMPLE01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:15
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案 fno=00002 name=G:\ORACLE\PRODUCT\10.2.0\ORADATA\XH\UNDOTBS01.DBF
已轉換的資料檔案 = E:\DATAFILE\UNDOTBS01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:07
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案 fno=00004 name=G:\ORACLE\PRODUCT\10.2.0\ORADATA\XH\USERS01.DBF
已轉換的資料檔案 = E:\DATAFILE\USERS01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:01
在目標平臺上執行 SQL 指令碼 E:\DATAFILE\T.SQL 以建立資料庫
編輯 init.ora 檔案 G:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\INIT_00KTBLGL_1_0.ORA
。此 PFILE 將用於在目標平臺上建立資料庫據
要重新編譯所有 PL/SQL 模組, 請在目標平臺上執行 utlirp.sql 和 utlrp.sql
要更改內部資料庫識別符號, 請使用 DBNEWID 實用程式
完成 backup 於 02-11月-09

 

 


[root@oracle ~]# cd /
[root@oracle /]# mkdir oracletr
[root@oracle /]# chown oracle oracletr
[root@oracle /]# chown oracle oracletr
[root@oracle /]# su - oracle
[oracle@oracle ~]$ cd /oracletr
[oracle@oracle oracletr]$ mkdir datafile
[oracle@oracle oracletr]$ mkdir adump bdump cdump dpdump pfile udump
[oracle@oracle oracletr]$ ll
total 28
drwxr-xr-x  2 oracle oinstall 4096 Nov  2 03:36 adump
drwxr-xr-x  2 oracle oinstall 4096 Nov  2 03:36 bdump
drwxr-xr-x  2 oracle oinstall 4096 Nov  2 03:36 cdump
drwxr-xr-x  2 oracle oinstall 4096 Nov  2 03:35 datafile
drwxr-xr-x  2 oracle oinstall 4096 Nov  2 03:36 dpdump
drwxr-xr-x  2 oracle oinstall 4096 Nov  2 03:36 pfile
drwxr-xr-x  2 oracle oinstall 4096 Nov  2 03:36 udump

編輯生成的指令碼 和 pfile(主要改路徑)
指令碼在 e:\datafile\t.sql

-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- The contents of online logs will be lost and all backups will
-- be invalidated. Use this only if online logs are damaged.

-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE

STARTUP NOMOUNT PFILE='/oracletr/pfile/INIT_00KTBLGL_1_0.ORA'

-- Create SPFILE
CREATE SPFILE FROM PFILE = '/oracletr/pfile/INIT_00KTBLGL_1_0.ORA';
 

STARTUP FORCE NOMOUNT
CREATE CONTROLFILE REUSE SET DATABASE "XHTR" RESETLOGS FORCE LOGGING ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/oracletr/datafile/redo01.log'  SIZE 10M,
  GROUP 2 '/oracletr/datafile/redo02.log'  SIZE 10M,
  GROUP 3 '/oracletr/datafile/redo03.log'  SIZE 10M
DATAFILE
  '/oracletr/datafile/SYSTEM01.DBF',
  '/oracletr/datafile/UNDOTBS01.DBF',
  '/oracletr/datafile/SYSAUX01.DBF',
  '/oracletr/datafile/USERS01.DBF',
  '/oracletr/datafile/EXAMPLE01.DBF'
CHARACTER SET ZHS16GBK
;

-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;

-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE 'G:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\DATA_D-XHTR_I-3097375337_TS-TEMP_FNO-1_00KTBLGL'
     SIZE 20971520  AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
-- End of tempfile additions.
--

set echo off
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prompt * Your database has been created successfully!
prompt * There are many things to think about for the new database. Here
prompt * is a checklist to help you stay on track:
prompt * 1. You may want to redefine the location of the directory objects.
prompt * 2. You may want to change the internal database identifier (DBID)
prompt *    or the global database name for this database. Use the
prompt *    NEWDBID Utility (nid).
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SHUTDOWN IMMEDIATE
STARTUP UPGRADE
@@ ?/rdbms/admin/utlirp.sql
SHUTDOWN IMMEDIATE
STARTUP
-- The following step will recompile all PL/SQL modules.
-- It may take serveral hours to complete.
@@ ?/rdbms/admin/utlrp.sql
set feedback 6;

pfile在  G:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\INIT_00KTBLGL_1_0.ORA
# Please change the values of the following parameters:

  control_files            = "/oracletr/datafile/control01.ctl"

  db_recovery_file_dest    = "/oracletr/datafile"

  db_recovery_file_dest_size= 2147483648

  audit_file_dest          = "/oracletr/adump"

  background_dump_dest     = "/oracletr/bdump"

  user_dump_dest           = "/oracletr/udump"

  core_dump_dest           = "/oracletr/cdump"

  db_name                  = "XHTR"

 

# Please review the values of the following parameters:

  __shared_pool_size       = 75497472

  __large_pool_size        = 4194304

  __java_pool_size         = 4194304

  __streams_pool_size      = 0

  __db_cache_size          = 197132288

  remote_login_passwordfile= "EXCLUSIVE"

  db_domain                = ""

  dispatchers              = "(PROTOCOL=TCP) (SERVICE=xhXDB)"

 

# The values of the following parameters are from source database:

  processes                = 150

  sga_target               = 289406976

  db_block_size            = 8192

  compatible               = "10.2.0.1.0"

  db_file_multiblock_read_count= 16

  undo_management          = "AUTO"

  undo_tablespace          = "UNDOTBS1"

  job_queue_processes      = 10

  open_cursors             = 300

  pga_aggregate_target     = 95420416

 


通過FTP將檔案傳入相應的目錄

[oracle@oracle oracletr]$ export ORACLE_SID=xhtr
[oracle@oracle oracletr]$ sqlplus '/ as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Nov 2 03:47:15 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> STARTUP NOMOUNT PFILE='/oracletr/pfile/INIT_00KTBLGL_1_0.ORA'
ORA-00371: not enough shared pool memory, should be atleast 72265318 bytes
[oracle@oracle ~]$ vi /oracletr/pfile/INIT_00KTBLGL_1_0.ORA(修改下shared pool 大小)

[oracle@oracle ~]$ export ORACLE_SID=xhtr
[oracle@oracle ~]$ sqlplus ' / as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Nov 2 04:34:16 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.
可以直接執行t.sql指令碼 ,也可跟下面一樣 一步一步執行

SQL> STARTUP NOMOUNT PFILE='/oracletr/pfile/INIT_00KTBLGL_1_0.ORA'
ORACLE instance started.

Total System Global Area  264241152 bytes
Fixed Size                  1218868 bytes
Variable Size              88082124 bytes
Database Buffers          171966464 bytes
Redo Buffers                2973696 bytes


SQL> CREATE CONTROLFILE REUSE SET DATABASE "XHTR" RESETLOGS FORCE LOGGING ARCHIVELOG
  2      MAXLOGFILES 16
  3      MAXLOGMEMBERS 3
  4      MAXDATAFILES 100
  5      MAXINSTANCES 8
  6      MAXLOGHISTORY 292
  7  LOGFILE
  8    GROUP 1 '/oracletr/datafile/redo01.log'  SIZE 10M,
  9    GROUP 2 '/oracletr/datafile/redo02.log'  SIZE 10M,
 10    GROUP 3 '/oracletr/datafile/redo03.log'  SIZE 10M
 11  DATAFILE
 12    '/oracletr/datafile/SYSTEM01.DBF',
 13    '/oracletr/datafile/UNDOTBS01.DBF',
 14    '/oracletr/datafile/SYSAUX01.DBF',
 15    '/oracletr/datafile/USERS01.DBF',
 16    '/oracletr/datafile/EXAMPLE01.DBF'
 17  CHARACTER SET ZHS16GBK
 18  ;
CREATE CONTROLFILE REUSE SET DATABASE "XHTR" RESETLOGS FORCE LOGGING ARCHIVELOG
*
ERROR at line 1:
ORA-01503: CREATE CONTROLFILE failed
ORA-01130: database file version 10.2.0.1.0 incompatible with ORACLE version
10.2.0.0.0
ORA-01110: data file 1: '/oracletr/datafile/SYSTEM01.DBF'


[oracle@oracle ~]$ vi /oracletr/pfile/INIT_00KTBLGL_1_0.ORA

# Please review the values of the following parameters:

  __shared_pool_size       = 268435546

  __large_pool_size        = 4194304

  __java_pool_size         = 4194304

  __streams_pool_size      = 0

  __db_cache_size          = 197132288

  remote_login_passwordfile= "EXCLUSIVE"

  db_domain                = ""

  dispatchers              = "(PROTOCOL=TCP) (SERVICE=xhXDB)"

  sga_target               = 250m

# The values of the following parameters are from source database:

  processes                = 150
  compatible               =10.2.0.1.0~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~加上


SQL> shutdown immediate
ORA-01507: database not mounted


ORACLE instance shut down. " - rest of line ignored.
SQL> STARTUP NOMOUNT PFILE='/oracletr/pfile/INIT_00KTBLGL_1_0.ORA'
ORACLE instance started.d "

Total System Global Area  264241152 bytes
Fixed Size                  1218868 bytes
Variable Size              88082124 bytes
Database Buffers          171966464 bytes
Redo Buffers                2973696 bytes
SQL> STARTUP NOMOUNT PFILE='/oracletr/pfile/INIT_00KTBLGL_1_0.ORA'
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> CREATE CONTROLFILE REUSE SET DATABASE "XHTR" RESETLOGS FORCE LOGGING ARCHIVELOG
  2      MAXLOGFILES 16
  3      MAXLOGMEMBERS 3
  4      MAXDATAFILES 100
  5      MAXINSTANCES 8
  6      MAXLOGHISTORY 292
  7  LOGFILE
  8    GROUP 1 '/oracletr/datafile/redo01.log'  SIZE 10M,
  9    GROUP 2 '/oracletr/datafile/redo02.log'  SIZE 10M,
 10    GROUP 3 '/oracletr/datafile/redo03.log'  SIZE 10M
 11  DATAFILE
 12    '/oracletr/datafile/SYSTEM01.DBF',
 13    '/oracletr/datafile/UNDOTBS01.DBF',
 14    '/oracletr/datafile/SYSAUX01.DBF',
 15    '/oracletr/datafile/USERS01.DBF',
 16    '/oracletr/datafile/EXAMPLE01.DBF'
 17  CHARACTER SET ZHS16GBK
 18  ;


Control file created.


SQL> alter database open resetlogs;

Database altered.

SQL> set echo off
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> staa^H
SP2-0042: unknown command "sta" - rest of line ignored.
SQL> startup upgrade pfile='/oracletr/pfile/INIT_00KTBLGL_1_0.ORA'
ORACLE instance started.

Total System Global Area  264241152 bytes
Fixed Size                  1218868 bytes
Variable Size              88082124 bytes
Database Buffers          171966464 bytes
Redo Buffers                2973696 bytes
Database mounted.
Database opened.

SQL> ALTER TABLESPACE TEMP ADD TEMPFILE 'G:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\DATA_D-XHTR_I-3097375337_TS-TEMP_FNO-1_00KTBLGL'
  2       SIZE 20971520  AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;

Tablespace altered.


@@ ?/rdbms/admin/utlirp.sql 執行指令碼

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> CREATE SPFILE FROM PFILE = '/oracletr/pfile/INIT_00KTBLGL_1_0.ORA';

File created.

SQL> startup
ORACLE instance started.

Total System Global Area  264241152 bytes
Fixed Size                  1218868 bytes
Variable Size              88082124 bytes
Database Buffers          171966464 bytes
Redo Buffers                2973696 bytes
Database mounted.
Database opened.

@@ ?/rdbms/admin/utlrp.sql  執行指令碼


SQL> select * from t1;

         A
----------
         1

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12020513/viewspace-618458/,如需轉載,請註明出處,否則將追究法律責任。

相關文章