linux下oracle11G DG搭建(二):围绕主库搭建操作
环境
名称 |
主库 |
备库 |
主机名 |
bjsrv |
shsrv |
软件版本 |
RedHat Enterprise5.5、Oracle 11g 11.2.0.1 |
RedHat Enterprise5.5、Oracle 11g 11.2.0.1 |
SQL> show parameter spfile;
NAME TYPE VALUE
------------------------------------ -----------------------------------------
spfile string /u01/app/oracle/product/11.2.0
/dbhome_1/dbs/spfileTestDB12.ora
SQL>create pfile from spfile;
$cd $ORACLE_HOME/dbs/
$vi initTestDB12.ora //编辑pfile
查找在线文档,找到DG的pfile文件格式:
添加修改说明:
原参数文件中设置:
*.audit_file_dest='/u01/app/oracle/admin/TestDB12/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/TestDB12/control01.ctl','/u01/app/oracle/fast_recovery_area/TestDB12/control02.ctl'
*.db_block_size=8192
*.db_domain='cuug.net' //删除
*.db_name='TestDB12'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4322230272
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP)(SERVICE=TestDB12XDB)'
*.log_archive_dest_1='location=/dsk4/arch_bj' //删除
*.log_archive_format='arch_%t_%s_%r.log'
*.memory_target=642006528
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE' //添加
*.undo_tablespace='UNDOTBS1' //添加
通过文档添加的参数设置:
DB_NAME=chicago //删除
DB_UNIQUE_NAME=bjdb //别名
LOG_ARCHIVE_CONFIG='DG_CONFIG=(bjdb,shdb)'
//参与DG的数据库主机的别名
CONTROL_FILES='/arch1/chicago/control1.ctl','/arch2/chicago/control2.ctl'//删除
LOG_ARCHIVE_DEST_1=
'LOCATION=/dsk4/arch_bj
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=bjdb' //填写主库别名
LOG_ARCHIVE_DEST_2=
'SERVICE=shdb ASYNC //通过网络传递给远程备库,最大性能,异步传输
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
//只针对主库才会生效,只有主库把日志传递给备库
DB_UNIQUE_NAME=shdb
'
LOG_ARCHIVE_DEST_STATE_1=ENABLE //设置归档位置是否可用
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE //删除
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc //删除
LOG_ARCHIVE_MAX_PROCESSES=3 //添加,文档中没有此行?
FAL_SERVER=shdb //写对方service name
DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/sh','/u01/app/oracle/oradata/TestDB12'
//文件转换,让备库知道主库的数据发生了变化,先写对方的,再写自己的
LOG_FILE_NAME_CONVERT=
'/dsk1/oradata/sh','/dsk1/oradata/bj','/dsk2/oradata/sh','/dsk2/oradata/bj'
//如果redo日志文件发生变化,也要通知备库,先写对方的,再写自己的,如果有多个路径主备库要一一对应
STANDBY_FILE_MANAGEMENT=AUTO //表示自动转换
修改参数(样例):
*.audit_file_dest='/u01/app/oracle/admin/TestDB12/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/TestDB12/control01.ctl','/u01/app/oracle/fast_recovery_area/TestDB12/control02.ctl'
*.db_block_size=8192
*.db_name='TestDB12'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4322230272
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP)(SERVICE=TestDB12XDB)'
*.log_archive_format='arch_%t_%s_%r.log'
*.memory_target=642006528
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
DB_UNIQUE_NAME=bjdb
LOG_ARCHIVE_CONFIG='DG_CONFIG=(bjdb,shdb)'
LOG_ARCHIVE_DEST_1=
'LOCATION=/dsk4/arch_bj
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=bjdb'
LOG_ARCHIVE_DEST_2=
'SERVICE=shdb ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=shdb'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
LOG_ARCHIVE_MAX_PROCESSES=3
FAL_SERVER=shdb
DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/sh','/u01/app/oracle/oradata/TestDB12'
LOG_FILE_NAME_CONVERT=
'/dsk1/oradata/sh','/dsk1/oradata/bj','/dsk2/oradata/sh','/dsk2/oradata/bj'
STANDBY_FILE_MANAGEMENT=AUTO
使用pfile启动数据库
SQL>startupforce nomountpfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initTestDB12.ora';
补充:
SQL>startup force nomountpfile='$ORACLE_HOME/dbs/initTestdb12.ora';
报错ORA-01078:
查看发现,参数名书写错误导致由initTestdb12.ora改为initTestDB12.ora。
SQL>showparameter archive
SQL >create spfile frompfile; //由spfile生成pfile
SQL >startup forcemount; //启动到mount
在备库(sh)中创建目录(用以存放数据文件、日志文件):
$ mkdir -p/u01/app/oracle/oradata/sh
$ mkdir -p/u01/app/oracle/admin/sh/adump //存放审计用的目录
注意:此时确保主库处于mount状态。
方式:
1、手工拷贝;
2、RMAN备份;
3、RMAN克隆。
$scp /u01/app/oracle/oradata/TestDB12/*.dbfshsrv:/u01/app/oracle/oradata/sh
The authenticity of host 'shsrv (192.168.4.72)' can't be established.
RSA key fingerprint is 0f:d8:72:64:60:b4:0e:b6:72:69:68:7d:aa:7e:b8:bb.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'shsrv,192.168.4.72' (RSA) to the list of knownhosts.
oracle@shsrv's password:oracle
SQL>selectstatus from v$instance;
//主库处于mount状态,此时可以为备库生产控制文件
SQL>alterdatabase create standby controlfile as'/home/oracle/sh_control01.ctlcle/sh_control01.ctl';
//将生产的控制文件放到指定的目录下
$scp /home/oracle/sh_control01.ctl shsrv:/u01/app/oracle/oradata/sh
//通过主库把生成的备库控制文件拷贝到备库(sh)上
$cd $ORACLE_HOME/dbs
$scpinitTestDB12.ora shsrv:$ORACLE_HOME/dbs/initshdb.ora
$scp$ORACLE_HOME/dbs/orapwTestDB12 shsrv:$ORACLE_HOME/dbs/orapwshdb
$tail -f/u01/app/oracle/diag/rdbms/bjdb/TestDB12/trace/alert_TestDB12.log
crtl+z退出//由CRT设置决定
********************未完待续**************************
声明:
原创作品,出自 “深蓝的blog” 博客,允许转载,转载时请务必注明出处(http://blog.csdn.net/huangyanlong)。
关于涉及版权事宜,作者有权追究法律责任。