千家信息网

DM7如何搭建数据守护

发表于:2024-11-25 作者:千家信息网编辑
千家信息网最后更新 2024年11月25日,这篇文章主要介绍DM7如何搭建数据守护,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!数据守护(DG)环境说明下列机器事先都安装了DM软件,安装路径为/dm7,执行程序保存在/d
千家信息网最后更新 2024年11月25日DM7如何搭建数据守护

这篇文章主要介绍DM7如何搭建数据守护,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

数据守护(DG)
环境说明
下列机器事先都安装了DM软件,安装路径为/dm7,执行程序保存在/dm7/bin目录中,数据存放路径为/dm7/data

机器名     IP地址                  初始状态                         操作系统    19c1     10.13.13.141(对外)        主库 dm1                         redhat 6.7         10.10.10.141(mal对内)19c2     10.13.13.142(对外)         10.10.10.142(mal对内)     备库 dm2                         redhat 6.7ora19c   10.13.13.140              确认监视器                       redhat 6.7实例名       port_num             dw_port    mal_host              mal_port        mal_dw_portdm1          5236                 5239       10.10.10.141          5237            5238dm2          5236                 5239       10.10.10.142          5237            5238

数据准备
在主库机器上初始化数据库到目录/dm7/data:

[dmdba@19c1 bin]$ ./dminit path=/dm7/data db_name=DAMENG instance_name=DM1 port_num=5236 page_size=8 charset=0initdb V7.1.6.46-Build(2018.02.08-89107)ENTdb version: 0x7000afile dm.key not found, use default license!License will expire in 14 day(s) on 2020-06-17log file path: /dm7/data/DAMENG/DAMENG01.loglog file path: /dm7/data/DAMENG/DAMENG02.logwrite to dir [/dm7/data/DAMENG].create dm database success. 2020-06-03 02:55:43

注册服务用于启动数据库

[root@19c1 root]# ./dm_service_installer.sh -i /dm7/data/DAMENG/dm.ini -p DM1 -t dmserverln -s '/usr/lib/systemd/system/DmServiceDM1.service' '/etc/systemd/system/multi-user.target.wants/DmServiceDM1.service'Finished to create the service (DmServiceDM1)

正常启动数据库并正常关闭

[root@19c1 root]# service DmServiceDM1 startRedirecting to /bin/systemctl start DmServiceDM1.service[root@19c1 root]# ps -ef | grep dmserverdmdba 21312 1 14 02:59 ? 00:00:03 /dm7/bin/dmserver /dm7/data/DAMENG/dm.ini -noconsoleroot 21536 18668 0 03:00 pts/2 00:00:00 grep --color=auto dmserver[dmdba@19c1 bin]$ ./disql SYSDBA/SYSDBAServer[LOCALHOST:5236]:mode is normal, state is openlogin used time: 5.903(ms)disql V7.1.6.46-Build(2018.02.08-89107)ENTConnected to: DM 7.1.6.46SQL> exit[root@19c1 root]# service DmServiceDM1 stopRedirecting to /bin/systemctl stop DmServiceDM1.service

ARCH_INI=1(打开归档)
MAL_INI=1(打开MAL配置)
DW_PORT=5239 (DW端口)

配置dmmal.ini文件
配置MAL系统,各主备库的dmmal.ini配置必须完全一致,MAL_HOST使用内部网络IP,MAL_PORT与dm.ini中PORT_NUM使用不同的端口值,MAL_DW_PORT是各实例对应的守护进程之间,以及守护进程和监视器之间的通信端口,配置如下:

[dmdba@19c1 DAMENG]$ vi dmmal.iniMAL_CHECK_INTERVAL = 5MAL_CONN_FAIL_INTERVAL = 5[MAL_INST1]MAL_INST_NAME = DM1MAL_HOST = 10.10.10.141MAL_PORT = 5237MAL_INST_HOST = 10.13.13.141MAL_INST_PORT = 5236MAL_DW_PORT = 5238[MAL_INST2]MAL_INST_NAME = DM2MAL_HOST = 10.10.10.142MAL_PORT = 5237MAL_INST_HOST = 10.13.13.142MAL_INST_PORT = 5236MAL_DW_PORT = 5238

配置dmarch.ini
修改dmarch.ini,配置本地归档和实时归档。除了本地归档外,其他归档配置项中的ARCH_DEST表示实例是Primary模式时,需要同步归档数据的目标实例名。当前实例DM1是主库,需要向DM2(实时备库)同步数据,因此实时归档的ARCH_DEST配置为DM2。

[dmdba@19c1 DAMENG]$ vi dmarch.ini[ARCHIVE_REALTIME]ARCH_TYPE = REALTIMEARCH_DEST = DM2[ARCHIVE_LOCAL1]ARCH_TYPE = LOCALARCH_DEST = /dm7/data/DAMENG/archARCH_FILE_SIZE = 128ARCH_SPACE_LIMIT = 0

