最近有个项目要干,对现有生产的rac进行一个改造
客户原有两个ibm p710小型机要替换成国产浪潮k1 power s914小型机。(额,国产化替代也算,不要问我为啥国产的机器和原来的小型机可以做adg。。。)
开干前,我再用模拟环境还原一下整个项目的操作流程。由于整个过程比较长,我预计分3篇文章来分别对各个环境进行实验(我这实验环境没有小型机拉,用linux代替,原理1毛1样)
关于如何搭建rac-单机的adg可以参考我的另一篇文章:搭建记录:rac到单实例搭建dataguard
那么先开始第1篇:rac-rac主备搭建
1.1、现有环境
现有模拟环境如下图所示
2台数据库rac主机(两台主机心跳线直连),灾备机房有1个单机dg容灾,现有示意图如下:
1.2、项目目标计划
计划新增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)
改造之后如下图所示:
1.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 |
1.4、现有环境hosts文件
目前主库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
1.5、目前主库的数据文件路径
为了和真实环境下,我也按生产搞了一下(生产库之前不知道谁搭建的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.
2.1、rac备库上创建数据库
在搭建好的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] {<command> <options> } | { [<command> [options] ] -responsefile <response file > } [-continueonnonfatalerrors <true | false>]
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 <name of an existing template in default location or the complete template path>
[-clonetemplate]
-gdbname <global database name>
[-raconenode
-raconenodeservicename <service name for the service to be created for rac one node database.>]
[-policymanaged | -adminmanaged <policy managed or admin managed database, default is admin managed database>]
[-createserverpool <to create serverpool which will be used by the database to be created>]
[-force <to create serverpool by force when adequate free servers are not available. this may affect already running database>]
-serverpoolname <one serverpool name in case of create server pool and comma separated list of serverpool name in case of use serverpool>
-[cardinality <specify cardinality for new serverpool to be created, default is the number of qualified nodes>]
[-sid <database system identifier prefix>]
[-syspassword <sys user password>]
[-systempassword <system user password>]
[-emconfiguration <central|local|all|none>
-dbsnmppassword <dbsnmp user password>
-sysmanpassword <sysman user password>
[-hostusername <host user name for em backup job>
-hostuserpassword <host user password for em backup job>
-backupschedule <daily backup schedule in the form of hh:mm>]
[-centralagent <enterprise manager central agent home>]]
[-disablesecurityconfiguration <all|audit|password_profile|none>
[-datafiledestination <destination directory for all database files> | -datafilenames <a text file containing database objects such as controlfiles, tablespaces, redo log files and spfile to their corresponding raw device file names mappings in name=value format.>]
[-redologfilesize <size of each redo log file in megabytes>]
[-recoveryareadestination <destination directory for all recovery files>]
[-datafilejarlocation <location of the data file jar, used only for clone database creation>]
[-storagetype < cfs | asm >
[-asmsnmppassword <asmsnmp password for asm monitoring>]
-diskgroupname <database area disk group name>
-recoverygroupname <recovery area disk group name>
[-nodelist <node names separated by comma for the database>]
[-characterset <character set for the database>]
[-nationalcharacterset <national character set for the database>]
[-registerwithdirservice <true | false>
-dirserviceusername <user name for directory service>
-dirservicepassword <password for directory service >
-walletpassword <password for database wallet >]
[-listeners <list of listeners to configure the database with>]
[-variablesfile <file name for the variable-value pair for variables in the template>]]
[-variables <comma separated list of name=value pairs>]
[-initparams <comma separated list of name=value pairs>]
[-sampleschema <true | false> ]
[-memorypercentage <percentage of physical memory for oracle>]
[-automaticmemorymanagement ]
[-totalmemory <memory allocated for oracle in mb>]
[-databasetype <multipurpose|data_warehousing|oltp>]]
configure a database by specifying the following parameters:
-configuredatabase
-sourcedb <database unique name for rac database and sid for single instance database>
[-sysdbausername <user name with sysdba privileges>
-sysdbapassword <password for sysdbausername user name>]
[-registerwithdirservice|-unregisterwithdirservice|-regeneratedbpassword <true | false>
-dirserviceusername <user name for directory service>
-dirservicepassword <password for directory service >
-walletpassword <password for database wallet >]
[-disablesecurityconfiguration <all|audit|password_profile|none>
[-enablesecurityconfiguration <true|false>
[-emconfiguration <central|local|all|none>
-dbsnmppassword <dbsnmp user password>
-sysmanpassword <sysman user password>
[-hostusername <host user name for em backup job>
-hostuserpassword <host user password for em backup job>
-backupschedule <daily backup schedule in the form of hh:mm>]
[-centralagent <enterprise manager central agent home>]]
create a template from an existing database by specifying the following parameters:
-createtemplatefromdb
-sourcedb <service in the form of <host>:<port>:<sid>>
-templatename <new template name>
-sysdbausername <user name with sysdba privileges>
-sysdbapassword <password for sysdbausername user name>
[-maintainfilelocations <true | false>]
create a clone template from an existing database by specifying the following parameters:
-createclonetemplate
-sourcesid <source database sid>
-templatename <new template name>
[-sysdbausername <user name with sysdba privileges>
-sysdbapassword <password for sysdbausername user name>]
[-maintainfilelocations <true | false>]
[-datafilejarlocation <directory to place the datafiles in a compressed format>]
generate scripts to create database by specifying the following parameters:
-generatescripts
-templatename <name of an existing template in default location or the complete template path>
-gdbname <global database name>
[-scriptdest <destination for all the scriptfiles>]
delete a database by specifying the following parameters:
-deletedatabase
-sourcedb <database unique name for rac database and sid for single instance database>
[-sid <local instance_name of source database>]
[-sysdbausername <user name with sysdba privileges>
-sysdbapassword <password for sysdbausername user name>]
add an instance to a cluster database by specifying the following parameters:
-addinstance
-gdbname <global database name>
-nodelist <node name for the new instance to add>
[-instancename <instance name for the new instance to add>]
[-sysdbausername <user name with sysdba privileges>]
-sysdbapassword <password for sysdbausername user name>
[-updatedirservice <true | false>
-dirserviceusername <user name for directory service>
-dirservicepassword <password for directory service >]
delete an instance from a cluster database by specifying the following parameters:
-deleteinstance
-gdbname <global database name>
-instancename <instance name for the instance to be removed>
[-nodelist <node name for the instance to be removed>]
[-sysdbausername <user name with sysdba privileges>]
-sysdbapassword <password for sysdbausername user name>
[-updatedirservice <true | false>
-dirserviceusername <user name for directory service>
-dirservicepassword <password for directory service >]
query for help by specifying the following options: -h | -help
2.2、rac备库增加静态监听
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
米乐app官网下载 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
米乐app官网下载 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]$
2.3、rac备库增加参数
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;
2.4、rac备库修改tnsnames.ora
这里需要在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)
)
)
2.5、拷贝口令文件到rac备库
在rac主库,拷贝主库口令文件到rac备库2个节点,并进行md5校验
[oracle@rac1 ~]$ cd /u01/app/oracle/product/11.2.0/dbhome_1/dbs/
[oracle@rac1 dbs]$ scp -r orapworcl1 oracle@192.168.56.30:/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 oracle@192.168.56.31:/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
2.6、关闭rac备数据库,清理环境
在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;
2.7、在备库rac1节点执行duplicate 复制
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
米乐app官网下载 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
2.8、rac主库修改参数
增加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;
2.9、rac备库启动同步进程
登录备库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 :
墨天轮:https://www.modb.pro/u/3605
pgfans:
————————————————————————————