dm8搭建数据守护集群详解

数据守护

解决方案:配置实时主备,mpp主备,读写分离

实现原理:主库产生redo,传到备库,备库接收并重新应用redo日志实现备库与主库的同步。

组成:主库,备库,redo日志,redo日志传输,重演,守护进程,监视器,mal系统。

Mal系统:基于tcp协议实现的一种内部通信机制,DM通过MAL实现redo日志传输。实现实例之间的消息通讯。

归档的介绍:

本地归档:redo写入本地归档日志文件,不能被覆盖。

实时归档:主库产生的redo日志,通过mal传到备库,只有在主库配置为primary模库,才能生效。

即时归档:主库将redo日志写入redo日志文件后,通过mal系统发送到备库。(读写分离集群用到)

异步归档:由主库和备库上配置定时器触发,根据异步备库curlsn信息,扫描本地的归档目录,获取redo日志,发送到异步的备库。

归档状态:本地归档:实时归档和即时归档:valid invalid

异步归档:valid

OGUID:数据守护唯一标识码,配置时,用户指定。

同一守护进程组中所有的数据库,守护进程和监视器,都必须配置相同的oguid.

Select oguid from v$instance;

监视器:作用:监控,管理数据守护系统确认状态信息发起故障自动接管命令。

监视器模式:

1、监控模式:最多允许同时启动10个监视器

2、确认模式:一个数据守护系统只能有一个确认监视器,实现自动接管理

。部署:三台机器(主机,备机,监视器)

DW配置步骤:

dwp 192.168.1.18 主库

dws 192.168.1.20 备库

dwm 192.168.1.60 监视器

           数据库名       实例名           PORT_NUM    MAL_INST_DW_PORT     MAL_HOST       MAL_PORT      MAL_DW_PORT
主库   DAMENG  GRP1_RT_01        5236                      45101                   192.168.1.18         55101                  65101
备库   DAMENG  GRP1_RT_02        5236                      45121                   192.168.1.20         55121                   65121

1、主库备库关闭实例库

 

2、主库备份

