节点 | 主机版本 | 主机名 | 实例名 | Oracle版本 | IP地址 |
---|---|---|---|---|---|
rac01 | rhel7.9 | rac01 | cdb19c | 19.3.0(补丁 29585399) | 10.211.55.100 |
rac02 | rhel7.9 | rac02 | orcl+cdb19c | 19.3.0(补丁 29585399) | 10.211.55.101 |
备库 | rhel7.9 | dbca_stby | 不创建实例 | 19.3.0(补丁 29585399) | 10.211.55.110 |
注意:
1、db_unique_name主备库不能相同。
2、db_name主备库需保持一致。
3、主备库DB版本需保持一致。
Oracle测试环境安装:
可参考:DBA运维福音:10分钟,Linux一行命令安装Oracle数据库
主库RAC环境一键安装:
./OracleShellInstall.sh -i 10.211.55.100 `#Public ip`\ -n rac `# hostname`\ -c TRUE `# cdb`\ -pb orcl `# pdb`\ -o cdb19c `# oraclesid`\ -rs oracle `# root password`\ -op oracle `# oracle password`\ -gp oracle `# grid password`\ -b /u01/app `# install basedir`\ -s AL32UTF8 `# characterset`\ -pb1 10.211.55.100 -pb2 10.211.55.101 `# node public ip`\ -vi1 10.211.55.102 -vi2 10.211.55.103 `# node virtual ip`\ -pi1 1.1.1.1 -pi2 1.1.1.2 `# node private ip`\ -si 10.211.55.105 `# scan ip`\ -dd /dev/sdc `# asm data disk`\ -od /dev/sdb `# asm ocr disk`\ -or EXTERNAL `# asm ocr redundancy`\ -dr EXTERNAL `# asm data redundancy`\ -on OCR `# asm ocr diskgroupname`\ -dn DATA `# asm data diskgroupname`\ -puf eth0 -prf eth1 `# network fcname`\ -tsi 10.211.55.200 `# timeserver`\ -gpa 32545008 `# Grid PSU NUMBER`
备库一键安装:(备库仅安装ORACLE软件,不建库)
./OracleShellInstall.sh -i 10.211.55.110 -n dbca_stby -o cdb19c -opa 32545013 -w Y
a.配置hosts文件
主库:
cat EOF >> /etc/hosts ##FOR DG BEGIN 10.211.55.110 dbca_stby ##FOR DG END EOF
备库:
cat EOF >> /etc/hosts ##FOR DG BEGIN 10.211.55.100 rac01 10.211.55.101 rac02 10.211.55.105 rac-scan ##FOR DG END EOF
b.配置静态监听和TNS
listener.ora增加静态监听:
grid用户执行:
rac01
cat EOF >> $TNS_ADMIN/listener.ora ##FOR DG BEGIN SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = cdb19c) (ORACLE_HOME = /u01/app/oracle/product/19.3.0/db) (SID_NAME = cdb19c1) ) ) ##FOR DG END EOF
rac02
cat EOF >> $TNS_ADMIN/listener.ora ##FOR DG BEGIN SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = cdb19c) (ORACLE_HOME = /u01/app/oracle/product/19.3.0/db) (SID_NAME = cdb19c2) ) ) ##FOR DG END EOF
备库
cat EOF >>$TNS_ADMIN/listener.ora ##FOR DG BEGIN SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = cdb19c_stby) (ORACLE_HOME = /u01/app/oracle/product/19.3.0/db) (SID_NAME = cdb19c_stby) ) ) ##FOR DG END EOF
重启监听
#主库RAC重启监听 srvctl stop listener srvctl start listener ##备库重启监听 lsnrctl start
tnsnames.ora增加TNS:
oracle用户执行:
cat EOF >> $TNS_ADMIN/tnsnames.ora ##FOR DG BEGIN CDB19C = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rac-scan)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = cdb19c) ) ) CDB19C1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rac01)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = cdb19c) ) ) CDB19C2 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rac02)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = cdb19c) ) ) CDB19C_STBY = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = dbca_stby)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = cdb19c_stby) ) ) ##FOR DG BEGIN EOF
tnsping测试连通性:
tnsping cdb19c tnsping cdb19c1 tnsping cdb19c2 tnsping cdb19c_stby
c.主库配置参数
SQL> select force_logging,log_mode,cdb from gv$database; FORCE_LOGGING LOG_MODE CDB --------------------------------------- YES ARCHIVELOG YES
如果没有开启强制日志:
alter database force logging;
如果没有开启归档日志:
shutdown immediate startup mount alter database archivelog; alter database open; alter pluggable database all open;
d.主库添加stanby log文件
set line222 col member for a60 select t2.thread#,t1.group#,t1.member,t2.bytes/1024/1024 from v$logfile t1,v$log t2 where t1.group#=t2.group# order by 1,2;
--需要注意: --1.stanby log日志大小至少要和redo log日志一样大小,不能小于 --2.stanby log数量: standby logfile=(1+logfile组数)=(1+2)=3组,每个thread需要加3组standby logfile. --3.thread要与redo log保持一致,如果是rac,需要增加多个thread对应的standby log ALTER DATABASE ADD STANDBY LOGFILE thread 1 group 5 ('+DATA') SIZE 120M, group 6 ('+DATA') SIZE 120M, group 7 ('+DATA') SIZE 120M; ALTER DATABASE ADD STANDBY LOGFILE thread 2 group 8 ('+DATA') SIZE 120M, group 9 ('+DATA') SIZE 120M, group 10 ('+DATA') SIZE 120M;
select t2.thread#,t1.group#,t1.member,t2.bytes/1024/1024 from v$logfile t1,v$standby_log t2 where t1.group#=t2.group# order by 1,2;
oracle用户执行:
dbca -silent -createDuplicateDB \ -gdbName cdb19c \ -sid cdb19c \ -sysPassword oracle \ -primaryDBConnectionString 10.211.55.105:1521/cdb19c \ -nodelist dbca_stby \ -databaseConfigType SINGLE \ -createAsStandby -dbUniqueName cdb19c_stby \ -datafileDestination '/oradata'
DBCA物理DG创建成功。
--主库设置DG参数 ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(CDB19C,CDB19C_STBY)' sid='*'; ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=+DATA VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=CDB19C' sid='*'; ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=cdb19c_stby ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=CDB19C_STBY' sid='*'; ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE sid='*'; ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=4 sid='*'; ALTER SYSTEM SET FAL_SERVER=CDB19C_STBY sid='*'; ALTER SYSTEM SET FAL_CLIENT=CDB19C sid='*'; ALTER SYSTEM SET DB_FILE_NAME_CONVERT='+DATA','/oradata/CDB19C_STBY' SCOPE=SPFILE sid='*'; ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='+DATA','/oradata/CDB19C_STBY' SCOPE=SPFILE sid='*'; ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO sid='*';
注意:RAC修改参数需要加上 sid='*'
,修改多个实例。
--备库设置DG参数 ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(CDB19C_STBY,CDB19C)'; ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=/archivelog VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=CDB19C_STBY'; ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=CDB19C ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=CDB19C'; ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE; ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=4; ALTER SYSTEM SET FAL_SERVER=CDB19C; ALTER SYSTEM SET FAL_CLIENT=CDB19C_STBY; ALTER SYSTEM SET DB_FILE_NAME_CONVERT='/oradata/CDB19C_STBY','+DATA' SCOPE=SPFILE; ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='/oradata/CDB19C_STBY','+DATA' SCOPE=SPFILE; ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;
查看OMF参数配置:
show parameter db_create_file_dest
注意:如果同时设置OMG和DB_FILE_NAME_CONVERT参数,则优先OMF参数。
##备库执行 alter database recover managed standby database using current logfile disconnect from session; ##主库执行 alter system set log_archive_dest_state_2=enable sid='*';
主库创建测试数据:
alter session set container=orcl;
sqlplus lucifer/lucifer@orcl
备库查看是否同步:
至此,ADG已搭建完毕。感谢食用~
参考文章:
官方文档12c:Using DBCA to Create a Data Guard Standby 12C
官方文档19c:Using DBCA to Create a Data Guard Standby 19C
官方文档21c:Using DBCA to Create a Data Guard Standby 21C
MOS文档:Creating a Physical Standby database using DBCA duplicate (Doc ID 2283697.1)
以上就是DBCA搭建Oracle ADG的详细内容,更多关于DBCA搭建Oracle ADG的资料请关注脚本之家其它相关文章!