热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

CentOS6.5+Oracle11.2.0.4的ADG环境搭建

预先下载1.VMwareworkstation2.CentOS6.53.linuxOracle11.2.0.4链接:https:pan.baidu.coms1

预先下载

1.VMware workstation

2. CentOS 6.5

3. linux Oracle 11.2.0.4

链接:https://pan.baidu.com/s/1_VaYV-uFO06k_49A_U8y9A 提取码:iqax


安装

1.安装CentOS6.5虚拟机,IP 192.168.18.23,作为 primary(主机)

2.安装并配置单实例Oracle 11.2.0.4

3.完成以上两步后,关闭虚拟机,然后克隆新虚拟机,IP 192.168.18.24 作为standby(备机)

 


ADG安装


1. Primary主机配置

开启归档模式

SQL>shutdown immediate;SQL>startup mount;
设置强制日志模式
SQL>alter database force logging;
设置为归档模式
SQL>alter database archivelog;SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /opt/oracle/oradata/orcl
Oldest online log sequence 17
Next log sequence to archive 19
Current log sequence 19
SQL>

添加standby redo log

       查看online redo log

select * from v$log;

      添加的standby redo log比online redo log多一组

alter database add standby logfile group 4 ('/opt/oracle/oradata/orcl/standby_log04.log') size 50M;
alter database add standby logfile group 5 ('/opt/oracle/oradata/orcl/standby_log05.log') size 50M;
alter database add standby logfile group 6 ('/opt/oracle/oradata/orcl/standby_log06.log') size 50M;
alter database add standby logfile group 7 ('/opt/oracle/oradata/orcl/standby_log07.log') size 50M;

      查看standby redo log

select * from v$standby_log;

2. TNS通信配置(主备)

主备分别配置listner.ora tnsname.ora

#表示主备机器的实际IP

listner.ora

# listener.ora Network Configuration File: /opt/oracle/product/OraHome/network/admin/listener.ora
# Generated by Oracle configuration tools.SID_LIST_LISTENER =(SID_LIST =(SID_DESC =(GLOBAL_DBNAME = orcl)(ORACLE_HOME = /opt/oracle/product/OraHome)(SID_NAME = orcl)))LISTENER =(DESCRIPTION_LIST =(DESCRIPTION =(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.2#)(PORT = 1521))))ADR_BASE_LISTENER = /opt/oracle

tnsname.ora

# tnsnames.ora Network Configuration File: /opt/oracle/product/OraHome/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.LISTENER_ORCL =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.2#)(PORT = 1521))main =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.23)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = orcl)))back =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.24)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = orcl)))

重启监听

[oracle@cent6 admin]$ lsnrctl stopLSNRCTL for Linux: Version 11.2.0.4.0 - Production on 30-NOV-2020 08:31:20Copyright (c) 1991, 2013, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
[oracle@cent6 admin]$ lsnrctl startLSNRCTL for Linux: Version 11.2.0.4.0 - Production on 30-NOV-2020 08:31:26Copyright (c) 1991, 2013, Oracle. All rights reserved.Starting /opt/oracle/product/OraHome/bin/tnslsnr: please wait...TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /opt/oracle/product/OraHome/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/cent6/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.18.23)(PORT=1521)))Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 30-NOV-2020 08:31:26
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/OraHome/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/cent6/listener/alert/log.xml
Listening Endpoints Summary...(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.18.23)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@cent6 admin]$

确认配置正确,相互之间能tnsping通

[oracle@cent6 admin]$ tnsping mainTNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 30-NOV-2020 08:30:17Copyright (c) 1997, 2013, Oracle. All rights reserved.Used parameter files:
/opt/oracle/product/OraHome/network/admin/sqlnet.oraUsed TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.23)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
OK (0 msec)

[oracle@cent6 admin]$ tnsping backTNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 30-NOV-2020 08:30:22Copyright (c) 1997, 2013, Oracle. All rights reserved.Used parameter files:
/opt/oracle/product/OraHome/network/admin/sqlnet.oraUsed TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.24)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
OK (10 msec)
[oracle@cent6 admin]$

3.ADG配置文件准备(主备)

创建pfile

create pfile = '/opt/oracle/pfile' from spfile;

Primary(主)库修改pfile配置,添加如下部分

