ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 利用热备份建立物理STANDBY

利用热备份建立物理STANDBY

原创 Linux操作系统 作者:yangtingkun 时间:2007-03-12 00:00:00 0 删除 编辑

前一阵简单测试了一下物理STANDBY的建立。又模拟了一下在同一台机器上建立物理STANDBY

具体步骤可以参考:http://yangtingkun.itpub.net/post/468/265309http://yangtingkun.itpub.net/post/468/267489

总的来说,文档上的步骤还是十分清晰明了的,在整个建立过程中没有碰到任何的问题。不过在STANDBY的建立过程中,我却对文档中的建立步骤产生了两个小疑问。


第一个疑问是,是否建立STANDBY数据库一定要关闭主库。一般来说需要部署DATA GUARD环境的数据库都是比较重要的产品库,而建立STANDBY过程却需要关闭数据库,那么这个操作明显会降低产品库的可用性,这与DATA GUARD的目标是违背的。

第二点疑问,文档采用了冷备份的方式,并在STANDBY数据库建立完成之后,才配置了主库的初始化参数,是指可以归档到STANDBY数据库。那么在冷备份和STANDBY数据库建立的这段时间,主库产生的ARCHIVELOG是否可以自动应用过去呢?

其实总的来说,这两个问题可以合二为一。如果Oracle可以利用热备份来建立物理STANDBY,那么后面这个疑问也就不是问题了。

这里采用上面给出的第一篇文档的环境来尝试使用热备份建立物理STANDBY,由于物理STANDBY的其他环境都已经具备了,这里只是尝试恢复热备份数据库并建立STANDBY机制,STANDBY数据库的其他步骤就省略了。

SQL> SELECT 'ALTER TABLESPACE ' || TABLESPACE_NAME || ' BEGIN BACKUP;'
2 FROM DBA_TABLESPACES
3 WHERE CONTENTS != 'TEMPORARY';

'ALTERTABLESPACE'||TABLESPACE_NAME||'BEGINBACKUP;'
-------------------------------------------------------------
ALTER TABLESPACE SYSTEM BEGIN BACKUP;
ALTER TABLESPACE UNDOTBS1 BEGIN BACKUP;
ALTER TABLESPACE DRSYS BEGIN BACKUP;.
.
.
ALTER TABLESPACE NDINDEX BEGIN BACKUP;
ALTER TABLESPACE NDMAIN BEGIN BACKUP;

26 rows selected.

SQL> ALTER TABLESPACE SYSTEM BEGIN BACKUP;

Tablespace altered.

SQL> ALTER TABLESPACE UNDOTBS1 BEGIN BACKUP;

Tablespace altered.

SQL> ALTER TABLESPACE DRSYS BEGIN BACKUP;

Tablespace altered.

.

.

.

SQL> ALTER TABLESPACE NDINDEX BEGIN BACKUP;

Tablespace altered.

SQL> ALTER TABLESPACE NDMAIN BEGIN BACKUP;

Tablespace altered.

下面可以通过ftp将数据文件拷贝到目的服务器的相同目录下:

SQL> HOST
[oracle@demo2 oracle]$ cd /data/oradata/testdata
[oracle@demo2 testdata]$ ftp 172.25.88.92
Connected to 172.25.88.92 (172.25.88.92).
220 (vsFTPd 1.1.3)
Name (172.25.88.92:root): oracle
331 Please specify the password.
Password:
230 Login successful. Have fun.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> bin
200 Switching to Binary mode.
ftp> prompt
Interactive mode off.
ftp> cd /data/oradata/testdata
250 Directory successfully changed.
ftp> mput *.dbf
local: drsys01.dbf remote: drsys01.dbf
227 Entering Passive Mode (172,25,88,92,28,170)
150 Ok to send data.
226 File receive OK.
52436992 bytes sent in 5.23 secs (9.8e+03 Kbytes/sec)
local: indx01.dbf remote: indx01.dbf
227 Entering Passive Mode (172,25,88,92,229,37)
150 Ok to send data.
226 File receive OK.
local: tools01.dbf remote: tools01.dbf
227 Entering Passive Mode (172,25,88,92,206,85)
150 Ok to send data.
226 File receive OK.
104865792 bytes sent in 8.84 secs (1.2e+04 Kbytes/sec)
local: undotbs01.dbf remote: undotbs01.dbf
227 Entering Passive Mode (172,25,88,92,210,87)
150 Ok to send data.
226 File receive OK.
local: users01.dbf remote: users01.dbf
227 Entering Passive Mode (172,25,88,92,248,111)
150 Ok to send data.
226 File receive OK.
26222592 bytes sent in 2.25 secs (1.1e+04 Kbytes/sec)
local: xdb01.dbf remote: xdb01.dbf
227 Entering Passive Mode (172,25,88,92,197,113)
150 Ok to send data.
226 File receive OK.
104865792 bytes sent in 10.5 secs (9.7e+03 Kbytes/sec)
ftp> exit
221 Goodbye.