配置dmwatcher.ini
修改dmwatcher.ini配置守护进程,配置为全局守护类型,使用自动切换模式。

[dmdba@19c1 DAMENG]$ vi dmwatcher.ini[GRP1]DW_TYPE = GLOBALDW_MODE = AUTODW_ERROR_TIME = 10INST_RECOVER_TIME = 60INST_ERROR_TIME = 10INST_OGUID = 453331INST_INI = /dm7/data/DAMENG/dm.iniINST_AUTO_RESTART = 1INST_STARTUP_CMD = /dm7/bin/dmserverRLOG_SEND_THRESHOLD = 0RLOG_APPLY_THRESHOLD = 0

配置dmwatcher.ctl
同一个守护进程组,必须使用同一份dmwatcher.ctl。因此,只需要使用dmctlcvt工具生成一份dmwatcher.ctl文件,然后分别拷贝到各个数据库目录下即可。在配置完成dmwatcher.ini后,使用dmctlcvt工具生成dmwatcher.ctl:(特别注意,DEST目录为DAMENG的上一级目录,否则不生成控制文件)

[dmdba@19c1 bin]$ ./dmctlcvt TYPE=3 SRC=/dm7/data/DAMENG/dmwatcher.ini DEST=/dm7/dataDMCTLCVT V7.1.6.46-Build(2018.02.08-89107)ENTconvert txt to ctl success!

会在/dm7/data目录中生成一个GRP1目录,在GRP1目录中生成了dmwatcher.ctl控制文件

[root@19c1 data]# ls -lrttotal 4drwxr-xr-x 8 dmdba dinstall 4096 Jun 3 03:44 DAMENGdrwxr-xr-x 2 dmdba dinstall 26 Jun 3 03:53 GRP1[root@19c1 data]# cd GRP1[root@19c1 GRP1]# ls -lrttotal 4-rw-r--r-- 1 dmdba dinstall 512 Jun 3 03:53 dmwatcher.ctl

拷贝生成的dmwatcher.ctl文件到数据文件目录/dm7/data/DAMENG。

将主库相关文件传输到备机:

[dmdba@19c1 dm7]$ scp -r data/ dmdba@10.13.13.142:/dm7/The authenticity of host '10.13.13.142 (10.13.13.142)' can't be established.ECDSA key fingerprint is 7f:1f:9a:0f:8b:d1:e0:17:32:08:12:73:d8:1d:9c:da.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '10.13.13.142' (ECDSA) to the list of known hosts.dmdba@10.13.13.142's password:dminit20200603025444.log 100% 783 0.8KB/s 00:00sqllog.ini 100% 479 0.5KB/s 00:00dm.ctl 100% 5120 5.0KB/s 00:00DAMENG01.log 100% 256MB 256.0MB/s 00:01DAMENG02.log 100% 256MB 128.0MB/s 00:02dm_20200603025543_320471.ctl 100% 5120 5.0KB/s 00:00dm_20200603030017_373808.ctl 100% 5120 5.0KB/s 00:00SYSTEM.DBF 100% 21MB 21.0MB/s 00:01dm_service.prikey 100% 633 0.6KB/s 00:00MAIN.DBF 100% 128MB 128.0MB/s 00:01ROLL.DBF 100% 128MB 128.0MB/s 00:01dminst.sys 100% 220 0.2KB/s 00:00TEMP.DBF 100% 10MB 10.0MB/s 00:00rep_conflict.log 100% 12 0.0KB/s 00:00dm.ini 100% 40KB 39.8KB/s 00:00dmmal.ini 100% 558 0.5KB/s 00:00dmarch.ini 100% 367 0.4KB/s 00:00dmwatcher.ini 100% 615 0.6KB/s 00:00dmwatcher.ctl 100% 512 0.5KB/s 00:00

备机修改相关配置

修改dm.iniINSTANCE_NAME = DM2

修改dmarch.ini

ARCH_DEST = DM1

其中dmwatcher.ini,dmmal.ini,dmwatcher.ctl和主库一致

二:启动到mount状态设置oguid
主库

[dmdba@19c1 bin]$ ./dmserver /dm7/data/DAMENG/dm.ini mountfile dm.key not found, use default license!version info: developUse normal os_malloc instead of HugeTLBUse normal os_malloc instead of HugeTLBDM Database Server x64 V7.1.6.46-Build(2018.02.08-89107)ENT startup...License will expire in 14 day(s) on 2020-06-17ckpt lsn: 32981SYSTEM IS READY.[dmdba@19c1 bin]$ ./disql SYSDBA/SYSDBAServer[LOCALHOST:5236]:mode is normal, state is mountlogin used time: 6.020(ms)disql V7.1.6.46-Build(2018.02.08-89107)ENTConnected to: DM 7.1.6.46SQL> sp_set_oguid(453331);DMSQL executed successfullyused time: 38.995(ms). Execute id is 1.SQL> exit

备库

