作者 | JiekeXu
来源 | JiekeXu DBA之路(ID: JiekeXu_IT)
大家好,我是 JiekeXu,很高兴又和大家见面了,今天和大家一起聊聊 Oracle 19C MAA 搭建情况,欢迎点击上方蓝字关注我,标星或置顶,更多干货第一时间到达!
前 言
搭建 19C RAC 对 RAC 的 ADG,网上找了一圈有很多 19c ADG 搭建的文档,但大多数都是单机对单机或者就是 RAC 对单机文件系统的 ADG,没有找到一篇是 RAC 对单机 ASM ADG 的文档,更不用说是 RAC 对 RAC 的 ADG 了。故这里给大家分享一下搭建的过程,我相信尤其是 19C 新特性 ADG 备库密码文件这一块的坑就可以避免踩雷了。
环境搭建前提条件:主库 19.10 RAC 已经安装完成,归档模式已开启;备库安装GI 软件和 DB 软件,创建磁盘组 DATA 和 ARCH,不需要 dbca 建库。双向开通 1521 端口即可,如有必要,可开通 22 端口用于 scp 文件传输并配置主备间互信。
db_unique_name |
DB 版本 |
OS 版本 |
Scan IP |
|
主库 |
JIEKE |
19.10 RAC |
Linuxone SUSE12SP5 |
XXX.XX.65.137 |
备库 |
JIEKESTB |
19.10 RAC |
Linuxone SUSE12SP5 |
XXX.XX.203.171 |
注:主备库均为非 CDB,文中涉及到的主机名及 IP 和实例名相关信息均已脱敏处理 |
ADG 搭建步骤大体总结如下十大步:
1、检查主库归档模式;2、打开主库强制日志模式;3、主库创建 standy 日志组;4、创建备库密码文件;5、修改主库参数文件并传至备库;6、修改备库参数文件并启动到 nomount;7、配置备库静态监听和tns并测试网络连通性;8、duplicate 恢复备库;9、应用 MRP0 日志进程开库;10、测试同步情况检查主备库状态。
下面分开描述搭建过程:
1)检查主库归档模式
su – oracle
sqlplus / as sysdba
archive log list;
-- 如果未开启归档模式,需重启开 归档
2)打开数据库强制日志
确认数据库日志模式:
select name,log_mode,force_logging from v$database;
NAME LOG_MODE FORCE_LOGGING
--------- ------------ ---------------------------------------
JIEKE ARCHIVELOG NO --此处为 NO 表示未打开强制日志模式
打开强制日志:
alter database force logging;
select name,log_mode,force_logging from v$database;
NAME LOG_MODE FORCE_LOGGING
--------- ------------ ---------------------------------------
JIEKE ARCHIVELOG YES
3)创建 standby 日志组
查看原生产库的日志信息,大小与原生产库一致:
set linesize 250
COLUMN groupno FORMAT a6 HEADING 'Group'
COLUMN thread FORMAT a6 HEADING 'Thread'
COLUMN member FORMAT a50 HEADING 'Member'
COLUMN redo_file_type FORMAT a10 HEADING 'Redo Type'
COLUMN group_status FORMAT a12 HEADING 'Group Status'
COLUMN member_status FORMAT a15 HEADING 'Member Status'
COLUMN bytes FORMAT 999,999 HEADING 'Size(M)'
COLUMN archived FORMAT a10 HEADING 'Archived?'
BREAK ON groupno
SELECT
to_char(f.group#) groupno
, to_char(l.thread#) thread
, f.member member
, f.type redo_file_type
, l.status group_status
, f.status member_status
, l.bytes/1024/1024 bytes
, l.archived archived
FROM
v$logfile f
, v$log l
WHERE
f.group# = l.group#
ORDER BY
f.group#
, f.member;
Group Thread Member Redo Type Group Status Member Status Size(M) Archived?
------ ------ -------------------------------------------------- ---------- ------------ --------------- -------- ----------
1 1 +JIEKER_ARCH/JIEKE/ONLINELOG/group_1.274.1071137137 ONLINE CURRENT 4,096 NO
1 +JIEKER_DATA/JIEKE/ONLINELOG/group_1.287.1071137125 ONLINE CURRENT 4,096 NO
2 1 +JIEKER_ARCH/JIEKE/ONLINELOG/group_2.266.1071137137 ONLINE INACTIVE 4,096 YES
1 +JIEKER_DATA/JIEKE/ONLINELOG/group_2.285.1071137125 ONLINE INACTIVE 4,096 YES
3 2 +JIEKER_ARCH/JIEKE/ONLINELOG/group_3.1057.1071137579 ONLINE INACTIVE 4,096 YES
2 +JIEKER_DATA/JIEKE/ONLINELOG/group_3.281.1071137575 ONLINE INACTIVE 4,096 YES
4 2 +JIEKER_ARCH/JIEKE/ONLINELOG/group_4.1056.1071137585 ONLINE INACTIVE 4,096 YES
2 +JIEKER_DATA/JIEKE/ONLINELOG/group_4.280.1071137583 ONLINE INACTIVE 4,096 YES
5 1 +JIEKER_ARCH/JIEKE/ONLINELOG/group_5.1058.1071137137 ONLINE INACTIVE 4,096 YES
1 +JIEKER_DATA/JIEKE/ONLINELOG/group_5.286.1071137125 ONLINE INACTIVE 4,096 YES
6 1 +JIEKER_ARCH/JIEKE/ONLINELOG/group_6.261.1071137137 ONLINE INACTIVE 4,096 YES
Group Thread Member Redo Type Group Status Member Status Size(M) Archived?
------ ------ -------------------------------------------------- ---------- ------------ --------------- -------- ----------
6 1 +JIEKER_DATA/JIEKE/ONLINELOG/group_6.284.1071137125 ONLINE INACTIVE 4,096 YES
7 2 +JIEKER_ARCH/JIEKE/ONLINELOG/group_7.1055.1071137593 ONLINE CURRENT 4,096 NO
2 +JIEKER_DATA/JIEKE/ONLINELOG/group_7.278.1071137589 ONLINE CURRENT 4,096 NO
8 2 +JIEKER_ARCH/JIEKE/ONLINELOG/group_8.1054.1071137599 ONLINE INACTIVE 4,096 YES
2 +JIEKER_DATA/JIEKE/ONLINELOG/group_8.277.1071137595 ONLINE INACTIVE 4,096 YES
添加 standby 日志组(大小一致):
19c 主库日志一般都是多路复用,DATA 和 归档 ARCH 盘里都有 redo 日志组, standby redolog 可酌情多路复用
ALTER DATABASE ADD standby LOGFILE THREAD 1 ('+JIEKER_DATA','+JIEKER_ARCH') SIZE 4G;
ALTER DATABASE ADD standby LOGFILE THREAD 1 ('+JIEKER_DATA','+JIEKER_ARCH') SIZE 4G;
ALTER DATABASE ADD standby LOGFILE THREAD 1 ('+JIEKER_DATA','+JIEKER_ARCH') SIZE 4G;
ALTER DATABASE ADD standby LOGFILE THREAD 1 ('+JIEKER_DATA','+JIEKER_ARCH') SIZE 4G;
ALTER DATABASE ADD standby LOGFILE THREAD 1 ('+JIEKER_DATA','+JIEKER_ARCH') SIZE 4G;
ALTER DATABASE ADD standby LOGFILE THREAD 2 ('+JIEKER_DATA','+JIEKER_ARCH') SIZE 4G;
ALTER DATABASE ADD standby LOGFILE THREAD 2 ('+JIEKER_DATA','+JIEKER_ARCH') SIZE 4G;
ALTER DATABASE ADD standby LOGFILE THREAD 2 ('+JIEKER_DATA','+JIEKER_ARCH') SIZE 4G;
ALTER DATABASE ADD standby LOGFILE THREAD 2 ('+JIEKER_DATA','+JIEKER_ARCH') SIZE 4G;
ALTER DATABASE ADD standby LOGFILE THREAD 2 ('+JIEKER_DATA','+JIEKER_ARCH') SIZE 4G;
select group#,MEMBER from v$logfile;
select GROUP#,THREAD#,BYTES/1024/1024 mb from v$standby_log;
密码文件存在于 ASM 磁盘组中,需将其 cp 到文件系统然后在传到备库。
--密码文件存在于 ASM 磁盘组中,需将其 cp 到文件系统然后在传到备库。
ASMCMD> cd JIEKE
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
PASSWORD/
TEMPFILE/
ASMCMD> cd PASSWORD
ASMCMD> ls
pwdJIEKE.256.1071137005
ASMCMD> pwd
+JIEKER_DATA/JIEKE/PASSWORD
ASMCMD> pwcopy pwdJIEKE.256.1071137005 /home/grid/orapwJIEKESTB
copying +JIEKER_DATA/JIEKE/PASSWORD/pwdJIEKE.256.1071137005 -> /home/grid/orapwJIEKESTB
--配置互信免密后使用 scp 将密码传至备库
scp orapwJIEKESTB 100.33.xx.xxx:/home/grid/orapwJIEKESTB
-- 然后复制密码文件到备库 ASM 下
ASMCMD> pwcopy /home/grid/orapwJIEKESTB +JIEKER_DATA/JIEKESTB/PASSWORD/
copying /home/grid/orapwJIEKESTB -> +JIEKER_DATA/JIEKESTB/PASSWORD/orapwJIEKESTB
ASMCMD> ls -l
Type Redund Striped Time Sys Name
PASSWORD UNPROT COARSE APR 29 11:00:00 N orapwJIEKESTB => +JIEKER_DATA/DB_UNKNOWN/PASSWORD/pwddb_unknown.256.1071140915
同步完密码文件后期如果修改了 SYS 管理员密码时,官方文档中有如下说明:
官方文档中关于刷新密码文件的说明大概如下:如果该 REMOTE_LOGIN_PASSWORDFILE 数据库初始化参数设置为 SHARED 或 EXCLUSIVE ,则物理备用数据库上的密码文件将自动替换为主数据库的新副本。在授予或撤消管理特权或更改具有管理特权的用户的密码后,将替换该文件。唯一的例外是 far sync 实例。更新的密码文件仍然必须手动复制到 far sync 实例,因为 far sync 接收 redo,但不应用它。在 far sync 实例上手动更新密码文件时,包含来自主数据库的相同密码更改的 redo 将自动传播到设置为从 far sync 实例接收重做的任何备用数据库。当应用 redo 时,将在待机状态下更新密码文件。
show parameter spfile
备份参数文件
create pfile='/home/oracle/pfile0527.ora' from spfile;
主库修改如下参数:
alter system set db_unique_name=JIEKE scope=spfile sid='*'; --DB_UNIQUE_NAME 唯一名,与主库一定不能一样
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(JIEKE,JIEKESTB)';
alter system set LOG_ARCHIVE_DEST_1='LOCATION=+JIEKER_ARCHVALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=JIEKE';
alter system set LOG_ARCHIVE_DEST_2='SERVICE=JIEKESTB LGWR ASYNCVALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=JIEKESTB';
alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE;
alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE;
alter system set FAL_SERVER=JIEKESTB;
alter system set FAL_CLIENT=JIEKE;
alter system set standby_file_management=auto;
重启数据库,当不修改 db_unique_name 和 db_file_name_convert 以及 log_file_name_convert 时不需重启实例。但备库一定要有唯一数据库名 db_unique_name ,db_name 主备库一定得一样。
主库两节点均重启
shu immediate
startup
create pfile='/tmp/pfile0527.ora' from spfile;
参数文件传输到备库
scp /tmp/pfile0527.ora 100.33.xx.xxx:/home/oracle
6)备库修改参数并启动到 nomount
vi pfile0527.ora 做如下替换