创建物理备用数据库
在创建物理备用数据库之前先查看主数据库的一些信息和对主数据库做好配置.
将主数据库置为force logging模式.在主数据库创建之后做如下操作:
sql>alter database force logging;
确认主数据库是归档的并定义好本地归档.如下:
sql >alter system set log_archive_dest_1=location=e:\oracle\oradata\orcl\archive mandatory scope=both;
在主节点a确认主数据库的数据文件的位置和文件名.
sql>select name from v$datafile;
name
———————————————————————————————————–
e:\oracle\ora92\orcl ystem01.dbf
e:\oracle\ora92\orcl\undotbs01.dbf
e:\oracle\ora92\orcl\cwmlite01.dbf
e:\oracle\ora92\orcl\drsys01.dbf
e:\oracle\ora92\orcl\example01.dbf
e:\oracle\ora92\orcl\indx01.dbf
e:\oracle\ora92\orcl\odm01.dbf
e:\oracle\ora92\orcl\tools01.dbf
e:\oracle\ora92\orcl\users01.dbf
e:\oracle\ora92\orcl\xdb01.dbf
做上面查询得出来的数据文件的物理备份.将其备份到一个临时的位置中.
sql>shutdown immediate;
sql>exit
将e:\oracle\ora92\orcl整个目录copy到a节点的f盘的oracle目录下.
在拷贝完之后再启动数据库
sql>startup;
sql>archive log list;
在主节点a为备用数据库创建备用控制文件
sql>alter database create standby controlfile as ‘f:\oracle tdbycon.ctl’;
创建初始化参数文件
sql>create pfile=’f:\oracle\initstdbyorcl.ora’ from spfile;
将上面几步所得到的文件从主节点a拷贝到备用节点b上.
修改并添加一些参数后如下:
*.aq_tm_processes=1
*.background_dump_dest=e:\oracle\admin\orcl\bdump
*.compatible=9.2.0.0.0
*.control_files=e:\oracle\ora92 tandby tdbycon.ctl,e:\oracle\ora92 tandby tdbycon02.ctl,e:\oracle\ora92 tandby tdbycon03.ctl
*.core_dump_dest=e:\oracle\admin tandby\cdump
*.db_block_size=16384
*.db_cache_size=137363456
*.db_domain=
*.db_file_multiblock_read_count=16
*.db_name=orcl
*.dispatchers=(protocol=tcp) (service=orclxdb)
*.fast_start_mttr_target=300
*.hash_join_enabled=true
*.instance_name=orcl2
*.java_pool_size=33554432
*.job_queue_processes=10
*.large_pool_size=27262976
*.log_archive_dest_1=location=e:\oracle\oradata tandby\archive mandatory
*.log_archive_format=log%d_%t_%s.arc
*.log_archive_start=true
*.open_cursors=300
*.pga_aggregate_target=80000000
*.processes=150
*.query_rewrite_enabled=false
*.remote_login_passwordfile=exclusive
*.shared_pool_size=45088768
*.sort_area_size=524288
*.sql_trace=false
*.star_transformation_enabled=false
*.timed_statistics=true
*.undo_management=auto
*.undo_retention=10800
*.undo_tablespace=undotbs1
*.user_dump_dest=e:\oracle\admin tandby\udump
*.workarea_size_policy=auto
*.standby_file_management=auto
*.fal_server=orcl
*.fal_client=orcl2
*.standby_archive_dest=e:\oracle\oradata tandby tdarch
*.utl_file_dir=e:\oracle
*.remote_archive_enable=true
在备用数据库一端创建一个新的实例.如下操作:
c:\>oradim –new –sid orcl2 –startmode m
将拷贝过来的文件放到e:\oracle\ora92底下,并修改文件夹名为orcl2
修改e:\oracle\ora92\orcl2下的控制文件,将其中的control01.ora, control02.ora, control03.ora删掉,将f:\oracle tdbycon01.ora文件拷贝到e:\oracle\ora92\orcl2目录下.并复制和修改其名为stdbycon02.ora, stdbycon03.ora
在e:\oracle\admin下建立orcl2文件夹,并在其底下建立三个文件夹,分别叫bdump,cdump,udump
在主节点a配置listner.ora和tnsnames.ora , sqlnet.ora配置后文件内容分别如下:
listener.ora文件为:
listener =
(description_list =
(description_list =
(description =
(address = (protocol = tcp)(host = 10.100.0.122)(port = 1521))
)
)
(description_list =
(description =
(address = (protocol = ipc)(key = extproc1))
)
)
)
sid_list_listener =
(sid_list =
(sid_desc =
(sid_name = plsextproc)
(oracle_home = e:\oracle\ora92)
(program = extproc)
)
(sid_desc =
(global_dbname = orcl)
(oracle_home = e:/oracle/ora92)
(sid_name = orcl)
)
)
tnsnames.ora文件为:
orcl =
(description =
(address_list =
(address = (protocol = tcp)(host = 10.100.0.122)(port = 1521))
)
(connect_data =
(server = dedicated)
(service_name = orcl)
)
)
standby =
(description =
(address_list =
(address = (protocol = tcp)(host = 10.100.0.222)(port = 1521))
)
(connect_data =
(server = dedicated)
(service_name = orcl)
)
)
extproc_connection_data =
(description =
(address_list =
(address = (protocol = ipc)(key = extproc1))
)
(connect_data =
(sid = plsextproc)
(presentation = ro)
)
)
sqlnet.ora文件为:
sqlnet.authentication_services= (nts)
names.directory_path= (hostname,tnsnames, onames)
在备用节点b配置listner.ora和tnsnames.ora,sqlnet.ora配置后文件内容分别如下:
其中配置sqlnet.ora文件中的参数sqlnet.expire_time是enable死连接侦测
listener.ora文件为:
listener =
(description_list =
(description =
(address_list =
(address = (protocol = ipc)(key = extproc))
)
(address_list =
(address = (protocol = tcp)(host = 10.100.0.222)(port = 1521))
)
)
)
sid_list_listener =
(sid_list =
(sid_desc =
(global_dbname = orcl2)
(oracle_home = e:\oracle\ora92)
(sid_name = orcl)
)
(sid_desc =
(program = extproc)
(sid_name = plsextproc)
(oracle_home = e:\oracle\ora92)
)
)
tnsnames.ora文件为:
orcl =
(description =
(address_list =
(address = (protocol = tcp)(host = 10.100.0.122)(port = 1521))
)
(connect_data =
(server = dedicated)
(service_name = orcl)
)
)
standby =
(description =
(address_list =
(address = (protocol = tcp)(host = 10.100.0.222)(port = 1521))
)
(connect_data =
(server = dedicated)
(service_name = orcl)
)
)
extproc_connection_data =
(description =
(address_list =
(address = (protocol = ipc)(key = extproc0))
)
(connect_data =
(sid = plsextproc)
(presentation = ro)
)
)
sqlnet.ora文件为:
sqlnet.authentication_services= (nts)
names.directory_path= (hostname,tnsnames, onames)
sqlnet.expire_time=2
为备用数据库创建server parameter file
create spfile from pfile;
启动备用数据库为mount状态
sql>startup nomout
sql>alter database mount standby database;
初始log apply services
sql>alter database recover managed standby database disconnect from session;
在主节点设置远程归档目录:
sql>alter system set log_archive_dest_2=service=standby’ scope=both;
sql> alter system set log_archive_dest_state_2=enable scope=both;
启动远程归档:
sql>alter system archive log current;
确认远程归档成功:
sql>select sequence#, first_time, next_time
2 from v$archived_log order by sequence#;
sequence# first_time next_time
———- —————— ——————
8 11-jul-02 17:50:45 11-jul-02 17:50:53
9 11-jul-02 17:50:53 11-jul-02 17:50:58
10 11-jul-02 17:50:58 11-jul-02 17:51:03
3 rows selected.