[dmdba@19c2 bin]$ ./dmserver /dm7/data/DAMENG/dm.ini mountfile dm.key not found, use default license!version info: developUse normal os_malloc instead of HugeTLBUse normal os_malloc instead of HugeTLBDM Database Server x64 V7.1.6.46-Build(2018.02.08-89107)ENT startup...License will expire in 14 day(s) on 2020-06-17ckpt lsn: 32981SYSTEM IS READY.[dmdba@19c2 bin]$ ./disql SYSDBA/SYSDBAServer[LOCALHOST:5236]:mode is normal, state is mountlogin used time: 6.005(ms)disql V7.1.6.46-Build(2018.02.08-89107)ENTConnected to: DM 7.1.6.46SQL> sp_set_oguid(453331);DMSQL executed successfullyused time: 46.333(ms). Execute id is 1.

注册服务用于启动数据库

[root@19c2 root]# ./dm_service_installer.sh -i /dm7/data/DAMENG/dm.ini -p DM2 -t dmserverln -s '/usr/lib/systemd/system/DmServiceDM2.service' '/etc/systemd/system/multi-user.target.wants/DmServiceDM2.service'Finished to create the service (DmServiceDM2)

三:打开数据库
主库以primary打开

SQL> alter database primary;executed successfullyused time: 37.838(ms). Execute id is 0.

备库以standby 打开

SQL> alter database standby;executed successfullyused time: 39.682(ms). Execute id is 0.

四:启动守护进程
启动各个主备库上的守护进程:
主库

[dmdba@19c1 bin]$ ./dmwatcher /dm7/data/DAMENG/dmwatcher.iniDMWATCHER[2.1] V7.1.6.46-Build(2018.02.08-89107)ENTDMWATCHER[2.1] IS READY

备库

[dmdba@19c2 bin]$ ./dmwatcher /dm7/data/DAMENG/dmwatcher.iniDMWATCHER[2.1] V7.1.6.46-Build(2018.02.08-89107)ENTDMWATCHER[2.1] IS READY五:查看file_lsn与cur_lsn主备库是否一致主库
SQL> select file_LSN, cur_LSN from v$rlog;LINEID FILE_LSN CUR_LSN---------- -------------------- --------------------1 34412 34412used time: 1.203(ms). Execute id is 6.

备库

SQL> select file_LSN, cur_LSN from v$rlog;LINEID FILE_LSN CUR_LSN---------- -------------------- --------------------1 34412 34412used time: 1.228(ms). Execute id is 3.

测试数据同步
主库:

SQL> create table t1(id int);executed successfullyused time: 18.410(ms). Execute id is 7.SQL> insert into t1 values(1);affect rows 1used time: 0.890(ms). Execute id is 8.SQL> commit;executed successfullyused time: 6.026(ms). Execute id is 9.SQL> select file_LSN, cur_LSN from v$rlog;LINEID FILE_LSN CUR_LSN---------- -------------------- --------------------1 34443 34443used time: 0.340(ms). Execute id is 10.

备库:

SQL> select file_LSN, cur_LSN from v$rlog;LINEID FILE_LSN CUR_LSN---------- -------------------- --------------------1 34443 34443used time: 0.363(ms). Execute id is 4.SQL> select * from t1;LINEID ID---------- -----------1 1used time: 1.213(ms). Execute id is 5.

六:配置监视器(基本要求,安装dm7的软件)
由于主库和实时备库的守护进程配置为自动切换模式,因此这里选择配置确认监视器。和普通监视器相比,确认监视器除了相同的命令支持外,在主库发生故障时,能够自动通知实时备库接管为新的主库,具有自动故障处理的功能。
修改dmmonitor.ini配置确认监视器,其中MON_DW_IP中的IP和PORT和dmmal.ini中的MAL_HOST和MAL_DW_PORT配置项保持一致。

[dmdba@ora19c data]$ vi dmmonitor.iniMON_DW_CONFIRM = 1MON_LOG_PATH = /dm7/data/logMON_LOG_INTERVAL = 60MON_LOG_FILE_SIZE = 32MON_LOG_SPACE_LIMIT = 0[GRP1]MON_INST_OGUID = 453331MON_DW_IP = 10.10.10.141:5238MON_DW_IP = 10.10.10.142:5238

启动监视器:

[dmdba@ora19c bin]$ ./dmmonitor /dm7/data/dmmonitor.ini[monitor] 2020-06-03 09:18:20: DMMONITOR[2.1] V7.1.6.46-Build(2018.02.08-89107)ENT[monitor] 2020-06-03 09:18:20: DMMONITOR[2.1] IS READY.[monitor] 2020-06-03 09:18:20: Received message from(DM1)WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN SSLSN SLSN2020-06-03 04:35:58 OPEN OK DM1 OPEN PRIMARY VALID 2 34443 34443 34443 34443[monitor] 2020-06-03 09:18:20: Received message from(DM2)WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN SSLSN SLSN2020-06-03 04:35:58 OPEN OK DM2 OPEN STANDBY VALID 2 34443 34443 34443 34443

以上是"DM7如何搭建数据守护"这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!

0