5 配置备库参数
LOG_ARCHIVE_DEST_2=‘SERVICE=standby LGWR ASYNC --此处为备库网络连接串 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby‘–备库的DB_UNIQUE_NAME
6.查看LOG_ARCHIVE_DEST_STATE状态
SQL> show parameter archive;
8.查看remote
SQL> show parameter remote;
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
9
备库相当于服务端 主库相当于客户端 主库不断相备库请求连接
FAL_SERVER=standby
FAL_CLIENT=primary
10查看主库和备库的数据文件路径和日志文件路径
SQL> select file_name from dba_data_files;
主库
备库
说明:‘/oracle/app/oradata/NANA’为主库数据\日志文件路径; ‘/oradata/STANDBY ‘为备库数据\日志文件路径
DB_FILE_NAME_CONVERT='/oracle/app/oradata/NANA ','/oradata/STANDBY‘
LOG_FILE_NAME_CONVERT='/oracle/app/oradata/NANA ','/oradata/STANDBY‘
11STANDBY_FILE_MANAGEMENT=AUTO
主库的初始化参数
*.audit_file_dest='/oracle/app/admin/NANA/adump'
*.background_dump_dest='/oracle/app/admin/NANA/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/oracle/app/oradata/NANA/control01.ctl','/oracle/app/oradata/NANA/control02.ctl','/oracle/app/oradata/NANA/control03.ctl'
*.core_dump_dest='/oracle/app/admin/NANA/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='NANA'
DB_UNIQUE_NAME=NANA
LOG_ARCHIVE_CONFIG='DG_CONFIG=(nana,standby)'
LOG_ARCHIVE_DEST_1='LOCATION=/home/oracle/archivelog
VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=NANA'
LOG_ARCHIVE_DEST_2='SERVICE=standby LGWR ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
FAL_SERVER=standby
FAL_CLIENT=nana
DB_FILE_NAME_CONVERT=' /oracle/app/oradata/NANA','/oradata/STANDBY'
LOG_FILE_NAME_CONVERT='/oracle/app/oradata/NANA ','/oradata/STANDBY'
STANDBY_FILE_MANAGEMENT=AUTO
*.db_recovery_file_dest='/oracle/app/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=NANAXDB)'
*.job_queue_processes=10
*.open_cursors=300
*.pga_aggregate_target=16777216
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=167772160
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/oracle/app/admin/NANA/udump'
二 备库standby 数据库配置
1.修改备库sys用户密码保持与库密码一致
SQL> alter user sys identified by sys;
2.从库改
db_name 与主库一致
3.配库归档文件路径与主库一致
LOG_ARCHIVE_DEST_1='LOCATION=/home/oracle/archivelog VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=standby'
配库参数
*.audit_file_dest='/oracle/app/admin/STANDBY/adump'
*.background_dump_dest='/oracle/app/admin/STANDBY/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/oradata/STANDBY/control01.ctl','/oradata/STANDBY/control02.ctl','/oradata/STANDBY/control03.ctl'
*.core_dump_dest='/oracle/app/admin/STANDBY/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
db_name='NANA'
DB_UNIQUE_NAME=standby
LOG_ARCHIVE_CONFIG='DG_CONFIG=(nana,standby)'
DB_FILE_NAME_CONVERT='/oracle/app/oradata/NANA','/oradata/STANDBY'
LOG_FILE_NAME_CONVERT='/oracle/app/oradata/NANA','/oradata/STANDBY'
STANDBY_FILE_MANAGEMENT=AUTO
LOG_ARCHIVE_DEST_1='LOCATION=/home/oracle/archivelog VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=standby'
LOG_ARCHIVE_DEST_2='SERVICE=nana LGWR ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=NANA'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
FAL_SERVER=NANA 主库和备库相反
FAL_CLIENT=standby
STANDBY_FILE_MANAGEMENT=AUTO
*.db_recovery_file_dest='/oracle/app/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=STANDBYXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='location=/home/oracle/data.bak'
*.open_cursors=300
*.pga_aggregate_target=89128960
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_max_size=268435456
*.sga_target=268435456
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/oracle/app/admin/STANDBY/udump'
~
三 主陪库的参数复制到相应的数据库参数里
[oracle@localhost ~]$ vi /home/oracle/initdg.ora
先关掉数据库
SQL> shutdown abort
制定文件启动数据库
SQL> startup pfile=/home/oracle/initdg.ora
启动后产看归档日志文件的位置
SQL> show parameter archive
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
archive_lag_target integer 0
log_archive_config string DG_CONFIG=(nana,standby)
log_archive_dest string
log_archive_dest_1 string LOCATION=/home/oracle/archivel
og
VALID_FOR=(ALL_LOGFILES,ALL_RO
LES) DB_UNIQUE_NAME=NANA
log_archive_dest_10 string
log_archive_dest_2 string SERVICE=standby LGWR ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRI
MARY_ROLE) DB_UNIQUE_NAME=STAN DBY
log_archive_dest_3 string
步骤7:迁移主库stand数据库的数据文件、控制文件到standby
RMAN
利用新的参数文件启动NANA到OPEN状态
-利用新的参数文件启动standby 到nomount 状态
前备库起到nomount
SQL> startup pfile=/home/oracle/initdg.ora nomount
二
-主库上利用RMAN制作nana数据库备份(所有RMAN操作都在主数据库上执行)
主库做rman备份
进入RMAN
[oracle@localhost ~]$ rman
RMAN> connect target
查看备份数据
RMAN> list backup;
删除备份文件
RMAN> delete backup;
备份数据
RMAN>backup full database format='/home/oracle/archivelog/%U' include current controlfile for standby;
-将NANA主库的rman的备份集拷贝至standby库相同的路径,并在主库连接,不要断开上面的连接,如果断开,那么重新连接主库
将备份文件拷贝到备库的相同目录下
[oracle@localhost ~]$ scp *_1
oracle@10.1.1.32:/home/oracle/archivelog/
RMAN > connect target /
复制standby数据库,接着上面的连接在主库上执行
RMAN > duplicate target database for standby nofilenamecheck;
正常运行无错误后直接执行下面的命令进行主备库的日志同步
说明:此命令结束后从库直接启动到mount
执行完后会自动启动到mount
修改standby数据库自动恢复状态
alter database recover managed standby database disconnect from session;
确认DATAGUARD环境状态是否正常
主库操作:
select process from v$managed_standby;
PROCESS
------------------
查询主库
是否存在日志网络传输进程
ARCH
ARCH
ARCH
LNS --确认主库有此lns进程(日志网络服务进程-负责把主库归档日志传输到备库)
如果无此进程则执行下面命令
alter system set log_archive_dest_2='SERVICE=standby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby';
alter system set log_archive_dest_state_2=ENABLE;
alter system switch logfile;
继续确认有无lns进程,如果还没有启动则查看相关错误信息
select error from v$archive_dest; 根据具体ORACLE错误码查找错误原因
备库操作:
SQL> select process from v$managed_standby;
PROCESS
------------------
ARCH
ARCH
RFS --远程文件服务-接收由主库lns进程传送过来的日志
RFS
MRP0 --介质恢复进程-同步主库日志数据到从库
注意:如果没有RFS进程,则查看主库lns进程是否正常.如果没有MRP进程则执行
alter database recover managed standby database disconnect from session;