Oracle Dataguard(主库为双节点集群)配置详解(4):配置备库

news/2025/1/14 9:34:40/

Oracle Dataguard(主库为双节点集群)配置详解(4):配置备库

目录

  • Oracle Dataguard(主库为双节点集群)配置详解(4):配置备库
    • 一、为备库配置静态监听
        • 1、配置 listener.ora 文件
        • 2、重启监听、查看监听状态
        • 3、配置 tnsnames
        • 4、测试连接
    • 二、创建备库的 pfile 文件
        • 1、在主库创建 pfile 文件并复制至备库
        • 2、修改备库的初始化参数文件
    • 三、创建参数文件中涉及到的目录并启动数据库到nomount
        • 1、创建目录
        • 2、启动备库到 nomount

一、为备库配置静态监听

1、配置 listener.ora 文件
[oracle@racdg admin]$ vi listener.ora # listener.ora Network Configuration File: /usr/local/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.LISTENER =(DESCRIPTION_LIST =(DESCRIPTION =(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))(ADDRESS = (PROTOCOL = TCP)(HOST = racdg)(PORT = 1521))))ADR_BASE_LISTENER = /usr/local/oracleSID_LIST_LISTENER =(SID_LIST =(SID_DESC =(GLOBAL_DBNAME = hisdbdg)(ORACLE_HOME = /usr/local/oracle/product/11.2.0/db_1)(SID_NAME = hisdg))
2、重启监听、查看监听状态
[oracle@racdg admin]$ lsnrctl startLSNRCTL for Linux: Version 11.2.0.4.0 - Production on 10-JAN-2025 15:14:59Copyright (c) 1991, 2013, Oracle.  All rights reserved.Starting /usr/local/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /usr/local/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /usr/local/oracle/diag/tnslsnr/racdg/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=racdg)(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                10-JAN-2025 15:14:59
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /usr/local/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /usr/local/oracle/diag/tnslsnr/racdg/listener/alert/log.xml
Listening Endpoints Summary...(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=racdg)(PORT=1521)))
Services Summary...
Service "hisdbdg" has 1 instance(s).Instance "hisdg", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
3、配置 tnsnames

备库的tnsnames文件配置内容与主库相同。

[oracle@racdg dbs]$ vi tnsnames.ora hisdb =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.21)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = hisdb)))hisdb1 =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.1.101)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = hisdb)(SID = his1)))hisdb2 =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.1.102)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = hisdb)(SID = his2)))dghisdb =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.5)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = hisdbdg)))
4、测试连接
[oracle@rac02 admin]$ tnsping hisdbTNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 10-JAN-2025 18:55:14Copyright (c) 1997, 2013, Oracle.  All rights reserved.Used parameter files:Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.21)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = hisdb)))
OK (0 msec)[oracle@rac02 admin]$ tnsping hisdb1TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 10-JAN-2025 18:55:17Copyright (c) 1997, 2013, Oracle.  All rights reserved.Used parameter files:Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.1.101)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = hisdb) (SID = his1)
))OK (0 msec)[oracle@rac02 admin]$ tnsping hisdb2TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 10-JAN-2025 18:55:19Copyright (c) 1997, 2013, Oracle.  All rights reserved.Used parameter files:Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.1.102)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = hisdb) (SID = his2)
))OK (0 msec)[oracle@rac02 admin]$ tnsping hisdbdgTNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 10-JAN-2025 18:55:21Copyright (c) 1997, 2013, Oracle.  All rights reserved.Used parameter files:Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.5)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = hisdbdg)))
OK (0 msec)

二、创建备库的 pfile 文件

1、在主库创建 pfile 文件并复制至备库

(1)在主库创建pfile文件

SQL> create pfile='/home/oracle/inithisdg.ora' from spfile;File created.

(2)把初始化参数文件复制到备库的$ORACLE_HOME/dbs目录

[oracle@rac01 ~]$ pwd
/home/oracle[oracle@rac01 ~]$ ll
total 2487208
drwxr-xr-x 7 oracle oinstall        136 Aug 27  2013 database
-rw-r--r-- 1 oracle asmadmin       2021 Jan 11 10:37 inithisdg.ora
-rw-r--r-- 1 oracle asmadmin       2020 Jan 10 14:13 inithis.ora
-rw-r--r-- 1 oracle oinstall 1395582860 Jan  7  2020 p13390677_112040_Linux-x86-64_1of7.zip
-rw-r--r-- 1 oracle oinstall 1151304589 Jan  7  2020 p13390677_112040_Linux-x86-64_2of7.zip[oracle@rac01 ~]$ scp inithisdg.ora oracle@racdg:/usr/local/oracle/product/11.2.0/db_1/dbs
oracle@racdg's password: 
inithisdg.ora                        100% 2021     2.0KB/s   00:00    
2、修改备库的初始化参数文件

在主库的参数文件基础上进行修改,内容如下:

[oracle@racdg dbs]$ pwd
/usr/local/oracle/product/11.2.0/db_1/dbs
[oracle@racdg dbs]$ ll
总用量 16
-rw-r--r--  1 oracle oinstall 2021 111 10:41 inithisdg.ora
-rw-r--r--. 1 oracle oinstall 2851 515 2009 init.ora
-rw-r-----  1 oracle oinstall 1536 110 14:57 orapwhisdg
-rw-r-----  1 oracle oinstall  914 110 15:21 tnsnames.ora[oracle@rac11gstd dbs]$ vi inithisdg.ora
*.__db_cache_size=385875968
*.__java_pool_size=4194304
*.__large_pool_size=8388608
*.__oracle_base='/usr/local/oracle' #ORACLE_BASE set from environment
*.__pga_aggregate_target=209715200
*.__sga_target=629145600
*.__shared_io_pool_size=0
*.__shared_pool_size=222298112
*.__streams_pool_size=0
*.audit_file_dest='/usr/local/oracle/admin/hisdbdg/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/usr/local/oradata/hisdbdg/control01.ctl','/usr/local/oracle/fast_recovery_area/hisdbdg/control02.ctl'
*.db_block_size=8192
*.db_create_file_dest='/usr/local/oracle'
*.db_domain=''
*.db_file_name_convert='+DATA/hisdb/datafile/','/usr/local/oradata/hisdbdg/'
*.db_file_name_convert='+DATA/hisdb/tempfile/','/usr/local/oradata/hisdbdg/'
*.log_file_name_convert='+DATA/hisdb/onlinelog/','/usr/local/oradata/hisdbdg/'
*.db_name='hisdb'
*.db_unique_name='hisdbdg'
*.db_recovery_file_dest='/usr/local/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4621074432
*.diagnostic_dest='/usr/local/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=hisdbXDB)'
*.fal_client='hisdbdg'
*.fal_server='hisdb'
*.log_archive_config='dg_config=(hisdbdg,hisdb)'
*.log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=hisdbdg'
*.log_archive_dest_2='service=hisdbdg lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=hisdb'
*.log_archive_dest_state_1='enable'
*.log_archive_dest_state_2='enable'
*.open_cursors=300
*.pga_aggregate_target=209715200
*.processes=150
*.remote_login_passwordfile='exclusive'
*.sga_target=629145600
*.standby_file_management='auto'
*.undo_tablespace='UNDOTBS1'

三、创建参数文件中涉及到的目录并启动数据库到nomount

1、创建目录
# 要创建的目录如下:
mkdir -p /usr/local/oracle/admin/hisdbdg/adump
mkdir -p /usr/local/oracle/fast_recovery_area/hisdbdg
mkdir -p /usr/local/oradata/hisdbdg/[oracle@racdg dbs]$ mkdir -p /usr/local/oracle/admin/hisdbdg/adump
[oracle@racdg dbs]$ mkdir -p /usr/local/oracle/fast_recovery_area/hisdbdg
[oracle@racdg dbs]$ mkdir -p /usr/local/oradata/hisdbdg/
2、启动备库到 nomount
-- 使用修改后的 pfile 文件启动备库到 nomount
SQL> startup nomount pfile='$ORACLE_HOME/dbs/inithisdg.ora';
ORACLE instance started.Total System Global Area  626327552 bytes
Fixed Size		    2255832 bytes
Variable Size		  234882088 bytes
Database Buffers	  385875968 bytes
Redo Buffers		    3313664 bytes-- 查看备库的 db_unique_name
SQL> show parameter db_unique_nameNAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
db_unique_name			     string	 hisdbdg-- 生成 spfile 文件
SQL> create spfile from pfile='$ORACLE_HOME/dbs/inithisdg.ora';File created.

http://www.ppmy.cn/news/1562995.html

相关文章

Kafka优势剖析-流处理集成

目录 1. Kafka Streams API 1.1 什么是 Kafka Streams API? 1.2 Kafka Streams 的工作原理 1.3 Kafka Streams 的优势 1.4 Kafka Streams 的典型应用场景 2. KSQL 2.1 什么是 KSQL? 2.2 KSQL 的工作原理 2.3 KSQL 的优势 Kafka 的流处理能力是其…

【物流管理系统 - IDEAJavaSwingMySQL】基于Java实现的物流管理系统导入IDEA教程

有问题请留言或私信 步骤 下载项目源码:项目源码 解压项目源码到本地 打开IDEA 左上角:文件 → 新建 → 来自现有源代码的项目 找到解压在本地的项目源代码文件,点击确定,根据图示步骤继续导入项目 查看项目目录&#xff…

Redis十大数据类型详解

Redis(一) 十大数据类型 redis字符串(String) string是redis最基本的类型,一个key对应一个value string类型是二进制安全的,意思是redis的string可以包含任何数据。例如说是jpg图片或者序列化对象 一个re…

02.05、链表求和

02.05、[中等] 链表求和 1、题目描述 给定两个用链表表示的整数,每个节点包含一个数位。 这些数位是反向存放的,也就是个位排在链表首部。 编写函数对这两个整数求和,并用链表形式返回结果。 2、解题思路 本题要求对两个链表表示的整数…

反弹SHELL不回显带外正反向连接防火墙出入站文件下载

什么是反弹shell 正向连接正向连接(Forward Connection):正向连接是一种常见的网络通信模式,其中客户端主动发起连接到服务器或目标系统。正向连接通常用于客户端-服务器通信,客户端主动请求服务或资源,例如…

Python的循环

Python的循环 Python的循环有两种,分别是for…in循环和while循环。 for…in 循环 假设我们要循环输出一个列表里的元素: names [张三,李四,王五] for name in names:print(name)执行这段代码后,会依次打印names的每一个元素:…

Pathview包:整合表达谱数据可视化KEGG通路

Pathview是一个用于整合表达谱数据并用于可视化KEGG通路的一个R包,其会先下载KEGG官网上的通路图,然后整合输入数据对通路图进行再次渲染,从而对KEGG通路图进行一定程度上的个性化处理,并且丰富其信息展示。(KEGG在线数…

zerox - 使用视觉模型将 PDF 转换为 Markdown

7900 Stars 478 Forks 39 Issues 17 贡献者 MIT License Python 语言 代码: https://github.com/getomni-ai/zerox 主页: OmniAI. Automate document workflows 更多AI开源软件:AI开源 - 小众AI zerox基于视觉模型 API 服务,提供了将 PDF 文档转化为 Mar…