关闭实例,冷备数据
[dmdba@localhost bin]$ ./dmrman CTLSTMT="BACKUP DATABASE '/dm8/data/DAMENG/dm.ini' FULL TO BACKUP_FILE1 BACKUPSET '/dm8/backup/BACKUP_FILE_01'"

 

 

 3、把主库备份传到备份(先去备库下建/dm8/backup目录[root@localhost ~]# mkdir -p /dm8/backup)

[dmdba@localhost bin]$ cd ../backup
[dmdba@localhost backup]$ scp BACKUP_FILE_01/*.* 192.168.1.20:/dm8/backup/

 

 

 4、备库还原 恢复

[root@localhost ~]# su - dmdba
[dmdba@localhost ~]cd /dm8/bin
[dmdba@localhost bin]$./dmrman CTLSTMT="RESTORE DATABASE '/dm8/data/DAMENG/dm.ini' FROM BACKUPSET '/dm8/backup/'"
[dmdba@localhost bin]$./dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/DAMENG/dm.ini' FROM BACKUPSET '/dm8/backup/'"
[dmdba@localhost bin]$./dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/DAMENG/dm.ini' UPDATE DB_MAGIC"

 

 

 

5、primary(主库配置)

[root@localhost ~]# mkdir -p /dm8/arch

[dmdba@localhost backup]$ cd /dm8/data/DAMENG/
[dmdba@localhost DAMENG]$ ls

[dmdba@localhost DAMENG]$ vi dm.ini
dm.ini
----------

INSTANCE_NAME = GRP1_RT_01
PORT_NUM = 5236
DW_INACTIVE_INTERVAL = 60
ALTER_MODE_STATUS = 0
ENABLE_OFFLINE_TS = 2
MAL_INI = 1
ARCH_INI = 1
RLOG_SEND_APPLY_MON = 64

[dmdba@localhost DAMENG]$ vi dmmal.ini
dmmal.ini
---------

MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = GRP1_RT_01
MAL_HOST = 192.168.1.18
MAL_PORT = 55101
MAL_INST_HOST = 192.168.1.18
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = GRP1_RT_02
MAL_HOST = 192.168.1.20
MAL_PORT = 55121
MAL_INST_HOST = 192.168.1.20
MAL_INST_PORT = 5236
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121

[dmdba@localhost DAMENG]$ vi dmarch.ini
dmarch.ini
----------

[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = GRP1_RT_02
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0

[dmdba@localhost DAMENG]$ vi dmwatcher.ini
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 = /dm8/data/DAMENG/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0

6、以 Mount 方式启动主库
[dmdba@localhost DAMENG]$ cd /dm8/bin
[dmdba@localhost bin]$./dmserver /dm8/data/DAMENG/dm.ini mount

7、另开一个窗口
[root@promote ~]# su dmdba
[dmdba@promote root]$cd /dm8/bin
[dmdba@promote bin]$./disql SYSDBA/Dameng123

SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
SQL>sp_set_oguid(453331);
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
SQL>alter database primary;
SQL> exit
[dmdba@promote bin]$ ./disql SYSDBA/Dameng123
服务器[LOCALHOST:5236]:处于主库配置状态
登录使用时间: 3.887(毫秒)

8、standby((备库配置))

[root@localhost ~]# mkdir -p /dm8/arch

[dmdba@localhost backup]$ cd /dm8/data/DAMENG/
[dmdba@localhost DAMENG]$ ls

[dmdba@localhost DAMENG]$ vi dm.ini
dm.ini
----------

INSTANCE_NAME = GRP1_RT_02
PORT_NUM = 5236
DW_INACTIVE_INTERVAL = 60
ALTER_MODE_STATUS = 0
ENABLE_OFFLINE_TS = 2
MAL_INI = 1
ARCH_INI = 1
RLOG_SEND_APPLY_MON = 64


[dmdba@localhost DAMENG]$ vi dmmal.ini
dmmal.ini
--------

MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = GRP1_RT_01
MAL_HOST = 192.168.1.18
MAL_PORT = 55101
MAL_INST_HOST = 192.168.1.18
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = GRP1_RT_02
MAL_HOST = 192.168.1.20
MAL_PORT = 55121
MAL_INST_HOST = 192.168.1.20
MAL_INST_PORT = 5236
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121


[dmdba@localhost DAMENG]$ vi dmarch.ini
dmarch.ini
-----------

[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = GRP1_RT_01
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0


[dmdba@localhost DAMENG]$ vi dmwatcher.ini
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 = /dm8/data/DAMENG/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_APPLY_THRESHOLD = 0

9、以 Mount 方式启动备库
[dmdba@localhost DAMENG]$ cd /dm8/bin
[dmdba@localhost bin]./dmserver /dm8/data/DAMENG/dm.ini mount

10、另开一个窗口
[root@localhost ~]# su dmdba
[dmdba@localhost root]$ cd /dm8/bin
[dmdba@localhost bin]$./disql SYSDBA/Dameng123
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
SQL>sp_set_oguid(453331);
SQL>alter database standby;
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
SQL> exit
[dmdba@localhost bin]$ ./disql SYSDBA/Dameng123
服务器[LOCALHOST:5236]:处于备库配置状态
登录使用时间: 3.887(毫秒)

 

11、启动主库守护进程(在主库中):
[dmdba@localhost bin]$ ./dmwatcher /dm8/data/DAMENG/dmwatcher.ini
12、启动备库守护进程(在备库中):
[dmdba@localhost bin]$ ./dmwatcher /dm8/data/DAMENG/dmwatcher.ini

 

13、监视器中

[root@localhost ~]# su dmdba[dmdba@localhost root]$ cd /dm8
[dmdba@localhost dm8]$ vi dmmonitor.ini
dmmonitor.ini ( 监视器配置、在dm8/下)
--------------

MON_DW_CONFIRM = 1
MON_LOG_PATH = /dm8/data/log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 32
MON_LOG_SPACE_LIMIT = 0
[GRP1]
MON_INST_OGUID = 453331
MON_DW_IP = 192.168.1.18:65101
MON_DW_IP = 192.168.1.20:65121

14、启动监视器

[dmdba@promote bin]$ mkdir -p /dm8/data/log
[dmdba@localhost dm8]$ cd bin
[dmdba@localhost bin]$ ./dmmonitor /dm8/dmmonitor.ini

show 查看一下,和下图一致说明配置成功

 

posted @ 2021-01-21 13:03  梦想在风中飘扬  阅读(227)  评论(0编辑  收藏  举报