SQL> startup pfile='/home/oracle/pfiledgtest1.ora';
ORACLE instance started.
Total System Global Area 4275781632 bytes
Fixed Size 2260088 bytes
Variable Size 939525000 bytes
Database Buffers 3321888768 bytes
Redo Buffers 12107776 bytes
Database mounted.
Database opened.
SQL>
7. 确定修改完pfile,数据库还能正常起来后将数据库给down下来。(这里用来给数据库做冷备)测试环境,所以能直接起停。
8. 创建standby数据库,在oradata目录下新建dgtest2目录。
[oracle@oradata]$ pwd
/ulic/oradata
[oracle@bdev oradata]$ ls -l
total 8
drwxr-x--- 2 oracle oinstall 4096 Oct 18 17:07 dgtest1
drwxr-xr-x 2 oracle oinstall 4096 Oct 19 11:10 dgtest2
9. 将dgtest1目录下的datafile和log复制到dgtest2目录下。
[oracle@bdev dgtest2]$ ls -l
total 1561220
-rw-r----- 1 oracle oinstall 52429312 Oct 19 13:53 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Oct 19 13:53 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Oct 19 13:53 redo03.log
-rw-r----- 1 oracle oinstall 555753472 Oct 19 14:19 sysaux01.dbf
-rw-r----- 1 oracle oinstall 775954432 Oct 19 14:19 system01.dbf
-rw-r----- 1 oracle oinstall 30416896 Oct 19 11:05 temp01.dbf
-rw-r----- 1 oracle oinstall 73408512 Oct 19 14:19 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Oct 19 14:19 users01.dbf
10. 主库开库生成standby 控制文件,并copy到dgtest2目录下,并复制两份到control01.ctl, control02.ctl。
alter database create standby controlfile as '/ulic/oradata/dgtest2/control.std';
[oracle@dgtest2]$ ls -l
total 1561220
-rw-r----- 1 oracle oinstall 9748480 Oct 19 15:48 control01.ctl
-rw-r----- 1 oracle oinstall 9748480 Oct 19 15:48 control02.ctl
-rw-r----- 1 oracle asmadmin 9748480 Oct 19 11:08 control.std
-rw-r----- 1 oracle oinstall 52429312 Oct 19 13:53 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Oct 19 13:53 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Oct 19 13:53 redo03.log
-rw-r----- 1 oracle oinstall 555753472 Oct 19 14:19 sysaux01.dbf
-rw-r----- 1 oracle oinstall 775954432 Oct 19 14:19 system01.dbf
-rw-r----- 1 oracle oinstall 30416896 Oct 19 11:05 temp01.dbf
-rw-r----- 1 oracle oinstall 73408512 Oct 19 14:19 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Oct 19 14:19 users01.dbf
11. 复制一份pfiledgtest1.ora到pfiledgtest2.ora,并修改内容。
[oracle@~]$ more pfiledgtest2.ora
dgtest2.__db_cache_size=3338665984
dgtest2.__java_pool_size=67108864
dgtest2.__large_pool_size=83886080
dgtest2.__oracle_base='/ulic/app/oracle'#ORACLE_BASE set from environment
dgtest2.__pga_aggregate_target=2147483648
dgtest2.__sga_target=4294967296
dgtest2.__shared_io_pool_size=0
dgtest2.__shared_pool_size=771751936
dgtest2.__streams_pool_size=0
*.audit_file_dest='/ulic/app/oracle/admin/dgtest2/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/ulic/oradata/dgtest2/control01.ctl','/ulic/oradata/dgtest2/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_recovery_file_dest='/ulic/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/ulic/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=dgtest2XDB)'
*.log_archive_format='%t_%s_%r.arc'
*.open_cursors=300
*.pga_aggregate_target=2147483648
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=4294967296
*.undo_tablespace='UNDOTBS1'
DB_NAME=dgtest1
DB_UNIQUE_NAME=dgtest2
LOG_ARCHIVE_CONFIG='DG_CONFIG=(dgtest1,dgtest2)'
LOG_ARCHIVE_DEST_1=
'LOCATION=/ulic/archivelog/dgtest2/
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=dgtest2'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
FAL_SERVER=dgtest1
FAL_CLIENT=dgtest2
DB_FILE_NAME_CONVERT='/ulic/oradata/dgtest1','/ulic/oradata/dgtest2'
LOG_FILE_NAME_CONVERT='/ulic/oradata/dgtest1','/ulic/oradata/dgtest2'
STANDBY_FILE_MANAGEMENT=AUTO
12. 配置监听。
DGTEST1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = bdev)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dgtest1)
)
)
DGTEST2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.18.1.123)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dgtest2)
)
)
13.启动备库到mount状态。
SQL> startup mount pfile='/home/oracle/pfiledgtest2.ora';
ORACLE instance started.
Total System Global Area 4275781632 bytes
Fixed Size 2260088 bytes
Variable Size 939525000 bytes
Database Buffers 3321888768 bytes
Redo Buffers 12107776 bytes
Database mounted.
查看备库身份
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PHYSICAL STANDBY
查看主库身份
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PRIMARY
14. 从库进行standby recover 开始应用日志。
alter database recover managed standby database disconnect from session;
15.切换日志验证是否能正常传输。