搭建环境:
Red Hat Linux Enterprise 5.4
Oracle 10g R2
主机操作系统主要信息为192.168.199.128.
搭建准备:
已存在主库(生产库)DB_NAME=mustang SID=april
开始搭建Data Guard
首先需要准备好参数文件,设定一些必要的参数。在主库,先通过spfile生成pfile文件:
SQL>create pfile=’/home/oracle/product/10.2initapril.ora’ from spfile;
然后修改主库新生成的initapril.ora参数文件。在原有的基础上添加如下内容:
db_unique_name=mustang log_archive_config='DG_CONFIG=(mustang,standby)' log_archive_dest_2='service=standby arch async valid_for=(online_logfiles,primary_role) db_unique_name=standby' log_archive_dest_1='location=/home/oracle/archive valid_for=(all_logfiles,all_roles) db_unique_name=mustang' log_archive_dest_state_1=enable log_archive_dest_state_2=enable log_archive_format=%t_%s_%r.arc log_archive_max_processes=30 fal_server=standby fal_client=mustang db_file_name_convert='standby','mustang' log_file_name_convert='/home/oracle/','/home/oracle/standby/' standby_file_management=auto
修改完参数文件之后,要重新打开主库,然后通过iniapril.ora来创建spfile。如下:
SQL>create spfile=’/home/oracle/product/10.2.0/db_1/dbs/spfileapril.ora’ from pfile=’ /home/oracle/product/10.2.0/db_1/dbs/initapril.ora’;
接下来的工作就是要通过主库的参数文件,创建备库需要的参数文件,在主库上运行:
SQL>create pfile=’ /home/oracle/product/10.2.0/db_1/dbs/initstandby.ora’ from spfile;
编辑initstandby.ora。如下所示:
standby.__db_cache_size=213909504 standby.__large_pool_size=4194304 *.control_files='/home/oracle/standby/standby.ctl' *.db_file_multiblock_read_count=8 *.db_file_name_convert='standby','mustang' *.db_files=80 *.db_name='mustang' *.db_unique_name='standby' *.fal_client='standby' *.fal_server='mustang' *.global_names=TRUE *.instance_name='standby' *.log_archive_config='DG_CONFIG=(mustang,standby)' *.log_archive_dest_1='location=/home/oracle/standby/archive' *.log_archive_dest_2='service=mustang arch async valid_for=(online_logfiles,primary_role) db_unique_name=mustang' *.log_archive_dest_state_1='enable' *.log_archive_dest_state_2='enable' *.log_archive_format='%t_%s_%r.arc' *.log_archive_max_processes=30 *.log_buffer=32768 *.log_checkpoint_interval=10000 *.log_file_name_convert='/home/oracle/','/home/oracle/standby/' *.max_dump_file_size='10240' *.parallel_max_servers=5 *.processes=50 *.service_names='standby' *.sga_max_size=300M *.sga_target=300M *.standby_file_management='auto' *.undo_management='auto' *.undo_tablespace='undotbs'
保存initstandby.ora参数文件。通过initstandby.ora生成动态文件spfilestandby.ora:
SQL>create spfile=’/home/oracle/product/10.2.0/db_1/dbs/spfilestandby.ora’ from pfile=’ /home/oracle/product/10.2.0/db_1/dbs/initstandby.ora’;
在主库上创建我们的密码文件:
[oracle@localhost dbs]$orapwd file=’ /home/oracle/product/10.2.0/db_1/dbs/orapwstandby’ password=oracle entries=10
通过主库的控制文件生成我们备库的控制文件:
SQL>alter database create standby controlfile as ‘/home/oracle/standby.ctl’;