*.db_unique_name='main'
这个参数代表唯一名称,设置成刚刚tnsnames配置的别名名称
*.log_archive_config='dg_config=(main,back)'
归档配置,参数里面需要填写两个库的db_unique_name。
*.log_archive_dest_1='location=/opt/oracle/oradata/orcl valid_for=(all_logfiles,all_roles) db_unique_name=main'
这里dest_1 代表主库,localtion 代表主库归档日志存放路径
*.log_archive_dest_2='service=back lgwr async affirm valid_for=(online_logfiles,primary_role) db_unique_name=back'
这里dest_2代表备库,service代表备库的 db_unique_name,设置成刚刚tnsnames配置的别名名称
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.log_archive_max_processes=4
*.fal_server='back'
*.fal_client='main'
*.db_file_name_convert='/opt/oracle/oradata/orcl','/opt/oracle/oradata/orcl'
*.log_file_name_convert='/opt/oracle/oradata/orcl','/opt/oracle/oradata/orcl'
*.standby_file_management='auto'

standby(备)库修改pfile配置,添加如下部分

*.db_unique_name='back'
*.log_archive_config='dg_config=(main,back)'
*.log_archive_dest_1='location=/opt/oracle/oradata/orcl valid_for=(all_logfiles,all_roles) db_unique_name=main'
*.log_archive_dest_2='service=main lgwr async affirm valid_for=(online_logfiles,primary_role) db_unique_name=main'
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.log_archive_max_processes=4
*.fal_server='main'
*.fal_client='back'
*.db_file_name_convert='/opt/oracle/oradata/orcl','/opt/oracle/oradata/orcl'
*.log_file_name_convert='/opt/oracle/oradata/orcl','/opt/oracle/oradata/orcl'
*.standby_file_management='auto'

Primary(主)库使用pfile重启

SQL>shutdown immediate;
SQL>startup pfile='/opt/oracle/pfile';

Standby(备)库使用pfile重启至nomount状态

SQL>shutdown immediate;
SQL>startup nomount pfile='/opt/oracle/pfile';

4.RMAN复制(仅Standby(备)库)

RMAN连接主备库

[oracle@cent6 admin]$ rman target sys/schina@main auxiliary sys/schina@backRecovery Manager: Release 11.2.0.4.0 - Production on Mon Nov 30 05:29:28 2020Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.connected to target database: ORCL (DBID=1585353176)
connected to auxiliary database: ORCL (not mounted)

使用RMAN开始复制

RMAN> duplicate target database for standby from active database nofilenamecheck;Starting Duplicate Db at 30-NOV-20
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=129 device type=DISKcontents of Memory Script:
{backup as copy reusetargetfile '/opt/oracle/product/OraHome/dbs/orapworcl' auxiliary format '/opt/oracle/product/OraHome/dbs/orapworcl' ;
}
executing Memory ScriptStarting backup at 30-NOV-20
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=201 device type=DISK
Finished backup at 30-NOV-20
省略部分。。。。

复制完成后,Standby默认处于mount状态,需要手动打开

SQL>alter database open;
数据库已更改。启用备库日志文件
SQL>alter database recover managed standby database using current logfile disconnect from session;
关闭备库日志文件
SQL>alter database recover managed standby database cancel;

5.确认日志序号(主备)

分别在主备执行archive log list,确保主备的Current log sequence(当前日志序列)一致

SQL>archive log list

6.数据同步

在主库创建表T并插入数据,然后在备库查看,确认是否已同步

CREATE TABLE t(cno INT PRIMARY KEY,NAME VARCHAR2(20),sex CHAR(5),birthday DATE);
INSERT INTO t VALUES(1,'宋爱梅','女',SYSDATE-1000);
INSERT INTO t VALUES(2,'王志芳','女',SYSDATE-1234);
INSERT INTO t VALUES(3,'贾隽仙','女',SYSDATE-1034);
INSERT INTO t VALUES(4,'刘振杰','男',SYSDATE-1340);
INSERT INTO t VALUES(5,'郭卫东','男',SYSDATE-1312);
INSERT INTO t VALUES(6,'崔红宇','男',SYSDATE-1888);
INSERT INTO t VALUES(7,'马福平','男',SYSDATE-1777);
INSERT INTO t VALUES(8,'冯红','女',SYSDATE-1666);
INSERT INTO t VALUES(9,'穆增志','男',SYSDATE-1555);
INSERT INTO t VALUES(10,'付金旺','男',SYSDATE-1444);
COMMIT;

登录Standby(备)库,查询T表


7.修改数据库启动为spfile

将pfile转换为spfile

SQL>create spfile from pfile='/opt/oracle/pfile'

重启数据库

SQL>shutdown immediate;SQL>startup;

