内容发布更新时间 : 2024/11/18 3:25:58星期一 下面是文章的全部内容请认真阅读。
Oracle 11G Dataguard 详细配置手册
版本:V1 作者:知行合一
一、环境描述:
主库:
IP地址:192.168.1.37 OS:RHEL 6.5 X64 Hostname :lin-1
Oracle 版本:11.2.0.1
Oracle_home: /u01/app/oracle/product/11.2.0/db_1 SQL> show parameter name;
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_ string
db_name string orcl db_unique_name string orcl global_names boolean FALSE instance_name string orcl lock_name_space string log_ string
service_names string orcl
备库:
IP地址:192.168.1.38 OS:RHEL 6.5 X64 Hostname :lin-2
Oracle 版本:11.2.0.1
Oracle_home: /u01/app/oracle/product/11.2.0/db_1 SQL> show parameter name;
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_ string
db_name string orcl db_unique_name string orcl2 global_names boolean FALSE
instance_name string orcl lock_name_space string log_ string
service_names string orcl
说明:由于我采用的是vmware 虚拟化环境进行测试的。测试时首先安装好一台数据库,然后再克隆出另外一套。第二套根据需要,对主机名、IP地址进行更改。另外不要忘记更换oracle 用户的环境变量、更改/etc/hosts解析文件
注意:主库和备库的db_unique_name不能相同
二:修改主备库listener.ora,tnsnames.ora 2.1、主库配置
2.1.1、配置主库的监听:
[oracle@lin-1 admin]$ vi listener.ora
(G
# listener.ora Network Configuration File:
/u01/app/oracle/product/11.2.0/db_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/11.2.0/db_1) (SID_NAME = orcl) ) )
LISTENER =
(DESCRIPTION_LIST = (DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = lin-1)(PORT = 1521)) ) )
ADR_BASE_LISTENER = /u01/app/oracle
2.1.2、修改主库的Tnsname
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = lin-1)(PORT = 1521)) (CONNECT_DATA =
(SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )
ORCL2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = lin-2)(PORT = 1521)) (CONNECT_DATA =
(SERVER = DEDICATED) (SERVICE_NAME = orcl2) ) )
2.2、备库配置
2.2.1、配置备库的监听
监听:
[oracle@lin-2 admin]$ cat listener.ora # listener.ora Network Configuration /u01/app/oracle/product/11.2.0/db_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/11.2.0/db_1) (SID_NAME = orcl) ) )
LISTENER =
(DESCRIPTION_LIST = (DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = lin-2)(PORT = 1521)) ) )
ADR_BASE_LISTENER = /u01/app/oracle
2.1.2、修改备库的Tnsname
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = lin-1)(PORT = 1521))
File:
(CONNECT_DATA =
(SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )
ORCL2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = lin-2)(PORT = 1521)) (CONNECT_DATA =
(SERVER = DEDICATED) (SERVICE_NAME = orcl2) ) )
三、主库前期准备
设置强制写日志
SQL> select FORCE_LOGGING from v$database; NO
SQL> alter database force logging;
SQL> select FORCE_LOGGING from v$database; YES
四、 创建口令文件
orapwd file=$ORACLE_HOME/dbs/orapworcl password=oracle entries=5
五、修改主库初始化参数
创建主库pfile
sql > create pfile from spfile;
修改主库pfile:
在pfile 中添加如下内容: DB_UNIQUE_NAME=orcl