一、环境准备
主库 172.25.254.199
备库 172.25.254.200
监视器 172.25.254.201
数据库名 实例名 PORT_NUM MAL_INST_DW_PORT MAL_HOST MAL_PORT MAL_DW_PORT
DMDW GRP1_RT_01 5246 45101 172.25.254.199 55101 65101
DMDW GRP1_RT_03 5246 45121 172.25.254.200 55121 65121
--创建实例
主库创建实例 GRP1_RT_01
备库创建实例 GRP1_RT_03
监视器不需要创建实例
--主备都停掉服务
[dmdba@study:/dm8/data/bin]$./DmServiceGRP1_RT_01 stop
[dmdba@study:/dm8/data/bin]$./DmServiceGRP1_RT_03 stop
二、数据准备
主库创建一个备份目录mkdir /dm8/data/backup
--全库备份
BACKUP DATABASE '/dm8/data/data/DMDW/dm.ini' FULL TO BACKUP_FILE1 BACKUPSET '/dm8/data/backup/BACKUP_FILE_01'
--查看备份文件
cd /dm8/data/backup
--把备份文件拷贝至备库/dm8/data/backup
scp -r *.* 172.25.254.200:/dm8/data/backup
--备库查看确认文件存在
--备库操作还原与恢复
RESTORE DATABASE '/dm8/data/data/DMDW/dm.ini' FROM BACKUPSET '/dm8/data/backup'
RECOVER DATABASE '/dm8/data/data/DMDW/dm.ini' FROM BACKUPSET '/dm8/data/backup'
RECOVER DATABASE '/dm8/data/data/DMDW/dm.ini' UPDATE DB_MAGIC
三、参数配置
主库配置:
cd /dm8/data/data/DMDW
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 = 60
MAL_CONN_FAIL_INTERVAL = 60
[MAL_INST1]
MAL_INST_NAME = GRP1_RT_01
MAL_HOST = 172.25.254.199
MAL_PORT = 55101
MAL_INST_HOST = 172.25.254.199
MAL_INST_PORT = 5246
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = GRP1_RT_03
MAL_HOST = 172.25.254.200
MAL_PORT = 55121
MAL_INST_HOST = 172.25.254.200
MAL_INST_PORT = 5246
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121
vim dmarch.ini #新建文件,直接粘贴参数保存即可
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = GRP1_RT_03
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/data/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0
vim dmwatcher.ini #新建文件,直接粘贴参数保存即可
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = MANUAL
DW_ERROR_TIME = 60
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 60
INST_OGUID = 453331
INST_INI = /dm8/data/data/DMDW/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/data/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
以mount方式启动主库
cd /dm8/data/bin
./dmserver /dm8/data/data/DMDW/dm.ini mount
./disql sysdba/"2wsx3EDC1"@localhost:5246
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
SQL>sp_set_oguid(453331);
SQL>alter database primary;
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
备库配置:
vim dm.ini
INSTANCE_NAME = GRP1_RT_03
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
dmmal.ini
MAL_CHECK_INTERVAL = 60
MAL_CONN_FAIL_INTERVAL = 60
[MAL_INST1]
MAL_INST_NAME = GRP1_RT_01
MAL_HOST = 172.25.254.199
MAL_PORT = 55101
MAL_INST_HOST = 172.25.254.199
MAL_INST_PORT = 5246
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = GRP1_RT_03
MAL_HOST = 172.25.254.200
MAL_PORT = 55121
MAL_INST_HOST = 172.25.254.200
MAL_INST_PORT = 5246
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121
dmarch.ini
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = GRP1_RT_01
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/data/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0
dmwatcher.ini
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = MANUAL
DW_ERROR_TIME = 60
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 60
INST_OGUID = 453331
INST_INI = /dm8/data/data/DMDW/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/data/bin/dmserver
RLOG_APPLY_THRESHOLD = 0
以 Mount 方式启动备库
cd /dm8/data/bin
./dmserver /dm8/data/data/DMDW/dm.ini mount
./disql sysdba/"2wsx3EDC1"@localhost:5246
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);
四、主备库启动守护进程把数据库拉到open状态
cd /dm8/data/bin
./dmwatcher /dm8/data/data/DMDW/dmwatcher.ini
监视器配置:
cd /dm8/data
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 = 172.25.254.199:65101
MON_DW_IP = 172.25.254.200:65121
cd /dm8/data/bin
./dmmonitor /dm8/dmmonitor.ini
手动切换主备库
--切换到备库
在监视器里登录
login
用户名:sysdba
密码:
switchover
再执行一次恢复到原来的主库状态
switchover