部署實時主備叢集
---主庫第一次啟動可以為非mount 備庫從部署開始就只能以mount方式啟動
1.在兩臺機器上分別安裝資料庫,並初始化例項(主庫GRP1_RT_01 備庫GRP1_RT_02)
2.在主庫上做離線全量備份,並把備份集scp到備庫上的機器
dmrman
backup database '/database/dm8/myinst/DAMENG/dm.ini' full to backup_full backupset '/home/dmdba/test_dw/full_bak';
scp -r full_bak dmdba@sdb0:/home/dmdba/test_dw/
3.備庫上的機器進行離線還原
dmrman
restore database '/database/dm8/myinst/DAMENG/dm.ini' from backupset '/home/dmdba/test_dw/full_bak' ;
recover database '/database/dm8/myinst/DAMENG/dm.ini' from backupset '/home/dmdba/test_dw/full_bak' ;
recover database '/database/dm8/myinst/DAMENG/dm.ini' update db_magic ;
4.修改主庫配置
修改主庫ini
vi dm.ini
##例項名
INSTANCE_NAME = GRP1_RT_01
##例項埠號
PORT_NUM = 5236
##接收守護程序訊息超時時間
DW_INACTIVE_INTERVAL = 60
##設定不允許手工方式修改例項模式/狀態/OGUID
ALTER_MODE_STATUS = 0
##設定不允許備庫offline表空間
ENABLE_OFFLINE_TS = 2
##開啟MAL系統
MAL_INI = 1
##開啟歸檔配置
ARCH_INI = 1
##統計最近64次的日誌傳送資訊
RLOG_SEND_APPLY_MON = 64
配置mal系統,各主備庫的dmmal.ini配置必須完全一致
vi dmmal.ini
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = GRP1_RT_01
MAL_HOST = 192.168.43.128
MAL_PORT = 61141
MAL_INST_HOST = 192.168.43.128
MAL_INST_PORT = 5236
MAL_DW_PORT = 52141
MAL_INST_DW_PORT = 33141
[MAL_INST2]
MAL_INST_NAME = GRP1_RT_02
MAL_HOST = 192.168.43.127
MAL_PORT = 61142
MAL_INST_HOST = 192.168.43.127
MAL_INST_PORT = 5236
MAL_DW_PORT = 52142
MAL_INST_DW_PORT = 33142
配置本地歸檔和實時歸檔
vi dmarch.ini
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = GRP1_RT_02
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /database/dm8/myinst/DAMENG/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 1024
配置守護程序
vi 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 = /database/dm8/myinst/DAMENG/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /database/dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
用mount方式啟動主庫
dmsever /database/dm8/myinst/DAMENG/dm.ini mount
連線至客戶端,設定oguid,修改資料庫模式
SP_SET_PARA_VALUE(1,'ALTER_MODE_STATUS',1);
SP_SET_OGUID(453331);
SP_SET_PARA_VALUE(1,'ALTER_MODE_STATUS',0);
alter database primary ;
5.修改備庫
修改備庫ini
vi dm.ini
##例項名
INSTANCE_NAME = GRP1_RT_02
##例項埠號
PORT_NUM = 5236
##接收守護程序訊息超時時間
DW_INACTIVE_INTERVAL = 60
##設定不允許手工方式修改例項模式/狀態/OGUID
ALTER_MODE_STATUS = 0
##設定不允許備庫offline表空間
ENABLE_OFFLINE_TS = 2
##開啟MAL系統
MAL_INI = 1
##開啟歸檔配置
ARCH_INI = 1
##統計最近64次的日誌傳送資訊
RLOG_SEND_APPLY_MON = 64
配置mal系統,主備庫的dmmal.ini配置必須一致,直接拷貝即可
配置本地歸檔和實時歸檔 一般來說 改歸檔目標例項名即可
vi dmarch.ini
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = GRP1_RT_01
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /database/dm8/myinst/DAMENG/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 1024
配置守護程序
--幾乎一樣
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = AUTO
DW_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 453331
INST_INI = /database/dm8/myinst/DAMENG/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /database/dm8/bin/dmserver
RLOG_APPLY_THRESHOLD = 0
以mount方式啟動備庫
dmsever /database/dm8/myinst/DAMENG/dm.ini mount
連線至客戶端,設定oguid
SP_SET_PARA_VALUE(1,'ALTER_MODE_STATUS',1);
SP_SET_OGUID(453331);
修改資料庫模式
SP_SET_PARA_VALUE(1,'ALTER_MODE_STATUS',1);
alter database standby ;
SP_SET_PARA_VALUE(1,'ALTER_MODE_STATUS',0);
6.配置單例項監視器 --路徑不作要求 為了方便我直接配在例項目錄下
vi dmmonitor.ini
MON_DW_CONFIRM = 1
MON_LOG_PATH = /database/dm8/myinst/DAMENG/mymonitor/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.43.128:52141
MON_DW_IP = 192.168.43.127:52142
7.
mount 方式啟動資料庫例項
主備都啟
dmserver /database/dm8/myinst/DAMENG/dm.ini
啟動所有主備上的守護程序
dmwatcher /database/dm8/myinst/DAMENG/dmwatcher.ini
啟動監視器
dmmonitor /database/dm8/myinst/DAMENG/dmmonitor.ini
https://eco.dameng.com