一、实验环境
主库配置:
操作系统:win7 64bit
Oracle数据库: Oracle 11.2.0.1
IP地址:127.0.0.1
db_unique_name:orcl
oracle_sid:orcl
备库配置:
操作系统:win7 64bit
ORACLE数据库: Oracle 11.2.0.1
IP地址:127.0.0.1
oracle_sid: pdb
db_unique_name:pdb_orcl
注意:主库和备库的DB_NAME必须一致,即orcl
二、主库配置
1.归档模式
SQL> archive log list
数据库日志模式 存档模式
自动存档 启用
存档终点 E:\ora_arch
最早的联机日志序列 4
下一个存档日志序列 6
当前日志序列 6
2.查看db_unqie_name
SQL> show parameter db_unique_name
NAME TYPE VALUE
------------------------------------ ---------------------- ---------
db_unique_name string orcl
3.force logging模式
SQL> select force_logging from v$database;
FORCE_
------
YES
如果是NO,需要进行修改
SQL>alter database force logging;
4.配置tnsnames.ora
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = kermart)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
PDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = kermart)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb)
)
)
5.参数文件
通过pfile的方式批量修改需要配置的参数,添加如下参数:
*.db_file_name_convert='D:\oradata\pdb','C:\app\Administrator\oradata\orcl'
*.fal_client='pdb'
*.fal_server='orcl'
*.log_archive_config='DG_CONFIG=(orcl,pdb_orcl)'
*.log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl'
*.log_archive_dest_2='SERVICE=pdb LGWR VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=pdb_orcl'
*.log_file_name_convert='D:\oradata\pdb','C:\app\Administrator\oradata\orcl'
*.standby_file_management='AUTO'
6.通过pfile创建spfile
SQL>shutdown immediate
SQL> create spfile from pfile;
文件已创建。
SQL> startup
ORACLE 例程已经启动。
Total System Global Area 1235959808 bytes
Fixed Size 2175288 bytes
Variable Size 989859528 bytes
Database Buffers 234881024 bytes
Redo Buffers 9043968 bytes
数据库装载完毕。
数据库已经打开。
SQL>
三、备库配置
1.创建配置的instance service
C:\>oradim -NEW -SID pdb -startmode manual
实例已创建。
2.配置tnsnames.ora
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = kermart)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
PDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = kermart)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb)
)
)
主库和备库的tnsnames.ora保持一致。
3.配置监听
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\app\Administrator\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:C:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
--添加静态静态
(SID_DESC =
(GLOBAL_DBNAME = pdb)
(ORACLE_HOME = C:\app\Administrator\product\11.2.0\dbhome_1)
(SID_NAME = pdb)
)
)
4.创建必要的目录
C:\>mkdir -p C:\app\Administrator\admin\pdb
C:\>mkdir -p C:\app\Administrator\admin\pdb\adump
C:\>mkdir -p D:\oradata\archlog
C:\>mkdir -p C:\app\Administrator\flash_recovery_area\pdb
5.配置参数文件
将主库的pfile复制一份就行修改
*.db_create_file_dest='D:\oradata\pdb'
*.db_unique_name='pdb_orcl'
*.db_file_name_convert='C:\app\Administrator\oradata\orcl','D:\oradata\pdb'
*.fal_client='pdb'
*.fal_server='orcl'
*.log_archive_config='DG_CONFIG=(pdb_orcl,orcl)'
*.log_archive_dest_1='LOCATION=D:\oradata\archlog VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=pdb_orcl'
*.log_archive_dest_2='SERVICE=orcl LGWR VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl'
*.log_file_name_convert='C:\app\Administrator\oradata\orcl','D:\oradata\pdb'
*.standby_file_management='AUTO'
6.创建口令文件
将主库下的口令文件拷贝一份,重命名即可,当然也可以创建,注意密码要跟主库保持一致。
mv PWDorcl.ora PWDpdb.ora