備份與恢復--一個表空間能否被多個資料庫同時開啟?
一個表空間能否被多個資料庫同時開啟?我也來試試。
這個問題其實是來自論壇上的一個帖子:http://www.itpub.net/showthread.php?s=&threadid=658187。
參考:http://yangtingkun.itpub.net/post/468/228632
SQL> alter tablespace users read only;
Tablespace altered.
SQL> select tablespace_name,status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
UNDOTBS1 ONLINE
SYSAUX ONLINE
TEMP ONLINE
USERS READ ONLY
EXAMPLE ONLINE
JGLU ONLINE
TEST ONLINE
8 rows selected.
SQL> SELECT 'ALTER TABLESPACE ' || TABLESPACE_NAME || ' BEGIN BACKUP;'
2 FROM DBA_TABLESPACES
3 WHERE CONTENTS != 'TEMPORARY'
4 AND TABLESPACE_NAME != 'USERS';
'ALTERTABLESPACE'||TABLESPACE_NAME||'BEGINBACKUP;'
-------------------------------------------------------------
ALTER TABLESPACE SYSTEM BEGIN BACKUP;
ALTER TABLESPACE UNDOTBS1 BEGIN BACKUP;
ALTER TABLESPACE SYSAUX BEGIN BACKUP;
ALTER TABLESPACE EXAMPLE BEGIN BACKUP;
ALTER TABLESPACE JGLU BEGIN BACKUP;
ALTER TABLESPACE TEST BEGIN BACKUP;
6 rows selected.
SQL> ALTER TABLESPACE SYSTEM BEGIN BACKUP;
Tablespace altered.
SQL> ALTER TABLESPACE UNDOTBS1 BEGIN BACKUP;
Tablespace altered.
SQL> ALTER TABLESPACE SYSAUX BEGIN BACKUP;
Tablespace altered.
SQL> ALTER TABLESPACE EXAMPLE BEGIN BACKUP;
Tablespace altered.
SQL> ALTER TABLESPACE JGLU BEGIN BACKUP;
Tablespace altered.
SQL> ALTER TABLESPACE TEST BEGIN BACKUP;
Tablespace altered.
SQL> select 'host cp '|| file_name || ' /u01/app/oracle/oradata/jolly'
2 from
3 (
4 select file_name from dba_data_files where tablespace_name !='USERS'
5 union all
6 select file_name from dba_temp_files
7 );
'HOSTCP'||FILE_NAME||'/u01/app/oracle/oradata/jolly'
--------------------------------------------------------------------------------
host cp /u01/app/oracle/oradata/orcl/test02.dbf /u01/app/oracle/oradata/jolly
host cp /u01/app/oracle/oradata/orcl/jglu02.dbf /u01/app/oracle/oradata/jolly
host cp /u01/app/oracle/oradata/orcl/jglu01.dbf /u01/app/oracle/oradata/jolly
host cp /u01/app/oracle/oradata/orcl/example01.dbf /u01/app/oracle/oradata/jolly
host cp /u01/app/oracle/oradata/orcl/sysaux01.dbf /u01/app/oracle/oradata/jolly
host cp /u01/app/oracle/oradata/orcl/undotbs01.dbf /u01/app/oracle/oradata/jolly
host cp /u01/app/oracle/oradata/orcl/system01.dbf /u01/app/oracle/oradata/jolly
host cp /u01/app/oracle/oradata/orcl/temp01.dbf /u01/app/oracle/oradata/jolly
8 rows selected.
SQL> host cp /u01/app/oracle/oradata/orcl/test02.dbf /u01/app/oracle/oradata/jolly
SQL> host cp /u01/app/oracle/oradata/orcl/jglu02.dbf /u01/app/oracle/oradata/jolly
SQL> host cp /u01/app/oracle/oradata/orcl/jglu01.dbf /u01/app/oracle/oradata/jolly
SQL> host cp /u01/app/oracle/oradata/orcl/example01.dbf /u01/app/oracle/oradata/jolly
SQL> host cp /u01/app/oracle/oradata/orcl/sysaux01.dbf /u01/app/oracle/oradata/jolly
SQL> host cp /u01/app/oracle/oradata/orcl/undotbs01.dbf /u01/app/oracle/oradata/jolly
SQL> host cp /u01/app/oracle/oradata/orcl/system01.dbf /u01/app/oracle/oradata/jolly
SQL> host cp /u01/app/oracle/oradata/orcl/temp01.dbf /u01/app/oracle/oradata/jolly
SQL> SELECT 'ALTER TABLESPACE ' || TABLESPACE_NAME || ' END BACKUP;'
2 FROM DBA_TABLESPACES
3 WHERE CONTENTS != 'TEMPORARY'
4 AND TABLESPACE_NAME != 'USERS';
'ALTERTABLESPACE'||TABLESPACE_NAME||'ENDBACKUP;'
-----------------------------------------------------------
ALTER TABLESPACE SYSTEM END BACKUP;
ALTER TABLESPACE UNDOTBS1 END BACKUP;
ALTER TABLESPACE SYSAUX END BACKUP;
ALTER TABLESPACE EXAMPLE END BACKUP;
ALTER TABLESPACE JGLU END BACKUP;
ALTER TABLESPACE TEST END BACKUP;
6 rows selected.
SQL> ALTER TABLESPACE SYSTEM END BACKUP;
Tablespace altered.
SQL> ALTER TABLESPACE UNDOTBS1 END BACKUP;
Tablespace altered.
SQL> ALTER TABLESPACE SYSAUX END BACKUP;
Tablespace altered.
SQL> ALTER TABLESPACE EXAMPLE END BACKUP;
Tablespace altered.
SQL> ALTER TABLESPACE JGLU END BACKUP;
Tablespace altered.
SQL> ALTER TABLESPACE TEST END BACKUP;
Tablespace altered.
下面開始新建一個資料庫
SQL> host cp /u01/app/oracle/oradata/orcl/*.log /u01/app/oracle/oradata/jolly
SQL> host cp /u01/app/oracle/product/10201/dbs/orapworcl
/u01/app/oracle/product/10201/dbs/orapwjolly
SQL> host mkdir -p /u01/app/oracle/admin/jolly/udump
SQL> host mkdir -p /u01/app/oracle/admin/jolly/bdump
SQL> host mkdir -p /u01/app/oracle/admin/jolly/cdump
SQL> host mkdir -p /u01/app/oracle/admin/jolly/archive
SQL> host mkdir -p /u01/app/oracle/admin/jolly/dpdump
SQL> host mkdir -p /u01/app/oracle/admin/jolly/pfile
SQL> host mkdir -p /u01/app/oracle/admin/jolly/adump
SQL> create pfile='/u01/app/oracle/admin/jolly/pfile/init.ora' from spfile;
File created.
SQL> alter database backup controlfile to trace;
Database altered.
修改引數檔案如下:
[oracle@rhel131 pfile]$ cat init.ora
orcl.__db_cache_size=251658240
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__shared_pool_size=71303168
orcl.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/jolly/adump'
*.background_dump_dest='/u01/app/oracle/admin/jolly/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/app/oracle/oradata/jolly/control01.ctl','/u01/app/oracle/oradata/jolly/
control02.ctl','/u01/app/oracle/oradata/jolly/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/jolly/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='jolly'
#*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='location=/u01/app/oracle/admin/jolly/archive'
*.open_cursors=300
*.pga_aggregate_target=111149056
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=334495744
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
[oracle@rhel131 orcl]$ ORACLE_SID=jolly
[oracle@rhel131 orcl]$ echo $ORACLE_SID
jolly
[oracle@rhel131 orcl]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Jan 20 00:16:20 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile='/u01/app/oracle/admin/jolly/pfile/init.ora'
ORACLE instance started.
Total System Global Area 335544320 bytes
Fixed Size 1219280 bytes
Variable Size 104858928 bytes
Database Buffers 226492416 bytes
Redo Buffers 2973696 bytes
用trace出來的controlfile手動建立控制檔案,注意要修改一下內容,將REUSE DATABASE "ORCL"改成 SET
DATABASE "JOLLY"
SQL> CREATE CONTROLFILE SET DATABASE "JOLLY" RESETLOGS ARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 '/u01/app/oracle/oradata/jolly/redo01.log' SIZE 50M,
9 GROUP 2 '/u01/app/oracle/oradata/jolly/redo02.log' SIZE 50M,
10 GROUP 3 '/u01/app/oracle/oradata/jolly/redo03.log' SIZE 50M
11 -- STANDBY LOGFILE
12 DATAFILE
13 '/u01/app/oracle/oradata/jolly/system01.dbf',
14 '/u01/app/oracle/oradata/jolly/undotbs01.dbf',
15 '/u01/app/oracle/oradata/jolly/sysaux01.dbf',
16 '/u01/app/oracle/oradata/jolly/example01.dbf',
17 '/u01/app/oracle/oradata/jolly/jglu01.dbf',
18 '/u01/app/oracle/oradata/jolly/jglu02.dbf',
19 '/u01/app/oracle/oradata/jolly/test02.dbf'
20 CHARACTER SET WE8ISO8859P1
21 ;
Control file created.
CREATE CONTROLFILE SET DATABASE "JOLLY" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/jolly/redo01.log' SIZE 50M,
GROUP 2 '/u01/app/oracle/oradata/jolly/redo02.log' SIZE 50M,
GROUP 3 '/u01/app/oracle/oradata/jolly/redo03.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/oradata/jolly/system01.dbf',
'/u01/app/oracle/oradata/jolly/undotbs01.dbf',
'/u01/app/oracle/oradata/jolly/sysaux01.dbf',
'/u01/app/oracle/oradata/jolly/example01.dbf',
'/u01/app/oracle/oradata/jolly/jglu01.dbf',
'/u01/app/oracle/oradata/jolly/jglu02.dbf',
'/u01/app/oracle/oradata/jolly/test02.dbf'
CHARACTER SET WE8ISO8859P1
;
SQL> recover database using backup controlfile;
ORA-00279: change 700340 generated at 01/20/2009 00:00:56 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/admin/jolly/archive/1_4_676515900.dbf
ORA-00280: change 700340 for thread 1 is in sequence #4
Specify log: {
/u01/app/oracle/oradata/jolly/redo03.log
Log applied.
Media recovery complete.
SQL> ALTER DATABASE OPEN RESETLOGS;
Database altered.
SQL> select tablespace_name,status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
UNDOTBS1 ONLINE
SYSAUX ONLINE
TEMP ONLINE
USERS READ ONLY
EXAMPLE ONLINE
JGLU ONLINE
TEST ONLINE
8 rows selected.
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/jolly/system01.dbf
/u01/app/oracle/oradata/jolly/undotbs01.dbf
/u01/app/oracle/oradata/jolly/sysaux01.dbf
/u01/app/oracle/product/10201/dbs/MISSING00004
/u01/app/oracle/oradata/jolly/example01.dbf
/u01/app/oracle/oradata/jolly/jglu01.dbf
/u01/app/oracle/oradata/jolly/jglu02.dbf
/u01/app/oracle/oradata/jolly/test02.dbf
8 rows selected.
將這個檔案改名為orcl/users01.dbf,注意不是jolly/users01.dbf
SQL> alter database rename file 'MISSING00004'
2 to '/u01/app/oracle/oradata/orcl/users01.dbf';
Database altered.
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/jolly/system01.dbf
/u01/app/oracle/oradata/jolly/undotbs01.dbf
/u01/app/oracle/oradata/jolly/sysaux01.dbf
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/jolly/example01.dbf
/u01/app/oracle/oradata/jolly/jglu01.dbf
/u01/app/oracle/oradata/jolly/jglu02.dbf
/u01/app/oracle/oradata/jolly/test02.dbf
8 rows selected.
SQL> alter tablespace users online;
Tablespace altered.
SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/jolly/temp01.dbf'
2 SIZE 20971520 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
Tablespace altered.
SQL> SELECT TABLESPACE_NAME, STATUS FROM DBA_TABLESPACES WHERE TABLESPACE_NAME = 'USERS';
TABLESPACE_NAME STATUS
------------------------------ ---------
USERS READ ONLY
SQL> SELECT FILE_NAME FROM DBA_DATA_FILES WHERE TABLESPACE_NAME = 'USERS';
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/users01.dbf
SQL> SELECT NAME FROM V$DATABASE;
NAME
---------
JOLLY
至此,透過備份新建的資料庫已經載入了表空間USERS。
而源資料庫顯然也載入著同一個只讀表空間。透過這個實驗說明,對於一個只讀表空間,可以同時被多個
Oracle資料庫所載入。
[oracle@rhel131 orcl]$ ORACLE_SID=orcl
[oracle@rhel131 orcl]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Jan 20 00:31:34 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> SELECT TABLESPACE_NAME, STATUS FROM DBA_TABLESPACES WHERE TABLESPACE_NAME = 'USERS';
TABLESPACE_NAME STATUS
------------------------------ ---------
USERS READ ONLY
SQL> SELECT FILE_NAME FROM DBA_DATA_FILES WHERE TABLESPACE_NAME = 'USERS';
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/users01.dbf
SQL> SELECT NAME FROM V$DATABASE;
NAME
---------
ORCL
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/271283/viewspace-1016381/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 備份與恢復:Polardb資料庫資料基於時間點恢復資料庫
- 備份與恢復:polardb資料庫備份與恢復資料庫
- SYSTEM 表空間管理及備份恢復
- postgresql備份與恢復資料庫SQL資料庫
- 利用MySQL全備份(mysqldump),如何只恢復一個庫或者一個表?MySql
- 資料庫備份恢復資料庫
- 資料庫資料恢復—無備份,binlog未開啟的Mysql資料庫資料恢復案例資料庫資料恢復MySql
- 資料庫備份與恢復技術資料庫
- (Les16 執行資料庫恢復)-表空間恢復資料庫
- MySQL-19.資料庫備份與恢復MySql資料庫
- 【PG備份恢復】pg_basebackup 多表空間備份恢復測試
- 【RMAN】同時建立多個備份(建立多重備份)
- mongodb資料庫備份與恢復(資料庫資料遷移)MongoDB資料庫
- Mysql資料備份與恢復MySql
- Linux下MySQL資料庫的備份與恢復LinuxMySql資料庫
- Mysql資料庫備份及恢復MySql資料庫
- 達夢資料庫備份恢復資料庫
- SQL Server中使用臨時表進行資料備份與恢復SQLServer
- 時序資料庫 InfluxDB 之備份和恢復策略資料庫UX
- 時序資料庫InfluxDB之備份和恢復策略資料庫UX
- PostgreSQL從小白到高手教程 - 第41講:postgres表空間備份與恢復SQL
- RabbitMQ如何備份與恢復資料MQ
- Dedecms資料庫恢復與備份的兩種方法資料庫
- 淺談達夢資料庫的備份與恢復資料庫
- 在DG備庫備份資料庫並恢復到一個主機上,報錯RMAN-06820資料庫
- pg_dump 備份,恢復資料庫資料庫
- Mongo 資料庫備份和恢復命令Go資料庫
- PostgreSql資料庫的備份和恢復SQL資料庫
- 建立良好的資料庫備份和恢復策略時,需要考慮以下幾個點資料庫
- SqlServer資料庫恢復備份資料的方法SQLServer資料庫
- 【資料庫資料恢復】SQL Server資料庫磁碟空間不足的資料恢復案例資料庫資料恢復SQLServer
- RAC備份恢復之Voting備份與恢復
- mysqldump使用方法(MySQL資料庫的備份與恢復)MySql資料庫
- PG-pg_dump備份/恢復資料庫資料庫
- vivo 資料庫備份恢復系統演化資料庫
- 使用Mysqldump備份和恢復MySQL資料庫MySql資料庫
- 如何在HarmonyOS對資料庫進行備份,恢復與加密資料庫加密
- 分散式文件儲存資料庫之MongoDB備份與恢復分散式資料庫MongoDB
- 判斷一個數N能否同時被3和5整除;