在前面章节中已经部署了一主一实时备机,此次实施过程中主要添加异步备库。
1. 环境描述
实例详情:
端口详情
2. 关闭主备库守护进程、监视器、数据库实例
[dmdba@ray1 ]$ DmWatcherServiceDW stop
Stopping DmWatcherServiceDW: [ OK ]
[dmdba@ray1 ~]$ DmServiceGRP1_RT_01 stop
DmServiceGRP1_RT_01 service is stopped.
[dmdba@ray1 ~]$ DmMonitorServicemonitor stop
DmMonitorServicemonitor service is stopped.
[dmdba@ray2 ~]$ DmWatcherServiceDW stop
Stopping DmWatcherServiceDW: [ OK ]
[dmdba@ray2 ~]$ DmServiceGRP1_RT_02 stop
DmServiceGRP1_RT_02 service is stopped.
3. 主库进程文件参数修改
3.1. 主库修改dm.ini
[dmdba@ray1 GRP1_RT_01]$ vi /dmdba/data/GRP1_RT_01/dm.ini
修改
TIMER_INI = 1
3.2. 主库修改dmarch.ini
[dmdba@ray1 ~]$ vi /dmdba/data/GRP1_RT_01/dmarch.ini
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = GRP1_RT_02
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dmdba/arch/GRP1_RT_01
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0
[ARCHIVE_ASYNC]
ARCH_TYPE = ASYNC
ARCH_DEST = GRP1_RT_03
ARCH_TIMER_NAME = RT_TIMER
3.3. 主库修改dmmal.ini
[dmdba@ray1 ~]$ vi /dmdba/data/GRP1_RT_01/dmmal.ini
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = GRP1_RT_01
MAL_HOST = 10.10.10.1
MAL_PORT = 61141
MAL_INST_HOST = 192.168.0.1
MAL_INST_PORT = 32141
MAL_DW_PORT = 52141
MAL_INST_DW_PORT = 33141
[MAL_INST2]
MAL_INST_NAME = GRP1_RT_02
MAL_HOST = 10.10.10.2
MAL_PORT = 61142
MAL_INST_HOST = 192.168.0.2
MAL_INST_PORT = 32142
MAL_DW_PORT = 52142
MAL_INST_DW_PORT = 33142
[MAL_INST3]
MAL_INST_NAME = GRP1_RT_03
MAL_HOST = 10.10.10.3
MAL_PORT = 61143
MAL_INST_HOST = 192.168.0.3
MAL_INST_PORT = 32143
MAL_DW_PORT = 52143
MAL_INST_DW_PORT = 33143
3.4. 主库创建dmtimer.ini
[dmdba@ray1 ~]$ vi /dmdba/data/GRP1_RT_01/dmtimer.ini
[RT_TIMER]
TYPE=2
FREQ_MONTH_WEEK_INTERVAL = 1
FREQ_SUB_INTERVAL = 0
FREQ_MINUTE_INTERVAL = 0
START_TIME = 00:00:00
END_TIME = 00:00:00
DURING_START_DATE = 2024-08-19 00:00:00
DURING_END_DATE = 2099-12-31 00:00:00
NO_END_DATE_FLAG = 1
DESCRIBE = RT TIMER
IS_VALID = 1
3.5. 主库修改dmwatcher.ini
无需修改。
3. 同步参数文件
拷贝主库dmmal.ini、dmwatcher.ini、dmtimer.ini、dmarch.ini至实时备机和至异步备机。
[dmdba@ray1 ~]$ scp /dmdba/data/GRP1_RT_01/dmmal.ini ray2:/dmdba/data/GRP1_RT_02/
[dmdba@ray1 ~]$ scp /dmdba/data/GRP1_RT_01/dmwatcher.ini ray2:/dmdba/data/GRP1_RT_02/
[dmdba@ray1 ~]$ scp /dmdba/data/GRP1_RT_01/dmtimer.ini ray2:/dmdba/data/GRP1_RT_02/
[dmdba@ray1 ~]$ scp /dmdba/data/GRP1_RT_01/dmmal.ini ray3:/dmdba/data/GRP1_RT_03/
[dmdba@ray1 ~]$ scp /dmdba/data/GRP1_RT_01/dmwatcher.ini ray3:/dmdba/data/GRP1_RT_03/
5. 实时备库进程文件参数修改
5.1. 实时备库修改dm.ini
[dmdba@ray2 GRP1_RT_02]$ vi /dmdba/data/GRP1_RT_02/dm.ini
修改
TIMER_INI = 1
5.2. 实时备库修改dmmal.ini
已从主库同步过来,无需修改。
5.3. 实时备库修改dmarch.ini
[root@ray2 ~]# cd /dmdba/data/GRP1_RT_02/
[root@ray2 GRP1_RT_02]# vi dmarch.ini
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = GRP1_RT_02
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dmdba/arch/GRP1_RT_02
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0
[ARCHIVE_ASYNC]
ARCH_TYPE = ASYNC
ARCH_DEST = GRP1_RT_03
ARCH_TIMER_NAME = RT_TIMER
5.4. 实时备库修改dmwatcher.ini
[dmdba@ray2 GRP1_RT_02]$ vi dmwatcher.ini
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = AUTO
DW_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 453331
INST_INI = /dmdba/data/GRP1_RT_02/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dmdba/dmdbms/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
5.5. 实时备库修改dmtimer.ini
已从主库同步过来,无需修改。
6. 异步备库环境准备
6.1. 异步备库初始化
[dmdba@ray3 root]$ cd /dmdba/dmdbms/bin
[dmdba@ray3 bin]$ ./dminit path=/dmdba/data PAGE_SIZE=32 EXTENT_SIZE=32 CASE_SENSITIVE=y CHARSET=1 DB_NAME=GRP1_RT_03 INSTANCE_NAME=GRP1_RT_03 PORT_NUM=32143
initdb V8
db version: 0x7000c
file dm.key not found, use default license!
License will expire on 2025-07-03
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
log file path: /dmdba/data/GRP1_RT_03/GRP1_RT_0301.log
log file path: /dmdba/data/GRP1_RT_03/GRP1_RT_0302.log
write to dir [/dmdba/data/GRP1_RT_03].
create dm database success. 2024-08-19 13:26:14
6.2. 异步备库实例注册服务
[root@ray3 ]# cd /dmdba/dmdbms/script/root/
[root@ray3 root]# ./dm_service_installer.sh -t dmserver -dm_ini /dmdba/data/GRP1_RT_03/dm.ini -p GRP1_RT_03
Created symlink from /etc/systemd/system/multi-user.target.wants/DmServiceGRP1_RT_03.service to /usr/lib/systemd/system/DmServiceGRP1_RT_03.service.
创建服务(DmServiceGRP1_RT_03)完成
6.3. 异步备库还原恢复
[dmdba@ray3 ]$ dmrman
dmrman V8
RMAN> RESTORE DATABASE '/dmdba/data/GRP1_RT_03/dm.ini' FROM BACKUPSET '/dmdba/dmbak/GRP0816'
RESTORE DATABASE '/dmdba/data/GRP1_RT_03/dm.ini' FROM BACKUPSET '/dmdba/dmbak/GRP0816'
file dm.key not found, use default license!
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:02][Remaining:00:00:00]
restore successfully.
time used: 00:00:02.453
RMAN> RECOVER DATABASE '/dmdba/data/GRP1_RT_03/dm.ini' FROM BACKUPSET '/dmdba/dmbak/GRP0816'
RECOVER DATABASE '/dmdba/data/GRP1_RT_03/dm.ini' FROM BACKUPSET '/dmdba/dmbak/GRP0816'
recover successfully!
time used: 419.778(ms)
RMAN> RECOVER DATABASE '/dmdba/data/GRP1_RT_03/dm.ini' UPDATE DB_MAGIC
RECOVER DATABASE '/dmdba/data/GRP1_RT_03/dm.ini' UPDATE DB_MAGIC
recover successfully!
time used: 00:00:01.057
7. 异步备库修改进程文件参数
7.1. 异步备库修改dm.ini
[dmdba@ray3 ~]$ vi /dmdba/data/GRP1_RT_02/dm.ini
INSTANCE_NAME = GRP1_RT_03
PORT_NUM = 32143
DW_INACTIVE_INTERVAL =60
ALTER_MODE_STATUS = 0
ENABLE_OFFLINE_TS = 2
MAL_INI = 1
ARCH_INI = 1
RLOG_SEND_APPLY_MON = 64
TIMER_INI = 1
7.2. 异步备库修改dmmal.ini
已从主库同步过来,无需修改。
7.3. 异步备库修改dmwatcher.ini
[dmdba@ray3 GRP1_RT_03]$ cat dmwatcher.ini
[GRP1]
DW_TYPE = LOCAL
DW_MODE = MANUAL
DW_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 453331
INST_INI = /dmdba/data/GRP1_RT_03/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dmdba/dmdbms/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
7.4. 异步备库创建dmarch.ini
[dmdba@ray3 GRP1_RT_03]$ vi dmarch.ini
添加:
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dmdba/arch/GRP1_RT_03
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0
[ARCHIVE_ASYNC]
ARCH_TYPE = ASYNC
ARCH_DEST = GRP1_RT_03
ARCH_TIMER_NAME = RT_TIMER
8. 修改监视器文件
[dmdba@ray1 ~]$ vi /dmdba/monitor/dmmonitor.ini
MON_DW_CONFIRM = 1
MON_LOG_PATH = /dmdba/data/log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 32
MON_LOG_SPACE_LIMIT = 0
[GRP1]
MON_INST_OGUID = 453331
MON_DW_IP = 10.10.10.1:52141
MON_DW_IP = 10.10.10.2:52142
MON_DW_IP = 10.10.10.3:52143
9. MOUNT异步备库
[dmdba@ray3 ~]$ /dmdba/dmdbms/bin/dmserver /dmdba/data/GRP1_RT_03/dm.ini mount
10. 异步备库设置OGUID
系统通过OGUID值确定一个守护进程组,由用户保证OGUID值的唯一性,并确保数据守护系统中,数据库、守护进程和监视器配置相同的OGUID值。
[dmdba@ray3 ~]$ disql SYSDBA/SYSDBA@192.168.0.3:32143
服务器[192.168.0.3:32143]:处于普通配置状态
登录使用时间 : 3.223(ms)
disql V8
SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
DMSQL 过程已成功完成
已用时间: 8.193(毫秒). 执行号:1.
SQL> sp_set_oguid(453331);
DMSQL 过程已成功完成
已用时间: 1.583(毫秒). 执行号:2.
SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
DMSQL 过程已成功完成
已用时间: 6.989(毫秒). 执行号:3.
11. 异步备库修改数据库模式
修改数据库模式为STANDBY。
[dmdba@ray3 ~]$ disql SYSDBA/SYSDBA@192.168.0.3:32143
服务器[192.168.0.3:32143]:处于普通配置状态
登录使用时间 : 2.461(ms)
disql V8
SQL> alter database standby;
操作已执行
已用时间: 5.541(毫秒). 执行号:0.
12. 启动守护进程
[dmdba@ray1 ~]$ DmWatcherServiceDW start
Starting DmWatcherServiceDW: [ OK ]
[dmdba@ray2 ~]$ DmWatcherServiceDW start
Starting DmWatcherServiceDW: [ OK ]
[dmdba@ray3 ~]$ DmWatcherServiceDW start
Starting DmWatcherServiceDW: [ OK ]
13. 启动监视器
[dmdba@ray1 GRP1_RT_01]$ DmMonitorServicemonitor start
Starting DmMonitorServicemonitor: [ OK ]