一实时备机+一异步备机集群搭建
1:主机规划
----- | 实例名 | IP地址 | 端口 |
---|---|---|---|
主库 | 3DW_1 | 192.168.139.100 | 5236 |
实时备库 | 3DW_2 | 192.168.139.101 | 5236 |
异步备库 | 3DW_3 | 192.168.139.102 | 5236 |
2:备份主库
1)首先初始化三台机器实例,以第一台为例,在安装目录bin目录下输入:
./dminit path=/home/dmdba/dmdbms/data db_name=3DW_1 instance_name=3DW_1 case_sensitive=1 port_num=5236;
2)然后在脱机状态 使用dmrman备份主库(bin下)
./dmrman ctlstmt=“backup database ‘/home/dmdba/dmdbms/data/3DW_1/dm.ini’ full to backup_3dw1 backupset ‘/home/dmdba/dmdbms/data/3DW_1/backup_3dw1’”
3)将备份发送到每个备库
scp -r /home/dmdba/dmdbms/data/3DW_1/backup_3dw1/ dmdba@192.168.139.100:/home/dmdba/dmdbms/data
3:备库还原、恢复与更新
脱机状态下在备库上使用dmrman还原、恢复与更新(下面是实时备库,异步备库同理)
读数据文件失败:换dmdba用户
还原:./dmrman ctlstmt=“restore database ‘/home/dmdba/dmdbms/data/3DW_2/dm.ini’ from backupset ‘/home/dmdba/dmdbms/data/backup_3dw1’”
恢复:./dmrman ctlstmt=“recover database ‘/home/dmdba/dmdbms/data/3DW_2/dm.ini’ from backupset ‘/home/dmdba/dmdbms/data/backup_3dw1’”
更新:./dmrman ctlstmt=“recover database ‘/home/dmdba/dmdbms/data/3DW_2/dm.ini’ update db_magic”
4:配置主库
dm.ini配置
INSTANCE_NAME=3DW_1
ARCH_INI=1
MAL_INI=1
ALTER_MODE_STATUS= 0
ENABLE_OFFLINE_TS = 2
TIMER_INI = 1 #配置有异步归档时,打开定时器,定时同步归档到异备库
dmmal.ini配置
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = 3DW_1
MAL_HOST = 192.168.139.100
MAL_PORT = 61141
MAL_INST_HOST = 192.168.139.100
MAL_INST_PORT = 5236
MAL_DW_PORT = 52141
MAL_INST_DW_PORT = 33141
[MAL_INST2]
MAL_INST_NAME = 3DW_2
MAL_HOST = 192.168.139.101
MAL_PORT = 61141
MAL_INST_HOST = 192.168.139.101
MAL_INST_PORT = 5236
MAL_DW_PORT = 52141
MAL_INST_DW_PORT = 33141
[MAL_INST3]
MAL_INST_NAME = 3DW_3
MAL_HOST = 192.168.139.102
MAL_PORT = 61141
MAL_INST_HOST = 192.168.139.102
MAL_INST_PORT = 5236
MAL_DW_PORT = 52141
MAL_INST_DW_PORT = 33141
dmarch.ini配置
[ARCHIVE_REALTIME1]
ARCH_TYPE = REALTIME
ARCH_DEST = 3DW_2
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /home/dmdba/dmdbms/data/3DW_1/arch
ARCH_FILE_SIZE = 512
ARCH_SPACE_LIMIT = 10240
[ARCHIVE_ASYNC]
ARCH_TYPE = ASYNC #异步归档类型
ARCH_DEST = 3DW_3#异步归档目标实例名
ARCH_TIMER_NAME = RT_TIMER #定时器名称,和dmtimer.ini 中的名称一致
dmtimer.ini配置
主和实时备库都需要,配置 dmtimer.ini,用于定时触发实例发送归档日志到异步备库。
下面示例中定时器配置为每天 00:00:00 触发主库发送归档日志到异步备库,可以根据实际情况再做调整。
[RT_TIMER] #和 dmarch.ini 中的 ARCH_TIMER_NAME 一致
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 = 2016-02-11 17:36:09
DURING_END_DATE = 9999-12-31 23:59:59
NO_END_DATE_FLAG = 1
DESCRIBE = RT TIMER
IS_VALID = 1
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 = /home/dmdba/dmdbms/data/3DW_1/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /home/dmdba/dmdbms/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
配置主库OGUID:
①以mount模式开启主库:进入安装得bin目录,输入:
./dmserver /home/dmdba/dmdbms/data/3DW_1/dm.ini mount
②新打开一个终端,登录disql,修改OGUID
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);
③修改数据库模式
alter database primary;
后将配置文件发送到两个备库:
scp dm.ini dmmal.ini dmarch.ini dmwatcher.ini dmdba@192.168.139.101:/home/dmdba/dmdbms/data/3DW_2
5:配置所有备库
dm.ini:
里面的INSTANCE_NAME改为自己的,还有所有路径改变为自己的。
dmarch.ini:
将ARCH_DEST参数修改为除自己外的库(异步备库只保留本地归档)
Dmwatcher:
里面修改为自己的目录
配置所有备库OGUID:
①以mount模式开启备库:进入安装得bin目录,输入:
./dmserver /home/dmdba/dmdbms/data/3DW_2/dm.ini mount
②新打开一个终端,登录disql,修改OGUID
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);
③修改数据库模式
alter database standby;
配置异步备库 dmwatcher.ini
修改 dmwatcher.ini 配置守护进程,配置为本地守护类型,异步备库不具备故障自动切换等功能,DW_MODE 配置并不起作用,此处配置为 MANUAL 即可,另外异步备库不需要配置 dmwatcher.ctl 控制文件。
[GRP1]
DW_TYPE = LOCAL #本地守护类型
DW_MODE = MANUAL #故障手动切换模式
DW_ERROR_TIME = 10 #远程守护进程故障认定时间
INST_ERROR_TIME = 10 #本地实例故障认定时间
INST_OGUID = 453331 #守护系统唯一 OGUID 值
INST_INI = /home/dmdba/dmdbms/data/3DW_3/dm.ini #dm.ini 配置文件路径
INST_AUTO_RESTART = 1 #打开实例的自动启动功能
INST_STARTUP_CMD = /home/dmdba/dmdbms/bin/dmserver #命令行方式启动
6:配置监视器dmmonitor.ini
MON_DW_Confirm = 1
MON_LOG_PATH = /home/dmdba/dmdbms/monitor_3dw_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.139.100:52141
MON_DW_IP = 192.168.139.101:52141
MON_DW_IP = 192.168.139.102:52141
7:启动三个库的守护进程
先以mount方式启动数据库。然后启动守护进程
./dmwatcher /home/dmdba/dmdbms/data/3DW_1/dmwatcher.ini
8:启动监控功能
./dmmonitor /home/dmdba/dmdbms/data/3DW_3/dmmonitor.ini
注意:记得关闭防火墙,端口号不能重,初始化实例,配置文件名不能错