第二步:Dataguard配置
首先将主副两主机都设为归档模式。
1. 主节点备份并生成备用数据库控制文件
登陆主节点,进行数据库备份,并生成备用数据库控制文件
[oracle@primary]$ sqlplus "/ as sysdba"
SQL> startup
SQL> shutdown immediate
SQL> exit
[oracle@primary]pwd
/home/oracle
[oracle@primary]$ ls
admin dictionary.ora jre oradata oraInventory oui product soft
[oracle@primary]tar -cvf oradata.tar oradata
[oracle@primary]$ ls -l *.tar
-rw-r--r-- 1 oracle dba 576512000 Aug 16 10:22 oradata.tar
[oracle@primary]$ sqlplus "/ as sysdba"
SQL> startup
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/oradata/primary/archive
Oldest online log sequence 88
Next log sequence to archive 90
Current log sequence 90
SQL> alter database create standby controlfile as '/home/oracle/standby.ctl';
Database altered.
SQL> exit
[oracle@primary] |
3. 登陆备用节点(standby),ftp获得primary主机的数据库文件(即oradata.tar文件)、备用控制文件(/home/oracle/standby.ctl) ,口令文件( $ORACLE_HOME/dbs/下的orapworacle)传到standby里的相应位置。
具体步骤:
3.1 在standby的/home/oracle/oradata下,原来有一个oracle的文件夹(里面是该主机下的dbf,redolog文件),再新建一个primary文件夹。将primary主机的oradata.tar解开的文件全部直接(即primary不要再有文件夹)放到primary下,将刚生成的备用控制文件(/home/oracle/standby.ctl)也放到primary下。
3.2 在standby的ORACLE_HOME/dbs/下,先将以前的orapworacle备份一下(改个名字即可),再将primary的$ORACLE_HOME/dbs/下的orapworacle 文件ftp放到standby的ORACLE_HOME/dbs/下. 说明一下,我在查阅eygle的大作及很多人的相关文章,都没有提到这一点,但如果没做这一步的话,再后面的启动备用数据库的时候,即在
[oracle@eygle primary]$ sqlplus "/ as sysdba"
SQL> startup nomount;
SQL> alter database mount standby database;
SQL> alter database recover managed standby database disconnect from session;
这一步时就会报ORA-01991 错误,说是Invalid passwd file.询问我们的dba,说是必须要用primary的orapworacle来替换standby的. 我试过,这样做了后就OK了。
所以我这在这里就把primary的orapworacle来替换standby的orapworacl也当作一步必须步骤,但我真的不能肯定这一步是否是必须的,如果不是必须的,为何我做这一步,总会报错。如果是必须的,为何eygle和其他大牛的大作里都没有提到这一步,难道是因为这个太简单吗?? 我真的是有些疑惑。如果哪位大牛看到这,请给我一个肯定的回答,我不胜感激。
在standby主机的$oracle/home/admin下原来有oracle目录。现在新建primary目录,再在primary目录下新建bdump,cdump,udump.
Primary的参数文件
oracle@primary_andy $cat .bash_profile
# .bash_profile
# Get the aliases and functions
#if [ -f ~/.bashrc ]; then
# . ~/.bashrc
#fi
# User specific environment and startup programs
#export BASH_ENV=$HOME/.bashrc
PATH=$PATH:/home/oracle/product/9.2.0
/bin:$oracle_home/jre/bin:/opt/SUNWspro/
bin:/usr/bin:/usr/ccs/bin:/usr/ucb:/
etc:/usr/local/bin:/usr/bin/saved:
export PATH
unset USERNAME
ORACLE_OWNER=oracle
ORACLE_BASE=/home/oracle
export ORACLE_BASE
ORACLE_HOME=/home/oracle/product/9.2.0
export ORACLE_HOME
LANG=
LC_ALL=
ORACLE_SID=oracle
export ORACLE_SID
TNS_ADMIN=/home/Oracle/config/9.2.0; export TNS_ADMIN
NLS_LANG=american_america.ZHS16GBK; export NLS_LANG
#ORA_NLS33=$Oracle_HOME/ocommon/nls/admin/data; export ORA_NLS33
CLASSPATH=$Oracle_HOME/JRE:$Oracle_HOME/jlib:$Oracle_HOME/rdbms/
jlib:/opt/j2sdk_nb/j2sdk1.4.2/bin
export CLASSPATH
TMPDIR=/tmp;export TMPDIR
umask 022
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/lib/tls:/lib/i686:/usr/openwin/
lib:/usr/dt/lib
export LD_LIBRARY_PATH
export LD_PRELOAD=/home/oracle/libcwait.so;
export LD_ASSUME_KERNEL=2.4.19;
DISPLAY=1.1.1.3:0.0;export DISPLAY;
export PS1="\u@\H $"
#cat initoracle.ora_primary
*.aq_tm_processes=1
*.background_dump_dest='/home/oracle/admin/oracle/bdump'
*.compatible='9.2.0.0.0'
*.control_files='/home/oracle/oradata/oracle/control01.ctl','/home/
oracle/oradata/oracle/c
ontrol02.ctl','/home/oracle/oradata/oracle/control03.ctl'
*.core_dump_dest='/home/oracle/admin/oracle/cdump'
*.db_block_size=8192
*.db_cache_size=33554432
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=oracleXDB)'
*.fast_start_mttr_target=300
*.hash_join_enabled=TRUE
*.instance_name='oracle'
*.java_pool_size=83886080
*.job_queue_processes=10
*.large_pool_size=16777216
*.log_archive_dest_1='LOCATION=/home/oracle/oradata/archivelog/'
*.log_archive_dest_2='service=standby mandatory reopen=60'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_format='log_%t_%s.arc'
*.log_archive_start=TRUE
*.open_cursors=300
*.pga_aggregate_target=25165824
*.processes=150
*.query_rewrite_enabled='FALSE'
*.remote_login_passwordfile='EXCLUSIVE'
*.shared_pool_size=83886080
*.sort_area_size=524288
*.star_transformation_enabled='FALSE'
*.timed_statistics=TRUE
*.undo_management='AUTO'
*.undo_retention=10800
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/home/oracle/admin/oracle/udump' |
修改standby主机的initoracle.ora文件(先备份),我的initoracle.ora如下,供参考
*.aq_tm_processes=1
*.background_dump_dest='/home/oracle/admin/primary/bdump'
*.compatible='9.2.0.0.0'
*.control_files='/home/oracle/oradata/primary/standby.ctl'
*.core_dump_dest='/home/oracle/admin/primary/cdump'
*.db_block_size=8192
*.db_cache_size=33554432
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=oracleXDB)'
*.fast_start_mttr_target=300
*.hash_join_enabled=TRUE
*.instance_name='oracle'
*.java_pool_size=83886080
*.job_queue_processes=10
*.large_pool_size=16777216
*.open_cursors=300
*.pga_aggregate_target=25165824
*.processes=150
*.query_rewrite_enabled='FALSE'
*.remote_login_passwordfile='EXCLUSIVE'
*.shared_pool_size=83886080
*.sort_area_size=524288
*.star_transformation_enabled='FALSE'
*.timed_statistics=TRUE
*.undo_management='AUTO'
*.undo_retention=10800
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/home/oracle/admin/primary/udump'
*.log_archive_format=log_%t_%s.arc
*.log_archive_start=TRUE
*.STANDBY_FILE_MANAGEMENT=AUTO
*.log_archive_dest_1='LOCATION=/home/oracle/oradata/archivelog/'
*.log_archive_dest_state_1 = ENABLE
*.fal_server='primary'
*.fal_client='standby'
*.DB_FILE_NAME_CONVERT=("/home/oracle/oradata/oracle","/home/oracle/oradata/primary")
----(主辅数据库数据文件相互转换的目录)
*.STANDBY_FILE_MANAGEMENT=AUTO 即可实现重命名主库的数据文件!!
*.LOG_FILE_NAME_CONVERT=("/home/oracle/oradata/archivelog","/home/oracle/oradata/archivelog")
----(主辅数据库联机日志redolog相互转换的目录)
*.STANDBY_ARCHIVE_DEST=/home/oracle/oradata/archivelog
----(从主数据库产生的archivelog传到辅数据库的目录) |
4. 配置主节点(primary主机上)的tnsnames.ora文件
primary=(description=
(address=
(protocol=tcp)
(port=1521)
(host=1.1.1.1))
(connect_data=
(SID=oracle)))
standby=(description=
(address=
(protocol=tcp)
(port=1521)
(host=1.1.1.2))
(connect_data=
(SID=oracle))) |
同样,在副节点(standby) 的tnsnames.ora文件。