数据守护的优点包括高可用性、数据一致性、故障自动切换、恢复灵活等,能够满足用户不间断提供数据库服务的要求。本文将列出数据守护集群的搭建方法,需要提前准备好三台虚拟机,主、备、监视器。
数据库名 实例名 PORT_NUM MAL_INST_DW_PORT MAL_HOST MAL_PORT MAL_DW_PORT
GRP1_RT_01 GRP1_RT_01 i 5246 45101 192.168.160.128 55101 65101
GRP1_RT_02 GRP1_RT_02 5246 45121 192.168.160.129 55121 65121
Dameng123
先初始化主备库实例,dbca建库,注意名称
cd /dm8/tool
./dbca
主备两台实例关掉
./DmServiceGRP1_RT_01 stop
./DmServiceGRP1_RT_02 stop
对主机进行备份:
mkdir -p /dm8/backup
./dmrman CTLSTMT="BACKUP DATABASE '/dm8/data/GRP1_RT_01/dm.ini' FULL TO BACKUP_FILE BACKUPSET '/dm8/backup'"
从主传到备
scp /dm8/backup/* 192.168.160.129:/dm8/backup
在备上进行恢复
./dmrman CTLSTMT="RESTORE DATABASE '/dm8/data/GRP1_RT_02/dm.ini' FROM BACKUPSET '/dm8/backup'"
./dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/GRP1_RT_02/dm.ini' FROM BACKUPSET '/dm8/backup'"
./dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/GRP1_RT_02/dm.ini' UPDATE DB_MAGIC"
cd /dm8/data/GRP1_RT_01
vim dm.ini
INSTANCE_NAME = GRP1_RT_01
PORT_NUM = 5246
DW_INACTIVE_INTERVAL = 60
ALTER_MODE_STATUS = 0
ENABLE_OFFLINE_TS = 2
MAL_INI = 1
ARCH_INI = 1
RLOG_SEND_APPLY_MON = 64
vim dmmal.ini
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = GRP1_RT_01
MAL_HOST = 192.168.160.128
MAL_PORT = 55101
MAL_INST_HOST = 192.168.160.128
MAL_INST_PORT = 5246
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = GRP1_RT_02
MAL_HOST = 192.168.160.129
MAL_PORT = 55121
MAL_INST_HOST = 192.168.160.129
MAL_INST_PORT = 5246
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121
vim dmarch.ini
注:arch_dest备机写主机实例,主机写备机实例
[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
vim 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/GRP1_RT_01/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
启动主库
./dmserver /dm8/data/GRP1_RT_01/dm.ini mount
或者
cd /dm8/bin
./DmServiceGRP1_RT_01 start mount
修改主库的模式和设置oguid。
./disql sysdba/Dameng123@localhost:5246
SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
sp_set_oguid(453331);
alter database primary;
SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
cd /dm8/data/GRP1_RT_02
vim dm.ini
INSTANCE_NAME = GRP1_RT_02
PORT_NUM = 5246
DW_INACTIVE_INTERVAL = 60
ALTER_MODE_STATUS = 0
ENABLE_OFFLINE_TS = 2
MAL_INI = 1
ARCH_INI = 1
RLOG_SEND_APPLY_MON = 64
vim dmmal.ini
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = GRP1_RT_01
MAL_HOST = 192.168.160.128
MAL_PORT = 55101
MAL_INST_HOST = 192.168.160.128
MAL_INST_PORT = 5246
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = GRP1_RT_02
MAL_HOST = 192.168.160.129
MAL_PORT = 55121
MAL_INST_HOST = 192.168.160.129
MAL_INST_PORT = 5246
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121
vim dmarch.ini
注:arch_dest备机写主机实例,主机写备机实例
[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
vim 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/GRP1_RT_02/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_APPLY_THRESHOLD = 0
以 Mount 方式启动备库
./dmserver /dm8/data/GRP1_RT_02/dm.ini mount
或者
cd /dm8/bin
./DmServiceGRP1_RT_02 start mount
设置备库模式和oguid值
./disql sysdba/Dameng123@localhost:5246
SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
sp_set_oguid(453331);
alter database standby;
SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
启主库守护进程
[dmdba@/dm8/bin]# ./dmwatcher /dm8/data/GRP1_RT_01/dmwatcher.ini
启备库守护进程
[dmdba@/dm8/bin]# ./dmwatcher /dm8/data/GRP1_RT_02/dmwatcher.ini
cd /dm8
vim dmmonitor.ini
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.160.128:65101
MON_DW_IP = 192.168.160.129:65121
cd /dm8/bin
./dmmonitor /dm8/dmmonitor.ini
切换主备库
login
sysdba
Dameng123
# 切换
switchover
/dm8/script/root/dm_service_installer.sh -t dmmonitor -p ITSM_DB -monitor_ini /dm8/dmmonitor.ini
注册主库的守护进程
/dm8/script/root/dm_service_installer.sh -t dmwatcher -p Watcher -watcher_ini /dm8/data/GRP1_RT_01/dmwatcher.ini
注册备库的守护进程
/dm8/script/root/dm_service_installer.sh -t dmwatcher -p Watcher -watcher_ini /dm8/data/GRP1_RT_02/dmwatcher.ini
1、关闭监视器
2、关闭备库守护进程
3、关闭主库守护进程
4、关闭主库实例
5、关闭备库实例
文章
阅读量
获赞