下面可以关闭表空间的备份状态:

SQL> SELECT 'ALTER TABLESPACE ' || TABLESPACE_NAME || ' END BACKUP;'
2 FROM DBA_TABLESPACES
3 WHERE CONTENTS != 'TEMPORARY';

'ALTERTABLESPACE'||TABLESPACE_NAME||'ENDBACKUP;'
-----------------------------------------------------------
ALTER TABLESPACE SYSTEM END BACKUP;
ALTER TABLESPACE UNDOTBS1 END BACKUP;
ALTER TABLESPACE DRSYS END BACKUP;
.
.
.
ALTER TABLESPACE NDINDEX END BACKUP;
ALTER TABLESPACE NDMAIN END BACKUP;

26 rows selected.

SQL> ALTER TABLESPACE SYSTEM END BACKUP;

Tablespace altered.

SQL> ALTER TABLESPACE UNDOTBS1 END BACKUP;

Tablespace altered.

SQL> ALTER TABLESPACE DRSYS END BACKUP;

Tablespace altered.

.

.

.

SQL> ALTER TABLESPACE NDINDEX END BACKUP;

Tablespace altered.

SQL> ALTER TABLESPACE NDMAIN END BACKUP;

Tablespace altered.

然后将联机日志、归档日志和控制文件传到目的站点指定位置:

SQL> host
[oracle@demo2 oracle]$ cd /data/oradata/testdata
[oracle@demo2 testdata]$ ftp 172.25.88.92
Connected to 172.25.88.92 (172.25.88.92).
220 (vsFTPd 1.1.3)
Name (172.25.88.92:root): oracle
331 Please specify the password.
Password:
230 Login successful. Have fun.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> bin
200 Switching to Binary mode.
ftp> prompt
Interactive mode off.
ftp> cd /data/oradata/testdata
250 Directory successfully changed.
ftp> mput *.log *.ctl
local: redo01.log remote: redo01.log
227 Entering Passive Mode (172,25,88,92,148,47)
150 Ok to send data.
226 File receive OK.
104858112 bytes sent in 9.26 secs (1.1e+04 Kbytes/sec)
local: redo02.log remote: redo02.log
227 Entering Passive Mode (172,25,88,92,230,37)
150 Ok to send data.
226 File receive OK.
104858112 bytes sent in 10.9 secs (9.4e+03 Kbytes/sec)
local: redo03.log remote: redo03.log
227 Entering Passive Mode (172,25,88,92,224,25)
150 Ok to send data.
226 File receive OK.
104858112 bytes sent in 10.1 secs (1e+04 Kbytes/sec)
local: control01.ctl remote: control01.ctl
227 Entering Passive Mode (172,25,88,92,195,72)
150 Ok to send data.
226 File receive OK.
1908736 bytes sent in 0.201 secs (9.3e+03 Kbytes/sec)
local: control02.ctl remote: control02.ctl
227 Entering Passive Mode (172,25,88,92,185,18)
150 Ok to send data.
226 File receive OK.
1908736 bytes sent in 0.166 secs (1.1e+04 Kbytes/sec)
local: control03.ctl remote: control03.ctl
227 Entering Passive Mode (172,25,88,92,150,87)
150 Ok to send data.
226 File receive OK.
1908736 bytes sent in 0.155 secs (1.2e+04 Kbytes/sec)
ftp> lcd archive
Local directory now /data/oradata/testdata/archive
ftp> cd standbyarchive
250 Directory successfully changed.
ftp> mput 1_1887.dbf 1_1888.dbf 1_1889.dbf
local: 1_1887.dbf remote: 1_1887.dbf
227 Entering Passive Mode (172,25,88,92,129,20)
150 Ok to send data.
226 File receive OK.
104857088 bytes sent in 10.6 secs (9.6e+03 Kbytes/sec)
local: 1_1888.dbf remote: 1_1888.dbf
227 Entering Passive Mode (172,25,88,92,146,20)
150 Ok to send data.
226 File receive OK.
104857088 bytes sent in 11.4 secs (9e+03 Kbytes/sec)
local: 1_1889.dbf remote: 1_1889.dbf
227 Entering Passive Mode (172,25,88,92,162,6)
150 Ok to send data.
226 File receive OK.
104857088 bytes sent in 10.9 secs (9.4e+03 Kbytes/sec)
ftp> exit
221 Goodbye.

