LOG_SIZE=1024
RLOG_COUNT=2
PAGE_SIZE=32
EXTENT_SIZE=16
CHARSET=1
CASE_SENSITIVE=N
主库做备份:
backup database full backupset '/home/dmdba/fullbak0327';
scp备份集到其他备库上
scp -r /home/dmdba/fullbak0327/ dmdba@192.168.48.9:/home/dmdba
scp -r /home/dmdba/fullbak0327/ root@192.168.48.22:/home/dmdba
使用脚本初始化一个单机C和D,初始化参数和主备集群相同
TIME_ZONE=(480)
LANGUAGE=(CN)
GRP3=(192.168.48.7:42141,192.168.48.8:42142)
[GRP3]
TIME_ZONE=(+480)
LOGIN_MODE=(1)
SWITCH_TIME=(3)
SWITCH_INTERVAL=(1000)
#配置有订阅归档时,打开定时器,定时同步归档到订阅备库
INSTANCE_NAME = GRP3_SUBSCB01
PORT_NUM = 42143
MAL_INI = 1
ARCH_INI = 1 #dmarch.ini
TIMER_INI = 1 #dmtimer.ini
订阅备库配置本地归档和订阅归档。
订阅备库通过在 ARCH_DEST 中配置一个 disql 登录串来指定源库。
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /home/dmdba/dmdata/dmarch/DAMENG_Q4P16
ARCH_FILE_SIZE = 1024
ARCH_SPACE_LIMIT = 2048
ARCH_FLUSH_BUF_SIZE = 0
ARCH_HANG_FLAG = 1
[ARCHIVE_SUBSCRIBE1]
ARCH_TYPE = SUBSCRIBE
ARCH_SUBSCRIBE_MODE = 3
ARCH_DEST = SYSDBA/SYSDBA@GRP3
ARCH_TIMER_NAME = SUBSCRIBE_TIMER
ARCH_THRESHOLD_PER_SECOND = 0
ARCH_SEND_DELAY = 0
订阅备库需要开启定时器。
下面示例中定时器配置为每天每1min 触发订阅备库获取主库的归档日志,可以根据实际情况再做调整。
[SUBSCRIBE_TIMER] #和 dmarch.ini 中的 ARCH_TIMER_NAME 一致
TYPE = 2
FREQ_MONTH_WEEK_INTERVAL = 1
FREQ_SUB_INTERVAL = 0
FREQ_MINUTE_INTERVAL = 1
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
释义如下:
vi dmtimer.ini
[RT_TIMER]
#和 dmarch.ini 中的 ARCH_TIMER_NAME 一致
TYPE = 2 #2 按日执行
FREQ_MONTH_WEEK_INTERVAL = 1 #间隔月或周数
FREQ_SUB_INTERVAL = 0 #间隔天数
FREQ_MINUTE_INTERVAL = 1 #间隔分钟数
START_TIME = 00:00:00 #开始时间
END_TIME = 00:00:00 #结束时间
DURING_START_DATE = 2021-5-15 12:00:00 #开始时间点
DURING_END_DATE = 9999-12-31 23:59:59 #结束时间点
NO_END_DATE_FLAG = 1 #是否结束标记
DESCRIBE = RT_TIMER #定时器描述
IS_VALID = 1 #0:表示关闭定时器,1:表示启用定时器
修改订阅备库 dm.ini,设置:
MAL_INI = 1 #打开 MAL 系统
MAL_CHECK_INTERVAL = 15
MAL_CONN_FAIL_INTERVAL = 15
MAL_LEAK_CHECK = 1
MAL_BUF_SIZE = 256
MAL_SYS_BUF_SIZE = 1024
MAL_COMPRESS_LEVEL = 0
MAL_TEMP_PATH = /home/dmdba/dmdata/DAMENG_Q4P16/TEMP.DBF
MAL_VPOOL_SIZE = 512
[MAL_INST3]
MAL_INST_NAME = GRP3_SUBSCB01
MAL_HOST = 192.168.48.9
MAL_PORT = 64143
MAL_INST_HOST = 192.168.48.9
MAL_INST_PORT = 42143
MAL_INST_DW_PORT = 57143
MAL_DW_PORT = 59143
[GRP3]
DW_TYPE = LOCAL
DW_MODE = MANUAL
DW_ERROR_TIME = 15
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 15
INST_OGUID = 453333
INST_INI = /home/dmdba/dmdata/DAMENG_Q4P16/dm.ini
INST_AUTO_RESTART =
INST_STARTUP_CMD = /home/dmdba/dmdbms_q4p16/bin/dmserver
创建守护进程服务:
cd /home/dmdba/dmdbms_q4p16/script/root/
./dm_service_installer.sh -t dmwatcher -watcher_ini /home/dmdba/dmdata/DAMENG_Q4P16/dmwatcher.ini -p GRP3_SUBSCB01
restore database '/home/dmdba/dmdata/DAMENG_Q4P16/dm.ini' from backupset '/home/dmdba/fullbak0327';
recover database '/home/dmdba/dmdata/DAMENG_Q4P16/dm.ini' from backupset '/home/dmdba/fullbak0327';
recover database '/home/dmdba/dmdata/DAMENG_Q4P16/dm.ini' update db_magic;
./dmserver /dm/data/SUBSCB2/dm.ini mount
启动命令行工具 DIsql,设置 OGUID 值,然后修改数据库模式
SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
SP_SET_OGUID(453333); -- 设置 OGUID
ALTER DATABASE STANDBY; -- 修改数据库模式
SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
然后启动守护进程,守护进程启动后,进入 Startup 状态,此时实例处于 Mount 状态,订阅备库的守护进程会将本地实例自动 Open,并切换守护进程自身为 Open 状态。
./DmServiceDMSERVER start
./DmWatcherServiceGRP3_SUBSCB01 start
#配置有订阅归档时,打开定时器,定时同步归档到订阅备库
INSTANCE_NAME = GRP3_SUBSCB01_1
PORT_NUM = 42144
MAL_INI = 1
ARCH_INI = 1 #dmarch.ini
TIMER_INI = 1 #dmtimer.ini
订阅备库配置本地归档和订阅归档。
订阅备库通过在 ARCH_DEST 中配置一个 disql 登录串来指定源库。
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /home/dmdba/dmdata/dmarch/DAMENG_Q4P16
ARCH_FILE_SIZE = 1024
ARCH_SPACE_LIMIT = 2048
ARCH_FLUSH_BUF_SIZE = 0
ARCH_HANG_FLAG = 1
[ARCHIVE_SUBSCRIBE1]
ARCH_TYPE = SUBSCRIBE
ARCH_SUBSCRIBE_MODE = 3
ARCH_DEST = SYSDBA/SYSDBA@192.168.48.9:42143
ARCH_TIMER_NAME = SUBSCRIBE_TIMER
ARCH_THRESHOLD_PER_SECOND = 0
ARCH_SEND_DELAY = 0
订阅备库需要开启定时器。
下面示例中定时器配置为每天每1min 触发订阅备库获取主库的归档日志,可以根据实际情况再做调整。
[SUBSCRIBE_TIMER] #和 dmarch.ini 中的 ARCH_TIMER_NAME 一致
TYPE = 2
FREQ_MONTH_WEEK_INTERVAL = 1
FREQ_SUB_INTERVAL = 0
FREQ_MINUTE_INTERVAL = 1
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
释义如下:
vi dmtimer.ini
[RT_TIMER]
#和 dmarch.ini 中的 ARCH_TIMER_NAME 一致
TYPE = 2 #2 按日执行
FREQ_MONTH_WEEK_INTERVAL = 1 #间隔月或周数
FREQ_SUB_INTERVAL = 0 #间隔天数
FREQ_MINUTE_INTERVAL = 1 #间隔分钟数
START_TIME = 00:00:00 #开始时间
END_TIME = 00:00:00 #结束时间
DURING_START_DATE = 2021-5-15 12:00:00 #开始时间点
DURING_END_DATE = 9999-12-31 23:59:59 #结束时间点
NO_END_DATE_FLAG = 1 #是否结束标记
DESCRIBE = RT_TIMER #定时器描述
IS_VALID = 1 #0:表示关闭定时器,1:表示启用定时器
订阅备库dmmal.ini可以不配置这么详细,本次暂时配置了集群全部节点的信息,
修改订阅备库 dmmal.ini,设置:
MAL_INI = 1 #打开 MAL 系统
MAL_CHECK_INTERVAL = 15
MAL_CONN_FAIL_INTERVAL = 15
MAL_LEAK_CHECK = 1
MAL_BUF_SIZE = 256
MAL_SYS_BUF_SIZE = 1024
MAL_COMPRESS_LEVEL = 0
MAL_TEMP_PATH = /home/dmdba/dmdata/DAMENG_Q4P16/TEMP.DBF
MAL_VPOOL_SIZE = 512
[MAL_INST1]
MAL_INST_NAME = GRP3_RT_01
MAL_HOST = 192.168.48.7
MAL_PORT = 64141
MAL_INST_HOST = 192.168.48.7
MAL_INST_PORT = 42141
MAL_INST_DW_PORT = 57141
MAL_DW_PORT = 59141
[MAL_INST2]
MAL_INST_NAME = GRP3_RT_02
MAL_HOST = 192.168.48.8
MAL_PORT = 64142
MAL_INST_HOST = 192.168.48.8
MAL_INST_PORT = 42142
MAL_INST_DW_PORT = 57142
MAL_DW_PORT = 59142
[MAL_INST3]
MAL_INST_NAME = GRP3_SUBSCB01
MAL_HOST = 192.168.48.9
MAL_PORT = 64143
MAL_INST_HOST = 192.168.48.9
MAL_INST_PORT = 42143
MAL_INST_DW_PORT = 57143
MAL_DW_PORT = 59143
[MAL_INST4]
MAL_INST_NAME = GRP3_SUBSCB01_1
MAL_HOST = 192.168.48.22
MAL_PORT = 64144
MAL_INST_HOST = 192.168.48.22
MAL_INST_PORT = 42144
MAL_INST_DW_PORT = 57144
MAL_DW_PORT = 59144
[GRP3]
DW_TYPE = LOCAL
DW_MODE = MANUAL
DW_ERROR_TIME = 15
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 15
INST_OGUID = 453333
INST_INI = /home/dmdba/dmdata/DAMENG_Q4P16/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /home/dmdba/dmdbms_q4p16/bin/dmserver
cd /home/dmdba/dmdbms_q4p16/script/root/
./dm_service_installer.sh -t dmwatcher -watcher_ini /home/dmdba/dmdata/DAMENG_Q4P16/dmwatcher.ini -p GRP3_SUBSCB01_1
2)使用主库备份恢复
restore database '/home/dmdba/dmdata/DAMENG_Q4P16/dm.ini' from backupset '/home/dmdba/fullbak0327';
recover database '/home/dmdba/dmdata/DAMENG_Q4P16/dm.ini' from backupset '/home/dmdba/fullbak0327';
recover database '/home/dmdba/dmdata/DAMENG_Q4P16/dm.ini' update db_magic;
3)启动至mount并修改模式
./dmserver /dm/data/SUBSCB2/dm.ini mount
启动命令行工具 DIsql,设置 OGUID 值,然后修改数据库模式
SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
SP_SET_OGUID(453333); -- 设置 OGUID
ALTER DATABASE STANDBY; -- 修改数据库模式
SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
然后启动守护进程,守护进程启动后,进入 Startup 状态,此时实例处于 Mount 状态,订阅备库的守护进程会将本地实例自动 Open,并切换守护进程自身为 Open 状态。
./DmServiceDMSERVER start
./DmWatcherServiceGRP3_SUBSCB01 start
vi /home/dmdba/dmdata/dmmon/DAMENG_Q4P16/dmmonitor_manual.ini
MON_DW_CONFIRM = 0
MON_LOG_PATH = /home/dmdba/dmdata/dmmon/DAMENG_Q4P16/log_manual
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 512
MON_LOG_SPACE_LIMIT = 4096
[GRP3]
MON_INST_OGUID = 453333
MON_DW_IP = 192.168.48.7:59141
MON_DW_IP = 192.168.48.8:59142
MON_DW_IP = 192.168.48.9:59143
MON_DW_IP = 192.168.48.22:59144
注:确认监视器需修改dmmonitor_auto.ini,此处略
./DmServiceGRP3_RT_01 start
./DmServiceGRP3_RT_02 start
./DmServiceGRP3_SUBSCB01 start
./DmServiceGRP3_SUBSCB01_1 start
./DmWatcherServiceGRP3_RT_01 start
./DmWatcherServiceGRP3_RT_02 start
./DmWatcherServiceGRP3_SUBSCB01 start
./DmWatcherServiceGRP3_SUBSCB01_1 start
./DmMonitorServiceGRP3 start
查看状态
文章
阅读量
获赞