分类: Oracle
2008-04-11 20:44:13
|
5. 在副节点(standby)上配置listener.ora文件, 添加监听服务standby_listener,在相应的节里添加有关的内容:
在主副库上启动lsnrctl,
-bash-2.05b$ lsnrctl
LSNRCTL>start # 启动监听服务
6.在主备节点用tnsping测试网络连通性
在primary机上
-bash-2.05b$ tnsping primary
-bash-2.05b$ tnsping standby
在standby机上
-bash-2.05b$ tnsping primary
-bash-2.05b$ tnsping standby
7. 启动副数据库
sql> startup nomount;
SQL> alter database mount standby database;
Database altered.
SQL> alter database recover managed standby database disconnect from session;
Database altered.
8. 在主节点设置归档路径
SQL> alter system set log_archive_dest_2='service=standby mandatory reopen=60';
System altered.
定义了主库向副库传输日志。
# 定义归档到备用库,强制归档,重试时间60秒。
# 如果定义为可选状态(optional),那么在归档失败后不会再次尝试归档的。定义
# 为madatory状态后,如果本次归档失败,则在归档下一个日志时会再次尝试。
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL>
在备用节点观察日志:
[oracle@eygle bdump]$ tail -f alert_primary.log
MRP0: Background Managed Standby Recovery process started
Starting datafile 1 recovery in thread 1 sequence 90
Datafile 1: '/opt/oracle/oradata/primary/system01.dbf'
Starting datafile 2 recovery in thread 1 sequence 90
Datafile 2: '/opt/oracle/oradata/primary/undotbs01.dbf'
…………………………
-bash-2.05b$ mkdir /home/oracle/oradata/oracle/stdarch
-------------------------------------------------------
9.主辅数据库的切换(停止主数据库,启用备用数据库)
修改primary的参数文件initoracle.ora(先做好备份)
增加
*.standby_archive_dest='/home/oracle/oradata/standbyarch'
*.fal_server='standby'
*.fal_client='primary'
*.DB_FILE_NAME_CONVERT=("/home/oracle/oradata/primary","/home/oracle/oradata/oracle")
*.LOG_FILE_NAME_CONVERT=("/home/oracle/oradata/archivelog","/home/oracle/oradata/archivelog")
*.STANDBY_FILE_MANAGEMENT='AUTO'
删除 log_archive_dest_2参数
修改standby的参数文件initoracle.ora(先做好备份)
增加
*.log_archive_dest_2='service=primary mandatory reopen=60'
*.log_archive_dest_state_2='ENABLE'
删除
*.STANDBY_ARCHIVE_DEST=/home/oracle/oradata/archivelog
*.fal_server='standby'
*.fal_client='primary'
*.DB_FILE_NAME_CONVERT=("/home/oracle/oradata/primary","/home/oracle/oradata/oracle")
*.LOG_FILE_NAME_CONVERT=("/home/oracle/oradata/archivelog","/home/oracle/oradata/archivelog")
*.STANDBY_FILE_MANAGEMENT=AUTO
在primary主机上执行
SQL> alter database commit to switchover to physical standby with session shutdown ;
Database altered.
察看primary主机上的后台日志
…………………………….
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
以备用模式(standby)启用主数据
SQL> create spfile from pfile;
SQL> startup nomount;
SQL>show parameter standby_file_management;
SQL> alter database mount standby database;
Database altered.
打开备用数据库(在standby主机上执行)
在primary主机上执行:
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Database altered.
在primary主机上观察日志应用情况
[oracle@primary bdump]$ tail -f alert_oracle.log
Starting datafile 2 recovery in thread 1 sequence 93
Datafile 2: '/opt/oracle/oradata/primary/undotbs01.dbf'
Starting datafile 3 recovery in thread 1 sequence 93
Datafile 3: '/opt/oracle/oradata/primary/users01.dbf'
……………………………………………….
Media recover |