rman异机duplicate active数据库
2012-06-21 09:01 java环境变量 阅读(305) 评论(0) 编辑 收藏 举报
实验环境:
源数据库服务器名:beijing 数据库全局名和SID:orcl
辅助数据库:suzhou 只安装数据库软件,没有新建数据库
在辅助服务器suzhou上复制一个例程名和数据库名都是bj的数据库.
----------------------------------------------------------------
步骤如下:
(1)辅助数据库服务器suzhou上构建辅助数据库目录结构
(2)suzhou服务器上建立数据库复制例程服务
(3)源数据库服务器名beijing上创建pfile,并复制到辅助数据库,修改相关内容
(4)在辅助服务器suzhou上用pfile文件,将辅助数据库启动到nomount 状态
(5)添加配置监听和网络服务解析
(6)源数据库服务器名suzhou上执行RMAN duplicate命令复制数据库
(7)在辅助服务器suzhou上创建spfile文件
---------------------------------------------------------------------
--------------------------------------------------
第一部分:源数据库配置
--------------------------------------------------
1.源数据库开启归档
SQL> archive log list;
数据库日志模式 非存档模式
自动存档 禁用
存档终点 USE_DB_RECOVERY_FILE_DEST
最早的联机日志序列 5
当前日志序列 7
SQL>host mkdir e:\archive
SQL>host mkdir e:\backup
SQL> alter system set log_archive_dest_1='location=e:\archive' scope=both;
系统已更改。
SQL> archive log list;
数据库日志模式 非存档模式
自动存档 禁用
存档终点 e:\archive
最早的联机日志序列 5
当前日志序列 7
SQL> shutdown immediate;
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup mount;
ORACLE 例程已经启动。
Total System Global Area 1252663296 bytes
Fixed Size 2175328 bytes
Variable Size 788532896 bytes
Database Buffers 452984832 bytes
Redo Buffers 8970240 bytes
数据库装载完毕。
SQL> alter database archivelog;
数据库已更改。
SQL> alter database open;
数据库已更改。
SQL> archive log list;
数据库日志模式 存档模式
自动存档 启用
存档终点 e:\archive
最早的联机日志序列 5
下一个存档日志序列 7
当前日志序列 7
2. 源数据库服务器beijing上配置监听和网络服务
listener.ora如下:
# listener.ora Network Configuration File: E:\app\Administrator\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = E:\app\Administrator\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:E:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
(SID_DESC =
(SID_NAME = orcl)
(ORACLE_HOME = E:\app\Administrator\product\11.2.0\dbhome_1)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = beijing)(PORT = 1521))
)
)
ADR_BASE_LISTENER = E:\app\Administrator
tnsnames.ora内容:
# tnsnames.ora Network Configuration File: E:\app\Administrator\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
bj =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.90.10)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
sz =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.90.20)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = sz)
)
)
3.为目标数据库建立参数文件
3.1连接到源数据库服务器beijing建立文本参数文件保存到备份目录
sqlplus sys/password@orcl as sysdba
create pfile='E:\backup\initsz.ora'
from spfile;
3.2编辑文本参数文件
编辑E:\backup\initsz.ora:
orcl.__db_cache_size=452984832
orcl.__java_pool_size=16777216
orcl.__large_pool_size=16777216
orcl.__oracle_base='F:\app\Administrator' #ORACLE_BASE set from environment #修改安装路径
orcl.__pga_aggregate_target=503316480
orcl.__sga_target=754974720
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=251658240
orcl.__streams_pool_size=0
##########################################################################
#上面这几项解释:
#1.orcl.__db_cache_size即orcl._*这种设置只是对实例orcl生效;#
#2.*.__db_cache_size即*._*这种情况则表示所有实例都用此参数,
#如直接指定db_cache_size,则默认等于*.db_cache_size#;
#如果上面几项不设置,数据库设置为自动分配,则oracle会根据SGA大小自动分配该值.
##########################################################################
*.audit_file_dest='F:\sz\adump' #修改审计文件位置
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='F:\sz\control01.ctl' #控制文件路径
*.db_file_name_convert=('E:\app\Administrator\oradata\orcl','F:\sz')
*.log_file_name_convert=('E:\app\Administrator\oradata\orcl','F:\sz')
*.db_block_size=8192
*.db_domain=''
*.db_name='sz' #修改数据库名
*.db_recovery_file_dest='F:\sz\flash_recovery_area' #修改快速恢复路径
*.db_recovery_file_dest_size=4102029312
*.diagnostic_dest='F:\app\Administrator' #修改安装路径
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.log_archive_dest_1='location=F:\sz\archive' #修改数据库归档位置
*.memory_target=1258291200
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
4.建立密码文件并复制到备份目录
如果该路径下存在就不必新建
E:\app\Administrator\product\11.2.0\dbhome_1\database
拷贝并命名PWDorcldg.ora :
copy E:\app\Administrator\product\11.2.0\dbhome_1\database\PWDorcl.ora E:\backup\PWDsz.ora
--------------------------------------------------
第二部分:目标数据库配置
--------------------------------------------------
5.目标服务器suzhou建立存放复制数据库各种数据文件的OS目录
由于是在不同机器上的不同目录, ,
这里将数据文件、控制文件、重做日志都保存到g盘下的sz目录;
alert文件和后台进程文保存到E:\sz\bdump中;
用户跟踪文件保存到E:\bj\udump中;
归档文件保存到E:\bj\archive中;
mkdir f:\sz
cd f:\sz
f:
mkdir adump bdump udump archive flash_recovery_area
6.目标服务器suzhou服务器上建立数据库复制例程服务
oradim -new -sid sz
oradim -delete -sid sz
7.将源数据服务器beijing上的参数文件复制到目标主机suzhou上.
将参数文件复制到目标服务器suzhou上的oracle安装目录下的database下(如果不保存到该目录,系统可能不认):
\\192.168.90.10\e$\backup\pfilesz.ora
复制到
F:\app\Administrator\product\11.2.0\dbhome_1\database\pfilesz.ora
C:\>copy \\192.168.90.10\e$\backup\pfilesz.ora F:\app\Administrator\product\11.2.0\dbhome_1\database\pfilesz.ora
\\192.168.90.10\e$\backup\PWDsz.ora
F:\app\Administrator\product\11.2.0\dbhome_1\database
8.目标服务器suzhou上启动例程
set oracle_sid=sz
sqlplus sys/password as sysdba
create spfile from pfile='F:\app\Administrator\product\11.2.0\dbhome_1\database\pfilesz.ora'
startup nomount
9.配置目标服务器suzhou监听和网络服务名
listener.ora如下:
# listener.ora Network Configuration File: F:\app\Administrator\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = F:\app\Administrator\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:F:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
(SID_DESC =
(SID_NAME = sz)
(ORACLE_HOME = F:\app\Administrator\product\11.2.0\dbhome_1)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.90.20)(PORT = 1521))
)
)
tnsnames.ora内容:
# tnsnames.ora Network Configuration File: F:\app\Administrator\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
bj =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.90.10)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
sz =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.90.20)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = sz)
)
)
lsnrctl start
10.建立复制数据库
10.1先连接到主库beijing上归档日志
alter system archive log current;
10.2复制数据库
RMAN 客户端可以在任何地方运行,只要能够连接到主、辅实例
rman target sys/password@bj auxiliary sys/password@sz
duplicate target database to sz from active database;