STANDBY服务器上恢复数据库:

$ sqlplus "/ as sysdba"

SQL*Plus: Release 9.2.0.4.0 - Production on 星期一 3 12 16:06:11 2007

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to an idle instance.

SQL> startup mount ORACLE instance started.

Total System Global Area 1175525576 bytes
Fixed Size 452808 bytes
Variable Size 335544320 bytes
Database Buffers 838860800 bytes
Redo Buffers 667648 bytes
Database mounted.
SQL> recover database;
ORA-00279: change 4207893783 generated at 03/12/2007 16:28:50 needed for thread
1
ORA-00289: suggestion : /data/oradata/testdata/archive/1_1887.dbf
ORA-00280: change 4207893783 for thread 1 is in sequence #1887


Specify log: {=suggested | filename | AUTO | CANCEL}
/data/oradata/testdata/standbyarchive/1_1887.dbf
Log applied.
Media recovery complete.
SQL> shutdown
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.

然后从主库建立STANDBY数据库所需的控制文件,并ftpSTANDBY数据库所在目录:

SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/home/oracle/control01.ctl';

Database altered.

SQL> host
[oracle@demo2 oracle]$ ftp 172.25.88.92
Connected to 172.25.88.92 (172.25.88.92).
220 (vsFTPd 1.1.3)
Name (172.25.88.92:root): oracle
331 Please specify the password.
Password:
230 Login successful. Have fun.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> bin
200 Switching to Binary mode.
ftp> prompt
Interactive mode off.
ftp> cd /data/oradata/testdata
250 Directory successfully changed.
ftp> put control01.ctl
local: control01.ctl remote: control01.ctl
227 Entering Passive Mode (172,25,88,92,209,187)
150 Ok to send data.
226 File receive OK.
1908736 bytes sent in 0.156 secs (1.2e+04 Kbytes/sec)
ftp> quit
221 Goodbye.

下面在从库拷贝control文件,并mountSTANDBY模式:

SQL> host
[oracle@testzone oracle]$ cd /data/oradata/testdata
[oracle@testzone testdata]$ cp control01.ctl control02.ctl
[oracle@testzone testdata]$ cp control01.ctl control03.ctl
[oracle@testzone testdata]$ exit
exit

SQL> STARTUP NOMOUNT
ORACLE instance started.

Total System Global Area 1175525576 bytes
Fixed Size 452808 bytes
Variable Size 335544320 bytes
Database Buffers 838860800 bytes
Redo Buffers 667648 bytes
SQL> ALTER DATABASE MOUNT STANDBY DATABASE;

Database altered.

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

Database altered.

至此,STANDBY数据库建立成功。

注意,这里只给出利用热备份建立物理STANDBY的基本步骤,其他详细步骤请参考上面连接给出的其他两篇文章

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/4227/viewspace-69200/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
暂无介绍

注册时间:2007-12-29

  • 博文量
    1955
  • 访问量
    10487598