8.备份虚拟机

将主备虚拟机关机,然后创建快照

 

问题排查

1.ORA-01153: an incompatible media recovery is active

2.ORA-16014: not archived, no available destinations

 


推荐阅读
  • CentOS 7.6环境下Prometheus与Grafana的集成部署指南
    本文旨在提供一套详细的步骤,指导读者如何在CentOS 7.6操作系统上成功安装和配置Prometheus 2.17.1及Grafana 6.7.2-1,实现高效的数据监控与可视化。 ... [详细]
  • 主调|大侠_重温C++ ... [详细]
  • 在高并发需求的C++项目中,我们最初选择了JsonCpp进行JSON解析和序列化。然而,在处理大数据量时,JsonCpp频繁抛出异常,尤其是在多线程环境下问题更为突出。通过分析发现,旧版本的JsonCpp存在多线程安全性和性能瓶颈。经过评估,我们最终选择了RapidJSON作为替代方案,并实现了显著的性能提升。 ... [详细]
  • 在Fedora 31上部署PostgreSQL 12
    本文详细介绍如何在Fedora 31操作系统上安装和配置PostgreSQL 12数据库。包括环境准备、安装步骤、配置优化以及安全设置,确保数据库能够稳定运行并提供高效的性能。 ... [详细]
  • 深入解析ESFramework中的AgileTcp组件
    本文详细介绍了ESFramework框架中AgileTcp组件的设计与实现。AgileTcp是ESFramework提供的ITcp接口的高效实现,旨在优化TCP通信的性能和结构清晰度。 ... [详细]
  • ElasticSearch 集群监控与优化
    本文详细介绍了如何有效地监控 ElasticSearch 集群,涵盖了关键性能指标、集群健康状况、统计信息以及内存和垃圾回收的监控方法。 ... [详细]
  • 并发编程 12—— 任务取消与关闭 之 shutdownNow 的局限性
    Java并发编程实践目录并发编程01——ThreadLocal并发编程02——ConcurrentHashMap并发编程03——阻塞队列和生产者-消费者模式并发编程04——闭锁Co ... [详细]
  • 本文详细介绍了如何在云服务器上配置Nginx、Tomcat、JDK和MySQL。涵盖从下载、安装到配置的完整步骤,帮助读者快速搭建Java Web开发环境。 ... [详细]
  • 本文深入探讨了UNIX/Linux系统中的进程间通信(IPC)机制,包括消息传递、同步和共享内存等。详细介绍了管道(Pipe)、有名管道(FIFO)、Posix和System V消息队列、互斥锁与条件变量、读写锁、信号量以及共享内存的使用方法和应用场景。 ... [详细]
  • 本文介绍如何配置SecureCRT以正确显示Linux终端的颜色,并解决中文显示问题。通过简单的步骤设置,可以显著提升使用体验。 ... [详细]
  • cJinja:C++编写的轻量级HTML模板引擎
    本文介绍了cJinja,这是一个用C++编写的轻量级HTML模板解析库。它利用ejson来处理模板中的数据替换(即上下文),其语法与Django Jinja非常相似,功能强大且易于学习。 ... [详细]
  • 俗话说得好,“工欲善其事,必先利其器”。这句话不仅强调了工具的重要性,也提醒我们在任何项目开始前,准备合适的工具至关重要。本文将介绍几款C语言编程中常用的工具,帮助初学者更好地选择适合自己学习和工作的编程环境。 ... [详细]
  • 深入解析SpringMVC核心组件:DispatcherServlet的工作原理
    本文详细探讨了SpringMVC的核心组件——DispatcherServlet的运作机制,旨在帮助有一定Java和Spring基础的开发人员理解HTTP请求是如何被映射到Controller并执行的。文章将解答以下问题:1. HTTP请求如何映射到Controller;2. Controller是如何被执行的。 ... [详细]
  • 离线安装Grafana Cloudera Manager插件并监控CDH集群
    本文详细介绍如何离线安装Cloudera Manager (CM) 插件,并通过Grafana监控CDH集群的健康状况和资源使用情况。该插件利用CM提供的API接口进行数据获取和展示。 ... [详细]
  • yikesnews第11期:微软Office两个0day和一个提权0day
    点击阅读原文可点击链接根据法国大选被黑客干扰,发送了带漏洞的文档Trumps_Attack_on_Syria_English.docx而此漏洞与ESET&FireEy ... [详细]
author-avatar
HANK_LIU刘浩象_862
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有