最近有个项目要干,对现有生产的RAC进行一个改造
客户原有两个IBM P710小型机要替换成国产浪潮K1 power s914小型机。(额,国产化替代也算,不要问我为啥国产的机器和原来的小型机可以做ADG。。。)
开干前,我再用模拟环境还原一下整个项目的操作流程。由于整个过程比较长,我预计分3篇文章来分别对各个环境进行实验(我这实验环境没有小型机拉,用LINUX代替,原理1毛1样)
关于如何搭建RAC-单机的ADG可以参考我的另一篇文章:搭建记录:RAC到单实例搭建Dataguard
那么先开始第1篇:RAC-RAC主备搭建
现有模拟环境如下图所示
2台数据库RAC主机(两台主机心跳线直连),灾备机房有1个单机DG容灾,现有示意图如下:
计划新增2节点RAC主机,替换原有两台数据库RAC。
替换之后原有两台RAC做为主中心备库,改用另1台存储数据进行存储(还需要做一次存储迁移)
改造步骤大致如下:
第1步,先在原有双活存储上划出1部分空间给新搭建的RAC点节;(这部分比较简单我就不实验了)
第2点,进行DATAGUARD迁移,主备切换,新的RAC节点切换成主节点,原有的变成备节点;(实验内容1)
第3步,修改IP地址,把原主RAC的IP(PUBLIC-IP/VIP/SCAN)都配置到新的RAC节点上;(实验内容2)
第4步,恢复RAC-RAC-单机DG环境;(实验内容2)
第5点,替换后的旧RAC主机切换存储,项目完成。(实验内容3)
改造之后如下图所示:
项目 |
RAC01 |
RAC02 |
单机DG |
计划新增RAC1 |
计划新增RAC2 |
操作系统版本 |
redhat 6.9 |
redhat 6.9 |
redhat 6.9 |
redhat 6.9 |
redhat 6.9 |
数据库版本 |
11.2.0.4 |
11.2.0.4 |
11.2.0.4 |
11.2.0.4 |
11.2.0.4 |
GI版本 |
11.2.0.4 |
11.2.0.4 |
11.2.0.4 |
11.2.0.4 |
11.2.0.4 |
hostname |
rac01 |
rac02 |
oracle |
rac01 |
rac02 |
实例名 |
orcl1 |
orcl2 |
orcl |
orcl1 |
orcl2 |
db_unique_name |
primary |
primary |
orcldg |
orcl | orcl |
数据磁盘组路径 |
+DATA |
+DATA |
/u01/app/oracle/oradata/orcldg |
+DATA |
+DATA |
归档路径 |
+DATA |
+DATA |
/u01/app/oracle/oradata/orcldg/archivelog |
+DATA |
+DATA |
目前主库RAC的HOSTS
192.168.56.10 rac1
192.168.56.11 rac2
10.10.10.1 rac1-priv
10.10.10.2 rac2-priv
192.168.56.12 rac1-vip
192.168.56.13 rac2-vip
192.168.56.14 rac-scan
目前备库RAC的HOSTS
192.168.56.30 rac1
192.168.56.31 rac2
10.10.10.1 rac1-priv
10.10.10.2 rac2-priv
192.168.56.32 rac1-vip
192.168.56.33 rac2-vip
192.168.56.20 rac-scan
为了和真实环境下,我也按生产搞了一下(生产库之前不知道谁搭建的DG,把库的db_unique_name给改成了primary),显示的位置都比较奇怪。
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DATA/orcl/datafile/system.256.1086172033
+DATA/orcl/datafile/sysaux.257.1086172033
+DATA/orcl/datafile/undotbs1.258.1086172033
+DATA/orcl/datafile/users.259.1086172033
+DATA/orcl/datafile/undotbs2.267.1086172237
+DATA/orcl/datafile/prod.273.1086172629
+DATA/primary/datafile/users.297.1147790221
+DATA/primary/datafile/users.331.1147792495
+DATA/primary/datafile/users.335.1147792667
+DATA/primary/datafile/users.338.1147793229
+DATA/primary/datafile/users.339.1147793259
+DATA/primary/datafile/users.353.1147806089
+DATA/primary/datafile/users.378.1147818285
13 rows selected.
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
+DATA/orcl/onlinelog/group_2.264.1086172199
+DATA/orcl/onlinelog/group_2.265.1086172203
+DATA/orcl/onlinelog/group_1.262.1086172195
+DATA/orcl/onlinelog/group_1.263.1086172197
+DATA/orcl/onlinelog/group_3.268.1086172281
+DATA/orcl/onlinelog/group_3.269.1086172283
+DATA/orcl/onlinelog/group_4.270.1086172287
+DATA/orcl/onlinelog/group_4.271.1086172289
+DATA/primary/onlinelog/group_11.274.1147787227
+DATA/primary/onlinelog/group_12.275.1147787229
+DATA/primary/onlinelog/group_13.276.1147787231
+DATA/primary/onlinelog/group_14.277.1147787233
+DATA/primary/onlinelog/group_15.278.1147787235
+DATA/primary/onlinelog/group_21.279.1147787239
+DATA/primary/onlinelog/group_22.280.1147787241
+DATA/primary/onlinelog/group_23.281.1147787243
+DATA/primary/onlinelog/group_24.282.1147787245
+DATA/primary/onlinelog/group_25.283.1147787247
18 rows selected.
在搭建好的11G RAC环境使用dbca创建数据库
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname orcl -sid orcl -sysPassword oracle -systemPassword oracle -datafileDestination '+DATA' -redoLogFileSize 50 -recoveryAreaDestination '+DATA' -storageType ASM -asmsnmpPassword system -emConfiguration NONE -diskGroupName 'DATA' -responseFile NO_VALUE -characterset ZHS16GBK -nationalCharacterSet AL16UTF16 -sampleSchema true -automaticMemoryManagement true -totalMemory 1024 -nodeinfo rac1,rac2
Copying database files
1% complete
3% complete
9% complete
15% complete
21% complete
27% complete
30% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
44% complete
45% complete
48% complete
50% complete
Creating cluster database views
52% complete
70% complete
Completing Database Creation
73% complete
76% complete
85% complete
94% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.
也可以用响应文件来弄,创建响应文件my.rsp内容如下
[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD="oracle"
SYSTEMPASSWORD="oracle"
SYSMANPASSWORD="oracle"
EMCONFIGURATION = "NONE"
DATAFILEDESTINATION="+DATA"
RECOVERYAREADESTINATION="+DATA"
STORAGETYPE="ASM"
DISKGROUPNAME="DATA"
CHARACTERSET="ZHS16GBK"
NATIONALCHARACTERSET="AL16UTF16"
AUTOMATICMEMORYMANAGEMENT = "TRUE"
TOTALMEMORY = "800"
NODELIST = "rac1,rac2"
然后执行
dbca -createDatabase -silent -responseFile my.rsp
关于DBCA静默创建,我这里简单加一下帮助,大家可以自己研究一下
[oracle@rac1 trace]$ dbca -h
dbca [-silent | -progressOnly | -customCreate] { } | { [ [options] ] -responseFile } [-continueOnNonFatalErrors ]
Please refer to the manual for details.
You can enter one of the following command:
Create a database by specifying the following parameters:
-createDatabase
-templateName
[-cloneTemplate]
-gdbName
[-RACOneNode
-RACOneNodeServiceName ]
[-policyManaged | -adminManaged ]
[-createServerPool ]
[-force ]
-serverPoolName
-[cardinality ]
[-sid ]
[-sysPassword ]
[-systemPassword ]
[-emConfiguration
-dbsnmpPassword
-sysmanPassword
[-hostUserName
-hostUserPassword
-backupSchedule ]
[-centralAgent ]]
[-disableSecurityConfiguration
[-datafileDestination | -datafileNames ]
[-redoLogFileSize ]
[-recoveryAreaDestination ]
[-datafileJarLocation ]
[-storageType < CFS | ASM >
[-asmsnmpPassword ]
-diskGroupName
-recoveryGroupName
[-nodelist ]
[-characterSet ]
[-nationalCharacterSet ]
[-registerWithDirService
-dirServiceUserName
-dirServicePassword
-walletPassword ]
[-listeners ]
[-variablesFile ]]
[-variables ]
[-initParams ]
[-sampleSchema ]
[-memoryPercentage ]
[-automaticMemoryManagement ]
[-totalMemory ]
[-databaseType ]]
Configure a database by specifying the following parameters:
-configureDatabase
-sourceDB
[-sysDBAUserName
-sysDBAPassword ]
[-registerWithDirService|-unregisterWithDirService|-regenerateDBPassword
-dirServiceUserName
-dirServicePassword
-walletPassword ]
[-disableSecurityConfiguration
[-enableSecurityConfiguration
[-emConfiguration
-dbsnmpPassword
-sysmanPassword
[-hostUserName
-hostUserPassword
-backupSchedule ]
[-centralAgent ]]
Create a template from an existing database by specifying the following parameters:
-createTemplateFromDB
-sourceDB ::>
-templateName
-sysDBAUserName
-sysDBAPassword
[-maintainFileLocations ]
Create a clone template from an existing database by specifying the following parameters:
-createCloneTemplate
-sourceSID
RAC1节点切到grid用户,增加静态监听,确认监听生效。
[root@rac1 ~]# su - grid
[grid@rac1 ~]$ cd /g01/app/11.2.0/grid/network/admin/
[grid@rac1 admin]$ cat listener.ora
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME= PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=orcl1)
)
)
[grid@rac1 admin]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 19-DEC-2023 19:47:50
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 19-DEC-2023 09:17:06
Uptime 0 days 10 hr. 30 min. 43 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /g01/app/11.2.0/grid/network/admin/listener.ora
Listener Log File /g01/app/grid/diag/tnslsnr/rac1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.30)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.32)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
Instance "orcl1", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
RAC2节点切换到Grid用户,增加静态监听,确认监听生效。
[root@rac2 ~]# su - grid
[grid@rac2 ~]$ cd /g01/app/11.2.0/grid/network/admin/
[grid@rac2 admin]$ cat listener.ora
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME= PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=orcl2)
)
)
[grid@rac2 admin]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 19-DEC-2023 19:47:32
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 19-DEC-2023 09:17:16
Uptime 0 days 10 hr. 30 min. 16 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /g01/app/11.2.0/grid/network/admin/listener.ora
Listener Log File /g01/app/grid/diag/tnslsnr/rac2/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.31)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.33)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
Instance "orcl2", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[grid@rac2 admin]$
alter system set db_file_name_convert='+DATA','+DATA' scope=spfile;
alter system set log_file_name_convert='+DATA','+DATA' scope=spfile;
alter system set fal_client='orcl' scope=spfile;
alter system set fal_server='primary' scope=spfile;
alter system set log_archive_config='DG_CONFIG=(primary,orcl)' scope=spfile;
alter system set log_archive_dest_1='location=+DATA valid_for=(all_logfiles,all_roles) db_unique_name=orcl' scope=spfile;
alter system set log_archive_dest_2='service=primary ASYNC NOAFFIRM valid_for=(online_logfiles,primary_role) db_unique_name=primary' scope=spfile;
alter system set log_archive_format='%t_%s_%r.dbf' scope=spfile;
alter system set standby_file_management='AUTO' scope=spfile;
这里需要在RAC备库的两个节点$ORACLE_HOME/network/admin/tnsname.ora增加如下内容。
PRIMARY =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.12)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.13)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
RACDG =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.32)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.33)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
RAC主库的tnsnames.ora需要添加RAC备库的监听
RACDG =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.32)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.33)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
在RAC主库,拷贝主库口令文件到RAC备库2个节点,并进行md5校验
[oracle@rac1 ~]$ cd /u01/app/oracle/product/11.2.0/dbhome_1/dbs/
[oracle@rac1 dbs]$ scp -r orapworcl1 [email protected]:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapworcl1
orapworcl1 100% 1536 1.5KB/s 00:00
[oracle@rac1 dbs]$ scp -r orapworcl1 [email protected]:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapworcl2
orapworcl1 100% 1536 1.5KB/s 00:00
[oracle@rac1 dbs]$ md5sum orapworcl1
1636465ada9d006d0e1828c6a0bc4812 orapworcl1
去到RAC备库2个节点,分别进行下口令文件校验。
[oracle@rac1 dbs]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/dbs
[oracle@rac1 dbs]$ md5sum orapworcl1
1636465ada9d006d0e1828c6a0bc4812 orapworcl1
[oracle@rac2 admin]$ cd /u01/app/oracle/product/11.2.0/dbhome_1/dbs/
[oracle@rac2 dbs]$ md5sum orapworcl2
1636465ada9d006d0e1828c6a0bc4812 orapworcl2
在RAC备库的RAC1节点,使用oracle用户执行关闭备库
su - oracle
srvctl stop database -d orcl -o abort
清理环境,删除旧的数据文件
[grid@rac2 ~]$ asmcmd
ASMCMD> lsdg
State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED EXTERN N 512 4096 4194304 12288 6668 0 6668 0 N DATA/
MOUNTED NORMAL N 512 4096 1048576 9216 8290 3072 2609 0 Y VOTE/
ASMCMD> cd data/orcl
ASMCMD> rm -rf CONTROLFILE
ASMCMD> rm -rf DATAFILE
ASMCMD> rm -rf ONLINELOG
ASMCMD> mkdir CONTROLFILE
ASMCMD> mkdir DATAFILE
ASMCMD> mkdir ONLINELOG
启动数据库单实例
sqlplus / as sysdba
startup nomount;
rman target sys/oracle@primary auxiliary sys/oracle@racdg
DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE NOFILENAMECHECK;
以下为输出
[oracle@rac1 admin]$ rman target sys/oracle@primary auxiliary sys/oracle@racdg
Recovery Manager: Release 11.2.0.4.0 - Production on Tue Dec 19 20:44:54 2023
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1613952925)
connected to auxiliary database: ORCL (not mounted)
RMAN> DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE NOFILENAMECHECK;
Starting Duplicate Db at 19-DEC-23
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=194 instance=orcl1 device type=DISK
contents of Memory Script:
{
backup as copy reuse
targetfile '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapworcl2' auxiliary format
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapworcl1' ;
}
executing Memory Script
Starting backup at 19-DEC-23
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=205 instance=orcl2 device type=DISK
Finished backup at 19-DEC-23
contents of Memory Script:
{
sql clone "alter system set control_files =
''+DATA/orcl/controlfile/current.352.1156020305'', ''+DATA/orcl/controlfile/current.351.1156020305'' comment=
''Set by RMAN'' scope=spfile";
backup as copy current controlfile for standby auxiliary format '+DATA/orcl/controlfile/current.350.1156020305';
restore clone controlfile to '+DATA/orcl/controlfile/current.349.1156020305' from
'+DATA/orcl/controlfile/current.350.1156020305';
sql clone "alter system set control_files =
''+DATA/orcl/controlfile/current.350.1156020305'', ''+DATA/orcl/controlfile/current.349.1156020305'' comment=
''Set by RMAN'' scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
sql statement: alter system set control_files = ''+DATA/orcl/controlfile/current.352.1156020305'', ''+DATA/orcl/controlfile/current.351.1156020305'' comment= ''Set by RMAN'' scope=spfile
Starting backup at 19-DEC-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying standby control file
output file name=+DATA/orcl/controlfile/snap_control.f tag=TAG20231219T204506 RECID=30 STAMP=1156020311
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 19-DEC-23
Starting restore at 19-DEC-23
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 19-DEC-23
sql statement: alter system set control_files = ''+DATA/orcl/controlfile/current.350.1156020305'', ''+DATA/orcl/controlfile/current.349.1156020305'' comment= ''Set by RMAN'' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 801701888 bytes
Fixed Size 2257520 bytes
Variable Size 339742096 bytes
Database Buffers 452984832 bytes
Redo Buffers 6717440 bytes
contents of Memory Script:
{
sql clone 'alter database mount standby database';
}
executing Memory Script
sql statement: alter database mount standby database
RMAN-05529: WARNING: DB_FILE_NAME_CONVERT resulted in invalid ASM names; names changed to disk group only.
contents of Memory Script:
{
set newname for tempfile 1 to
"+data";
switch clone tempfile all;
set newname for datafile 1 to
"+data";
set newname for datafile 2 to
"+data";
set newname for datafile 3 to
"+data";
set newname for datafile 4 to
"+data";
set newname for datafile 5 to
"+data";
set newname for datafile 6 to
"+data";
set newname for datafile 7 to
"+data";
set newname for datafile 8 to
"+data";
set newname for datafile 9 to
"+data";
set newname for datafile 10 to
"+data";
set newname for datafile 11 to
"+data";
set newname for datafile 12 to
"+data";
set newname for datafile 13 to
"+data";
backup as copy reuse
datafile 1 auxiliary format
"+data" datafile
2 auxiliary format
"+data" datafile
3 auxiliary format
"+data" datafile
4 auxiliary format
"+data" datafile
5 auxiliary format
"+data" datafile
6 auxiliary format
"+data" datafile
7 auxiliary format
"+data" datafile
8 auxiliary format
"+data" datafile
9 auxiliary format
"+data" datafile
10 auxiliary format
"+data" datafile
11 auxiliary format
"+data" datafile
12 auxiliary format
"+data" datafile
13 auxiliary format
"+data" ;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to +data in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting backup at 19-DEC-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=+DATA/orcl/datafile/system.256.1086172033
output file name=+DATA/orcl/datafile/system.348.1156020355 tag=TAG20231219T204554
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=+DATA/orcl/datafile/sysaux.257.1086172033
output file name=+DATA/orcl/datafile/sysaux.347.1156020401 tag=TAG20231219T204554
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=+DATA/orcl/datafile/undotbs2.267.1086172237
output file name=+DATA/orcl/datafile/undotbs2.346.1156020437 tag=TAG20231219T204554
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=+DATA/orcl/datafile/prod.273.1086172629
output file name=+DATA/orcl/datafile/prod.345.1156020443 tag=TAG20231219T204554
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00007 name=+DATA/primary/datafile/users.297.1147790221
output file name=+DATA/orcl/datafile/users.344.1156020451 tag=TAG20231219T204554
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=+DATA/orcl/datafile/undotbs1.258.1086172033
output file name=+DATA/orcl/datafile/undotbs1.343.1156020455 tag=TAG20231219T204554
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00008 name=+DATA/primary/datafile/users.331.1147792495
output file name=+DATA/orcl/datafile/users.342.1156020457 tag=TAG20231219T204554
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00009 name=+DATA/primary/datafile/users.335.1147792667
output file name=+DATA/orcl/datafile/users.341.1156020459 tag=TAG20231219T204554
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00010 name=+DATA/primary/datafile/users.338.1147793229
output file name=+DATA/orcl/datafile/users.340.1156020461 tag=TAG20231219T204554
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00011 name=+DATA/primary/datafile/users.339.1147793259
output file name=+DATA/orcl/datafile/users.378.1156020461 tag=TAG20231219T204554
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+DATA/orcl/datafile/users.259.1086172033
output file name=+DATA/orcl/datafile/users.377.1156020463 tag=TAG20231219T204554
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00012 name=+DATA/primary/datafile/users.353.1147806089
output file name=+DATA/orcl/datafile/users.376.1156020463 tag=TAG20231219T204554
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00013 name=+DATA/primary/datafile/users.378.1147818285
output file name=+DATA/orcl/datafile/users.375.1156020465 tag=TAG20231219T204554
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:02
Finished backup at 19-DEC-23
sql statement: alter system archive log current
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=30 STAMP=1156020467 file name=+DATA/orcl/datafile/system.348.1156020355
datafile 2 switched to datafile copy
input datafile copy RECID=31 STAMP=1156020467 file name=+DATA/orcl/datafile/sysaux.347.1156020401
datafile 3 switched to datafile copy
input datafile copy RECID=32 STAMP=1156020468 file name=+DATA/orcl/datafile/undotbs1.343.1156020455
datafile 4 switched to datafile copy
input datafile copy RECID=33 STAMP=1156020468 file name=+DATA/orcl/datafile/users.377.1156020463
datafile 5 switched to datafile copy
input datafile copy RECID=34 STAMP=1156020468 file name=+DATA/orcl/datafile/undotbs2.346.1156020437
datafile 6 switched to datafile copy
input datafile copy RECID=35 STAMP=1156020468 file name=+DATA/orcl/datafile/prod.345.1156020443
datafile 7 switched to datafile copy
input datafile copy RECID=36 STAMP=1156020468 file name=+DATA/orcl/datafile/users.344.1156020451
datafile 8 switched to datafile copy
input datafile copy RECID=37 STAMP=1156020468 file name=+DATA/orcl/datafile/users.342.1156020457
datafile 9 switched to datafile copy
input datafile copy RECID=38 STAMP=1156020469 file name=+DATA/orcl/datafile/users.341.1156020459
datafile 10 switched to datafile copy
input datafile copy RECID=39 STAMP=1156020469 file name=+DATA/orcl/datafile/users.340.1156020461
datafile 11 switched to datafile copy
input datafile copy RECID=40 STAMP=1156020469 file name=+DATA/orcl/datafile/users.378.1156020461
datafile 12 switched to datafile copy
input datafile copy RECID=41 STAMP=1156020469 file name=+DATA/orcl/datafile/users.376.1156020463
datafile 13 switched to datafile copy
input datafile copy RECID=42 STAMP=1156020469 file name=+DATA/orcl/datafile/users.375.1156020465
Finished Duplicate Db at 19-DEC-23
增加RAC备库的参数,原有为primary,orcldg分别为RAC主库、DG单机
其中service对应tnsname里的名称,后面du_nique_name就是字面的意思了
alter system set log_archive_config='DG_CONFIG=(primary,orcl,orcldg)' scope=both;
alter system set log_archive_dest_3='service=racdg ASYNC NOAFFIRM valid_for=(online_logfiles,primary_role) db_unique_name=orcl' scope=both;
登录备库RAC节点,执行同步命令:
alter database recover managed standby database disconnect from session;
这个是停止的命令,需要的时候再用
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
这个是OPEN后,使用ADG同步的命令
alter database recover managed standby database using current logfile disconnect from session;
启动同步,检查备库日志,可以接收到主库发来的归档日志
至此第1篇完结,接下来我准备一下,再更新第2篇。
总体来说RAC到RAC的DG和RAC到单机的DG区别不是很大
需要注意的就是:
1、RAC也要配置静态监听,不然duplicate时候会连不上。
2、如果RAC备库的db_unique_name与库名不一样的话有几种方法(19c简单的多,可以dbca -silent -createDuplicateDB 时直接指定,一键搞定备库,可以参考许冲玉大佬的文章oracle 19c rac dataguard 配置 - 墨天轮 (modb.pro))
a)可以在静默创建命令后加参数(不太推荐,因为有个BUG:DBCA Silent Mode Is Not Setting DB_UNIQUE_NAME Even Though It Is Specified In DBCA Template File. (Doc ID 1508337.1),据说是模板文件的问题,导致命令行加参数修改不生效,如非要用这个方法,可以按我下面操作执行,我试了好几回终于成功了!):
示例,先去asm磁盘组里创建orcltest的目录(如果不创建就会报错,创建SPFILE失败)
ASMCMD> cd data
ASMCMD> mkdir orcltest
然后DBCA建库
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname orcltest -sid orcltest -sysPassword oracle -systemPassword oracle -datafileDestination '+DATA' -redoLogFileSize 50 -recoveryAreaDestination '+DATA' -storageType ASM -asmsnmpPassword system -diskGroupName 'DATA' -responseFile NO_VALUE -characterset ZHS16GBK -nationalCharacterSet AL16UTF16 -sampleSchema true -automaticMemoryManagement true -totalMemory 1024 -nodeinfo rac1,rac2 -initParams db_unique_name=test -initParams db_unique_name=test
创建过程可查看如下日志
/u01/app/oracle/cfgtoollogs/dbca/test/trace
b)(推荐做法)图形建库时指定参数
c)就是正常建库,之后去库里改,但是这么改完,每次启动时alert里都会有个告警
ERROR: failed to establish dependency between database dgorcl and diskgroup resource ora.DATA.dg
虽说这样也不影使用,就是看着别扭
d) (推荐做法)你可以不用像我一样dbca创建个库出来,手动写参数创建实例,创建db_unique_name数据目录,然后直接duplicate库,然后手动去注册下服务。
3、RAC备库要启动1个实例来进行操作。
也欢迎关注我的公众号【徐sir的IT之路】,一起学习!
————————————————————————————
公众号:徐sir的IT之路
CSDN :徐sir(徐慧阳)_数据库记录,系统集成-CSDN博客
墨天轮:徐sir的个人主页 - 墨天轮
PGFANS:PGFans问答社区:全球唯一的PostgreSQL中文技术交流社区————————————————————————————