su - oracle
mkdir /backup/standby
cp $ORACLE_HOME/dbs/orapw* /backup/standby/.
sqlplus / as sysdba <<EOF
alter system set archive_lag_target=7200;
alter database force logging;
alter database create standby controlfile as '/backup/standby/standby.ctl';
exit;
EOF
rman target / <<EOF
backup full database format '/backup/standby/%D%u%s%U.dbf';
exit
EOF
cd /backup
gzip /backup/standby/*.dbf
2、目标端新建目录:
su - oracle
mkdir -p /data/test200/
3、将备份文件,控制文件传到目标端的/data/test200目录下
scp /backup/standby/* oracle@10.231.42.200:/data/test200/.
4.新的os调整异步IO
echo fs.aio-max-nr = 4867876 >>/etc/sysctl.conf
sysctl -p
chown oracle:dba /data
su - oracle
mkdir /data/database
5.目标端新建目录cp密码文件及控制文件
su - oracle
cp /data/test200/orapwprimary $ORACLE_HOME/dbs/orapwtest200_stdy
mkdir /data/database/test200_stdy
cp /data/test200/standby.ctl /data/database/test200_stdy/control01.ctl
cp /data/test200/standby.ctl /data/database/test200_stdy/control02.ctl
mkdir -p /opt/oracle/app/oracle/admin/test200_stdy
mkdir -p /opt/oracle/app/oracle/admin/test200_stdy/adump
mkdir -p /opt/oracle/app/oracle/admin/test200_stdy/bdump
mkdir -p /opt/oracle/app/oracle/admin/test200_stdy/cdump
mkdir -p /opt/oracle/app/oracle/admin/test200_stdy/trace
gunzip /data/test200/*.gz
6.从源端cp wallet
scp -r /opt/oracle/app/oracle/admin/primary/wallet oracle@10.231.4.52:/opt/oracle/app/oracle/admin/test200_stdy/.
7.源端查询
sqlplus / as sysdba <<EOF
select distinct bytes/1024/1024 from v\$log;
show parameter db_unique_name
exit
EOF
8.修改源端、目标端tnsnames.ora
echo "
test200 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.231.42.200)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = primary)
)
)
test200_stdy =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.231.154.208)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test200_stdy)
)
)
" >>$ORACLE_HOME/network/admin/tnsnames.ora
修改目标端edit listener.ora
vi $ORACLE_HOME/network/admin/listener.ora
lsnrctl stop
lsnrctl start
9.将primary数据库上的/opt/oracle/app/oracle/admin/primary/pfile.ora拷贝到standby的/opt/oracle/app/oracle/admin/test200_stdy/目录下,并且添加如下参数:
10.启动目标数据库
export ORACLE_SID=test200_stdy
export ORACLE_UNQNAME=test200_stdy
sqlplus / as sysdba <<EOF
create spfile from pfile='/data/test200/pfile.ora';
startup mount
EOF
11.恢复目标端数据库
rman target /
catalog start with '/data/test200';
yes
restore database;
12.修改源端数据库参数
alter system set log_archive_config='dg_config=(primary,test200_stdy)';
#alter system set log_archive_config='dg_config=(wfmstandby,test200_stdy)';
alter system set log_archive_config='dg_config=(primary,test200_stdy)';
alter system set log_archive_max_processes=6;
alter system set log_archive_dest_4='service=test200_stdy async reopen=15 valid_for=(online_logfiles,primary_role) db_unique_name=test200_stdy compression=enable';
alter system set log_archive_dest_state_2='defer';
alter system set log_archive_dest_state_4='enable';
alter system set fal_client= 'test200_stdy';
13.创建目标端standby日志文件
alter database clear logfile group 1;
alter database clear logfile group 2;
alter database clear logfile group 3;
alter database clear logfile group 4;
alter database clear logfile group 5;
alter database clear logfile group 6;
alter database clear logfile group 7;
alter database clear logfile group 8;
alter database clear logfile group 9;
alter database clear logfile group 10;
alter database clear logfile group 11;
alter database clear logfile group 12;
alter database clear logfile group 13;
alter database clear logfile group 14;
alter database clear logfile group 15;
alter database clear logfile group 16;
alter database clear logfile group 17;
alter database add standby logfile '/data/database/test200_stdy/redo01.dbf' size 256M;
alter database add standby logfile '/data/database/test200_stdy/redo02.dbf' size 256M;
alter database add standby logfile '/data/database/test200_stdy/redo03.dbf' size 256M;
alter database add standby logfile '/data/database/test200_stdy/redo04.dbf' size 256M;
alter database add standby logfile '/data/database/test200_stdy/redo05.dbf' size 256M;
alter database add standby logfile '/data/database/test200_stdy/redo06.dbf' size 256M;
alter database add standby logfile '/data/database/test200_stdy/redo07.dbf' size 256M;
alter database add standby logfile '/data/database/test200_stdy/redo08.dbf' size 256M;
alter database add standby logfile '/data/database/test200_stdy/redo09.dbf' size 256M;
alter database add standby logfile '/data/database/test200_stdy/redo10.dbf' size 256M;
alter database add standby logfile '/data/database/test200_stdy/redo11.dbf' size 256M;
alter database add standby logfile '/data/database/test200_stdy/redo12.dbf' size 256M;
alter database add standby logfile '/data/database/test200_stdy/redo13.dbf' size 256M;
alter database add standby logfile '/data/database/test200_stdy/redo14.dbf' size 256M;
alter database add standby logfile '/data/database/test200_stdy/redo15.dbf' size 256M;
alter database add standby logfile '/data/database/test200_stdy/redo16.dbf' size 256M;
alter database add standby logfile '/data/database/test200_stdy/redo17.dbf' size 256M;
14.启动目标端standby模式
#RECOVER MANAGED STANDBY DATABASE cancel;
#startup mount force;
RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
select sequence#,process,status from v$managed_standby where process='MRP0';
15.查看数据库警告日志
tail -f /opt/oracle/app/oracle/diag/rdbms/*standby/*/trace/a*.log
tail -f /opt/oracle/app/oracle/diag/rdbms/test200_stdy/*/trace/a*.log
orapki wallet create -wallet /opt/oracle/app/oracle/admin/test200_stdy/wallet -auto_login
primary_tde_001
其中的pfile文件如下:
test200_stdy.__db_cache_size=209715200
test200_stdy.__java_pool_size=4194304 test200_stdy.__large_pool_size=4194304 test200_stdy.__oracle_base='/opt/oracle/app/oracle'#ORACLE_BASE set from environment test200_stdy.__pga_aggregate_target=255852544 test200_stdy.__sga_target=771751936 test200_stdy.__shared_io_pool_size=0 test200_stdy.__shared_pool_size=524288000 test200_stdy.__streams_pool_size=0 *.archive_lag_target=1800 *.audit_file_dest='/opt/oracle/app/oracle/admin/test200_stdy/adump' *.audit_sys_operations=TRUE *.audit_trail='DB' *.compatible='11.2.0.3.0' *.control_files='/data/database/test200_stdy/control01.ctl','/data/database/test200_stdy/control02.ctl'#Restore Controlfile *.cursor_sharing='FORCE' *.db_block_size=8192 *.db_domain='' *.DB_FILE_NAME_CONVERT='/oradata/primary/','/data/database/test200_stdy/' *.db_files=2048 *.db_name='primary' *.db_recovery_file_dest_size=4517265408 *.db_recovery_file_dest='' *.db_unique_name='test200_stdy' *.fal_client='test200_stdy' *.fal_server='test200' *.local_listener='(address=(protocol=tcp)(host=linux)(port=1522))' *.log_archive_config='dg_config=(primary,test200_stdy)' *.LOG_ARCHIVE_DEST_1='LOCATION=/data/database/test200_stdy/archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=test200_stdy' *.LOG_ARCHIVE_DEST_STATE_1='ENABLE' *.log_archive_format='%t_%s_%r.dbf' *.log_archive_max_processes=4 *.log_archive_start=TRUE *.log_file_name_convert='/oradata/primary/','/data/database/test200_stdy/' *.memory_max_target=1024000000 *.memory_target=1024000000 *.open_cursors=300 *.parallel_force_local=TRUE *.pga_aggregate_target=0 *.processes=1500 *.remote_login_passwordfile='EXCLUSIVE' *.sessions=280 *.sga_target=768000000 *.shared_servers=0 *.standby_file_management='auto' *.undo_tablespace='UNDOTBS1'