点击上方“IT那活儿”公众号,关注后了解更多内容,不管IT什么活儿,干就完了!!!
作为oracle数据库提供的一种容灾方式,ADG在我们日常生产中还是比较常见的,如何更快更好的搭建一套ADG,也是一个DBA需要掌握的基本技能。
IP: 172.25.18.251
DATABASE VERSION: 11.2.0.4.0
DB_NAME:ptgbss
DB_UNIQUE_NAME:ptgbss
Standby Database
先搭建好备库的数据库软件,无需建库。保持主库和备库的DB_NAME参数一致,DB_UNIQUE_NAME参数不能一致。
主库配置
[oracle@localhost ~]$ telnet 172.25.18.252 1521
Trying 172.25.18.252...
Connected to 172.25.18.252.
Escape character is ^].
^C
^CConnection closed by foreign host.
[oracle@localhost ~]$
vi /u01/product/11.2.0/db_1/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
PTGBSS =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.18.251)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ptgbss)
)
)
PTGBSSDG =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.18.252)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ptgbssdg)
(UR=A)
)
)
tnsping 测试一下是否通:
[oracle@localhost admin]$ tnsping ptgbssdg
2.3 主库开启force_logging
查看是否已经开始强制日志:
select force_logging from v$database;
开启强制日志:
ALTER DATABASE FORCE LOGGING;
2.4 主库配置DG相关参数
主库添加standby 日志,日志大小与online日志保持一致,数量比online日志数量多一组:
set line 200
col member for a50
SELECT * FROM V$LOGFILE;
alter database add standby logfile thread 1 group 10 /u01/oradata/ptgbss/redo10.log size 1024M;
alter database add standby logfile thread 1 group 11 /u01/oradata/ptgbss/redo11.log size 1024M;
alter database add standby logfile thread 1 group 12 /u01/oradata/ptgbss/redo12.log size 1024M;
alter database add standby logfile thread 1 group 13 /u01/oradata/ptgbss/redo13.log size 1024M;
alter database add standby logfile thread 1 group 14 /u01/oradata/ptgbss/redo14.log size 1024M;
alter database add standby logfile thread 1 group 15 /u01/oradata/ptgbss/redo15.log size 1024M;
alter database add standby logfile thread 1 group 16 /u01/oradata/ptgbss/redo16.log size 1024M;
alter database add standby logfile thread 1 group 17 /u01/oradata/ptgbss/redo17.log size 1024M;
alter database add standby logfile thread 1 group 18 /u01/oradata/ptgbss/redo18.log size 1024M;
alter database add standby logfile thread 1 group 19 /u01/oradata/ptgbss/redo19.log size 1024M;
修改DG相关参数:
alter system set LOG_ARCHIVE_CONFIG=DG_CONFIG=(ptgbss,ptgbssdg) scope=both ;
alter system set LOG_ARCHIVE_DEST_1=LOCATION=/data/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ptgbss scope=both;
alter system set LOG_ARCHIVE_DEST_2=SERVICE=ptgbssdg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ptgbssdg scope=both;
alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE scope=both;
alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE scope=both;
alter system set FAL_SERVER=ptgbssdg scope=both;
alter system set FAL_CLIENT=ptgbss scope=both;
alter system set standby_file_management=auto;
alter system set db_file_name_convert=/data/ptgbssdg,/data/ptgbss scope=spfile;
alter system set log_file_name_convert=/u01/oradata/ptgbssdg,/u01/oradata/ptgbss scope=spfile;
2.5 生成PFILE参数文件
create pfile from spfile;
2.6 传输参数文件和密码文件到备库
[oracle@localhost dbs]$ scp /u01/product/11.2.0/db_1/dbs/initptgbss.ora 172.25.18.252:/u01/product/11.2.0/db_1/dbs
[oracle@localhost dbs]$ scp /u01/product/11.2.0/db_1/dbs/orapwptgbss 172.25.18.252:/u01/product/11.2.0/db_1/dbs
备库相关参数配置
1)数据文件目录
2)日志文件目录
3)归档目录
3.2 备库配置listener.ora
[oracle@ptgbssdg ~]$ vi /u01/product/11.2.0/db_1/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/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 = ptgbssdg)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /u01
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ptgbss)
(ORACLE_HOME = /u01/product/11.2.0/db_1)
(SID_NAME = ptgbssdg)
)
)
3.3 备库配置tnsname
# tnsnames.ora Network Configuration File: /u01/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
PTGBSS =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.18.251)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ptgbss)
)
)
PTGBSSDG =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.18.252)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ptgbssdg)
)
)
3.4 备库修改参数文件
ptgbss.__db_cache_size=17448304640
ptgbssdg.__db_cache_size=16642998272
ptgbss.__java_pool_size=134217728
ptgbssdg.__java_pool_size=134217728
ptgbss.__large_pool_size=134217728
ptgbssdg.__large_pool_size=134217728
ptgbss.__oracle_base=/u01#ORACLE_BASE set from environment
ptgbssdg.__oracle_base=/u01#ORACLE_BASE set from environment
ptgbss.__pga_aggregate_target=3422552064
ptgbssdg.__pga_aggregate_target=3422552064
ptgbss.__sga_target=19327352832
ptgbssdg.__sga_target=19327352832
ptgbss.__shared_io_pool_size=0
ptgbssdg.__shared_io_pool_size=0
ptgbss.__shared_pool_size=1476395008
ptgbssdg.__shared_pool_size=2281701376
ptgbss.__streams_pool_size=0
ptgbssdg.__streams_pool_size=0
*.audit_file_dest=/u01/admin/ptgbss/adump --此处修改
*.audit_trail=db
*.compatible=11.2.0.4.0
*.control_files=/u01/oradata/ptgbssdg/control01.ctl,/u01/fast_recovery_area/ptgbssdg/control02.ctl --此处修改存放控制文件路径
*.db_block_size=8192
*.db_domain=
*.db_file_name_convert=/data/ptgbss,/data/ptgbssdg --此处修改
*.db_name=ptgbss --此处修改
*.db_recovery_file_dest=/u01/fast_recovery_area --此处修改对应的路径
*.db_recovery_file_dest_size=4385144832
*.db_unique_name=ptgbssdg --此处修改
*.diagnostic_dest=/u01
*.dispatchers=(PROTOCOL=TCP) (SERVICE=ptgbssXDB)
*.fal_client=PTGBSSDG --此处修改
*.fal_server=PTGBSS --此处修改
*.log_archive_config=DG_CONFIG=(ptgbssdg,ptgbss) --此处修改
*.log_archive_dest_1=location=/data/arch --此处修改
*.log_archive_dest_2=SERVICE=ptgbssdg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ptgbssdg --此处修改
*.log_archive_dest_state_1=ENABLE --修改此处参数
*.log_archive_dest_state_2=ENABLE --修改此处参数
*.log_file_name_convert=/u01/oradata/ptgbss,/u01/oradata/ptgbssdg --此处修改对应路径
*.open_cursors=300
*.pga_aggregate_target=3365928960
*.processes=150
*.remote_login_passwordfile=EXCLUSIVE
*.sga_max_size=19327352832
*.sga_target=19327352832
*.standby_file_management=AUTO
*.undo_tablespace=UNDOTBS1
3.5 启动备库到nomount状态,启动监听
启动监听lsnrctl start:
---主库和备库都需要验证连通性:
sqlplus sys/oracle@ptgbss AS SYSDBA
sqlplus sys/oracle@ptgbssdg AS SYSDBA
3.6 使用RMAN DUPLICATE 主库到备库
rman target sys/oracle@ptgbss auxiliary sys/oracle@ptgbssdg
run
{
allocate channel cl1 type disk;
allocate channel cl2 type disk;
allocate channel cl3 type disk;
allocate auxiliary channel c1 type disk;
allocate auxiliary channel c2 type disk;
allocate auxiliary channel c3 type disk;
duplicate target database for standby from active database nofilenamecheck;
release channel c1;
release channel c2;
release channel c3;
}
备库开启日志应用并查看
4.1 duplicate成功后在备库开启日志应用
alter database open;
alter database recover managed standby database using current logfile disconnect from session;
select sequence#,thread#,applied from v$archived_log;
4.2 查看日志应用情况
col name for a50
select name,SEQUENCE#,APPLIED from v$archived_log order by sequence#;
select max(sequence#) from v$archived_log where applied=YES;
select thread#,max(sequence#) from v$archived_log where applied=YES group by threa
查看错误:
select dest_id,error from v$archive_dest;
查看gap:
select * from v$archive_gap;
查看standby日志状态:
查看备库状态:
select MESSAGE from v$dataguard_status;
总 结:
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/129274.html
RAC补丁日常更新成功反遇异常处理 img{ display:block; margin:0 auto !important; width:100%; } body{ width:75%; m...
摘要:搭建项目前准备工作首先你需要一台电脑,建议做开发的电脑最好是内存以上最佳,土豪随意。技术栈本次搭建主要采用开始搭建创建项目文件夹个人比价喜欢使用创建文件夹,毕竟接下来下载官方脚手架还是的用。 网上搜索了很久Vue项目搭建指南,并没有找到写的比较符合心意的,所以打算自己撸一个指南,集合众家之所长(不善于排版,有点逼死强迫症,如果觉得写的有问题,可以留言斧正,觉得写的太差的,可以留言哪里差...
摘要:项目地址前言大数据技术栈思维导图大数据常用软件安装指南一分布式文件存储系统分布式计算框架集群资源管理器单机伪集群环境搭建集群环境搭建常用命令的使用基于搭建高可用集群二简介及核心概念环境下的安装部署和命令行的基本使用常用操作分区表和分桶表视图 项目GitHub地址:https://github.com/heibaiying... 前 言 大数据技术栈思维导图 大数据常用软件安装指...
摘要:原文地址实战指南二在中搭建服务器学习最快的方法就是直接使用,在实战指南一介绍中,我们已经介绍了如何快速搭建,以及如何在中运行我们的第一个程序。 原文地址:Docker实战指南(二):在Docker中搭建Nginx服务器 Introduction 学习Docker最快的方法就是直接使用,在Docker实战指南(一):Docker介绍中,我们已经介绍了如何快速搭建Docker,以及如何在D...
阅读 1249·2023-01-11 13:20
阅读 1557·2023-01-11 13:20
阅读 1011·2023-01-11 13:20
阅读 1680·2023-01-11 13:20
阅读 3971·2023-01-11 13:20
阅读 2519·2023-01-11 13:20
阅读 1310·2023-01-11 13:20
阅读 3486·2023-01-11 13:20