前面介绍了如何通过RMAN Duplicate方式构建物理备用数据库,本篇将演示如何利用Cloud Control构建物理备用数据库。
1 软件环境
- Oracle Linux 6.9
- Oracle 12.1.0.2
- Oracle Enterprise Management Cloud Control 12.1.0.4
- 主库:odd.oracle.com,IP:192.168.1.105
- 备库:even.oracle.com,IP:192.168.1.106
2 使用Cloud Control创建备库
2.1 网络配置
2.1.1 主库网络配置
1)监听器配置
[oracle@odd admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ORCL)
(ORACLE_HOME = /u01/app/oracle/product/12.1.0/dbhome_1)
(SID_NAME = ORCL)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = odd.oracle.com)(PORT = 1521))
)
ADR_BASE_LISTENER = /u01/app/oracle
2)TNS配置
[oracle@odd admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
TNS_ODD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.105)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORCL)
)
)
TNS_EVEN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.106)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORCLDG)
)
)
2.1.2 备库网络配置
1)监听器配置
[oracle@even admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ORCLDG)
(ORACLE_HOME = /u01/app/oracle/product/12.1.0/dbhome_1)
(SID_NAME = ORCLDG)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = even.oracle.com)(PORT = 1521))
)
ADR_BASE_LISTENER = /u01/app/oracle
2)TNS配置
[oracle@even admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
TNS_ODD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.105)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORCL)
)
)
TNS_EVEN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.106)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORCLDG)
)
)
2.1.3 测试网络
1)主库测试
[oracle@odd ~]$ tnsping tns_odd
[oracle@odd ~]$ tnsping tns_even
2)备库测试
[oracle@even admin]$ tnsping tns_odd
[oracle@even admin]$ tnsping tns_even
2.2 图形界面创建备库
1)登录Cloud Control,进入目标>数据库实例ORCL
10)检查所有文件路径,确保ORCL置换为ORCLDG,点击确定
2.3 搭建完毕,验证
2.3.1 主库操作
1)查询主库角色信息
SQL> select name,open_mode,database_role,db_unique_name,dataguard_broker from v$database;
NAME OPEN_MODE DATABASE_ROLE DB_UNIQUE_NAME DATAGUAR
--------- -------------------- ---------------- ------------------------------ --------
ORCL READ WRITE PRIMARY ORCL ENABLED
2)创建测试数据
SQL> create table scott.test(id number,name varchar2(100));
Table created.
SQL> insert into scott.test values(1,'Alen');
1 row created.
SQL> commit;
Commit complete.
3)查询数据
SQL> select * from scott.test;
ID NAME
---------- ----------------------------------------------------------------------------------------------------
1 Alen
2.3.2 备库操作
1)查询主库角色信息
SQL> select name,open_mode,database_role,db_unique_name,dataguard_broker from v$database;
NAME OPEN_MODE DATABASE_ROLE DB_UNIQUE_NAME DATAGUAR
--------- -------------------- ---------------- ------------------------------ --------
ORCL READ ONLY WITH APPLY PHYSICAL STANDBY ORCLDG ENABLED
2)查询数据
SQL> select * from scott.test;
ID NAME
---------- ----------------------------------------------------------------------------------------------------
1 Alen
综上,就是使用Cloud Control搭建物理备用数据库的整个过程