linux单机配置DG过程记录
在单机的linux虚拟机上配置DG,记录过程
环境介绍:
linux 4.7 AS 32位
ORACLE Release 10.2.0.1.0
主库 testb
备库 testbdg
ORACLE_BASE=/oracle
ORACLE_HOME=/oracle/product/database
1.新建目录
mkdir -p /oracle/lsx/testbdg/arch
2.新建口令文件
orapwd file=orapwtestb password=oracle force=y
orapwd file=orapwtestbdg password=oracle force=y
3.新建pfile
testb>create pfile='/oracle/admin/testb/pfile/pfiletestb.ora' from spfile;
4.修改主库的pfile文件pfiletestb.ora,修改后内容如下:
testb.__db_cache_size=268435456
testb.__java_pool_size=4194304
testb.__large_pool_size=4194304
testb.__shared_pool_size=138412032
testb.__streams_pool_size=0
*.control_file_record_keep_time=365
*.control_files='/oracle/oradata/testb/control1.ctl','/oracle/oradata/testb/control2.ctl','/oracle/oradata/testb/control3.ctl'
*.db_name='testb'
*.job_queue_processes=10
*.sga_max_size=400M
*.sga_target=400M
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
DB_UNIQUE_NAME=testb
LOG_ARCHIVE_CONFIG='DG_CONFIG=(testb,testbdg)'
LOG_ARCHIVE_DEST_1='LOCATION=/oracle/oradata/testb/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=testb'
LOG_ARCHIVE_DEST_2='SERVICE=testbdg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=testbdg'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
FAL_SERVER=testbdg
FAL_CLIENT=testb
DB_FILE_NAME_CONVERT='/oracle/lsx/testbdg/','/oracle/oradata/testb/'
LOG_FILE_NAME_CONVERT='/oracle/lsx/testbdg/','/oracle/oradata/testb/'
STANDBY_FILE_MANAGEMENT=AUTO
5.复制到/oracle/lsx/testbdg/,命名为pfiletestbdg.ora,修改该文件,给备库testbdg使用,修改后内容如下:
testb.__db_cache_size=268435456
testb.__java_pool_size=4194304
testb.__large_pool_size=4194304
testb.__shared_pool_size=138412032
testb.__streams_pool_size=0
*.control_file_record_keep_time=365
*.control_files='/oracle/lsx/testbdg/control1.ctl'
*.db_name='testb'
*.job_queue_processes=10
*.sga_max_size=400M
*.sga_target=400M
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
DB_UNIQUE_NAME=testbdg
LOG_ARCHIVE_CONFIG='DG_CONFIG=(testb,testbdg)'
LOG_ARCHIVE_DEST_1='LOCATION=/oracle/lsx/testbdg/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=testbdg'
LOG_ARCHIVE_DEST_2='SERVICE=testb LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=testb'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
FAL_SERVER=testb
FAL_CLIENT=testbdg
DB_FILE_NAME_CONVERT='/oracle/oradata/testb/','/oracle/lsx/testbdg/'
LOG_FILE_NAME_CONVERT='/oracle/oradata/testb/','/oracle/lsx/testbdg/'
STANDBY_FILE_MANAGEMENT=AUTO
6.启动主库testb到mount,创建standby控制文件
testb>startup pfile='/oracle/admin/testb/pfile/pfiletestb.ora' ;
testb>create spfile from pfile='/oracle/admin/testb/pfile/pfiletestb.ora' ;
testb>startup mount force
testb>alter database create standby controlfile as '/oracle/lsx/testbdg/control1.ctl' ;
7.关闭主库testb,复制数据文件和日志文件到备库的位置
testb>shutdown immediate
cp /oracle/oradata/testb/*.dbf /oracle/lsx/testbdg/
cp /oracle/oradata/testb/*.log /oracle/lsx/testbdg/
8.先启动主库到open,再启动备库到mount
testb>startup ;
testbdg>startup mount pfile='/oracle/lsx/testbdg/pfiletestbdg.ora' ;
testbdg>create spfile from pfile='/oracle/lsx/testbdg/pfiletestbdg.ora' ;
testbdg>startup force mount
9.应用日志恢复
testbdg>alter database recover managed standby database disconncet from session ;
10.查看日志是否即时被恢复
select archived_seq#,applied_seq# from v$archive_dest_status ;
11.主备切换
先操作主库
alter database commit to switchover to physical standby with session shutdown ;
shutdown immediate
startup mount
再操作备库
alter database commit to swtichover to primary;
shutdown immediate
startup
李世侠,网名caibird2005 , initdba , 战神
MySQL DBA经验6年;
Oracle DBA经验10年;
精通MySQL HA架构,复制,备份,恢复,SQL优化;
熟悉SHELL编程、Python编程、SQL&PL/SQL编程;
MySQL OCP课程讲师;
ORACLE官方认证OCM证书;
BLOG: http://www.cnblogs.com/caibird2005
http://www.initdba.cn
Wechat: caibird2005
TEL :+86-186-5881-5300 +86-180-7290-8651