dm数据守护
1.先做备份
开归档
[dmdba
@dmp1 dmdbms
]$ mkdir dmarch
[dmdba
@dmp1 dmdbms
]$ vi DAMENG
/dm
.ini
[dmdba
@dmp1 dmdbms
]$ cat DAMENG
/dm
.ini
|grep ARCH_INI
ARCH_INI
= 1
[dmdba
@dmp1 DAMENG
]$ cat dmarch
.ini
[ARCHIVE_LOCAL1
]
ARCH_TYPE
=LOCAL
ARCH_DEST
=/home
/dmdba
/dmdbms
/dmarch
ARCH_FILE_SIZE
=1024
ARCH_SPACE_LIMIT
=10240
1.1脱机备份
确定启动dmap
[dmdba
@dmp1 bin
]$
./DmServicedm stop
Stopping DmServicedm:
[ OK
]
[dmdba
@dmp1 bin
]$
./dmrman
dmrman V8
RMAN
>
RMAN
> backup databases '/home/dmdba/dmdbms/DAMENG/dm.ini' backupset
'/home/dmdba/dmdbms/backup_file_01';
拷贝备份文件到所在机器dm.ini dm.ctl
[dmdba
@dmp1 dmdbms
]$ scp
-r backup_file_01 dmdba
@192.168.6.78:
/home
/dmdba
/dmdbms
1.2脱机恢复
[dmdba
@dms2 bin
]$
./DmServicedm stop
Stopping DmServicedm:
[ OK
]
[dmdba
@dms2 bin
]$
./dmrman
dmrman V8
RMAN
> restore database '/home/dmdba/dmdbms/DAMENG/dm.ini' from backupset
'/home/dmdba/dmdbms/backup_file_01';
restore database '/home/dmdba/dmdbms/DAMENG/dm.ini' from backupset
'/home/dmdba/dmdbms/backup_file_01';
file dm
.key not found
, use default license
!
RESTORE DATABASE CHECK......
RESTORE DATABASE,data collect
......
RESTORE DATABASE,database refresh
......
RESTORE BACKUPSET
[/home
/dmdba
/dmdbms
/backup_file_01
] START......
total
7 packages processed
...
total
8 packages processed
...
RESTORE DATABASE,UPDATE ctl
file......
RESTORE DATABASE,REBUILD
key file......
RESTORE DATABASE,CHECK db info
......
RESTORE DATABASE,UPDATE db info
......
total
8 packages processed
...
total
8 packages processed
!
CMD
END.CODE:
[0]
restore successfully
.
time used:
00:
00:
01.098
RMAN
> recover
database '/home/dmdba/dmdbms/DAMENG/dm.ini' from backupset
'/home/dmdba/dmdbms/backup_file_01';
recover
database '/home/dmdba/dmdbms/DAMENG/dm.ini' from backupset
'/home/dmdba/dmdbms/backup_file_01';
Database mode = 0, oguid
= 0
EP
[0]'s cur_lsn[49291]
RESTORE RLOG CHECK......
RESTORE RLOG, gen tmp file......
RESTORE RLOG FROM BACKUPSET [/home/dmdba/dmdbms/backup_file_01] START......
total 2 packages processed...
total 2 packages processed...
total 2 packages processed!
CMD END.CODE:[0]
EP:0 total 1 pkgs applied, percent: 50%
EP:0 total 2 pkgs applied, percent: 100%
Recover from archive log finished, time used:0.010s.
recover successfully!
time used: 305.045(ms)
RMAN> recover database '/home
/dmdba
/dmdbms
/DAMENG
/dm
.ini
' update db_magic;
recover database '/home
/dmdba
/dmdbms
/DAMENG
/dm
.ini
' update db_magic;
Database mode = 0, oguid = 0
EP[0]'s cur_lsn
[49296]
EP
[0]'s apply_lsn
[49296] >= end_lsn
[49296]
recover successfully
!
time used:
00:
00:
01.019
RMAN
>
1.3联机备份
SQL> backup database backupset
'/home/dmdba/dmdbms/backup_file_01';
操作已执行
已用时间:
00:
00:
01.170. 执行号:
5.
拷贝备份文件到所在机器dm.ini dm.ctl scp /home/dmdba/dmdbms/data/dmdb/dm.ini dmdba@192.168.6.67/home/dmdba/dmdbms/data/dmdb/dm.ini
1.4联机恢复
同上面的脱机恢复
2.环境规划
两个机器事先安装DM和实例 安装路径为/home/dmdba/dmdbms/ 数据库名字为/home/dmdba/dmdbms/dmdb 数据路径data/ 归档路径 /home/dmdba/dmdbms/data/dmdb/arch 数据库实例名字dmdbserver1 主库192.168.6.68 备库192.168.6.69
实例名PORT_NUMMAL_INST_DW_PORTMAL_HOSTMAL_PORTMAL_DW_PORT
GRP1_PT_01523633141192.168.6.686114152141GRP1_RT_02523633142182.168.6.696114252142
3.配置主库
3.1.配置dm.ini
INSTANCE_NAME
= GRP1_RT_01
PORT_NUM
= 5236
ALTER_MODE_STATUS
= 0
ENABLE_OFFLINE_TS
= 2
MAL_INI
= 1
ARCH_INI
= 1
DW_INACTIVE_INTERVAL
= 60
RLOG_SEND_APPLY_MON
= 64
3.2配置 dmmal.ini
MAL_CHECK_INTERVAL
= 5
MAL_CONN_FAIL_INTERVAL
= 5
[MAL_INST1
]
MAL_INST_NAME
= GRP1_RT_01
MAL_HOST
=192.168.6.68
MAL_PORT
= 61141
MAL_INST_HOST
= 192.168.6.68
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.6.78
MAL_PORT
= 61142
MAL_INST_HOST
= 192.168.6.78
MAL_INST_PORT
= 5237
MAL_DW_PORT
= 52142
MAL_INST_DW_PORT
= 33142
3.3配置dmarch.ini
[ARCHIVE_REALTIME
]
ARCH_TYPE
= REALTIME
ARCH_DEST
= GRP1_RT_02
[ARCHIVE_LOCAL1
]
ARCH_TYPE
= LOCAL
ARCH_DEST
= /home
/dmdba
/dmdbms
/dmarch
ARCH_FILE_SIZE
= 1024
ARCH_SPACE_LIMIT
= 10240
```sql
```sql
[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
/DAMENG
/dm
.ini
INST_AUTO_RESTART
= 1
INST_STARTUP_CMD
= /home
/dmdba
/dmdbms
/bin
/dmserver
RLOG_SEND_THRESHOLD
= 0
RLOG_APPLY_THRESHOLD
= 0
3.5启动主库
./dmserver
/home
/dmdba
/dmdbms
/DAMENG
/dm
.ini mount
file dm
.key not found
, use default license
!
version info: develop
Use normal os_malloc instead
of HugeTLB
Use normal os_malloc instead
of HugeTLB
DM
Database Server x64 V8
1-1-76-20.04.21-120616-ENT startup
...
Database mode = 0, oguid
= 0
License will expire
on 2021-04-21
file lsn:
54026
ndct db
load finished
ndct fill fast pool finished
nsvr_startup
end.
aud sys init success
.
aud rt sys init success
.
systables
desc init success
.
ndct_db_load_info success
.
SYSTEM
IS READY
.
3.6设置oguid
SP_SET_PARA_VALUE
(1, 'ALTER_MODE_STATUS', 1);
sp_set_oguid
(453331);
SP_SET_PARA_VALUE
(1, 'ALTER_MODE_STATUS', 0);
3.7修改数据库模式
[dmdba
@dmp1 bin
]$
./disql
disql V8
用户名:
密码:
服务器
[LOCALHOST:
5236]:处于普通配置状态
登录使用时间:
3.218(毫秒
)
SQL> alter database primary;
操作已执行
已用时间:
23.740(毫秒
). 执行号:
0.
SQL>
4.配置备库
4.1.配置dm.ini
INSTANCE_NAME
= GRP1_RT_02
PORT_NUM
= 5237
ALTER_MODE_STATUS
= 0
ENABLE_OFFLINE_TS
= 2
MAL_INI
= 1
ARCH_INI
= 1
DW_INACTIVE_INTERVAL
= 60
RLOG_SEND_APPLY_MON
= 64
4.2配置 dmmal.ini
MAL_CHECK_INTERVAL
= 5
MAL_CONN_FAIL_INTERVAL
= 5
[MAL_INST1
]
MAL_INST_NAME
= GRP1_RT_01
MAL_HOST
= 192.168.6.68
MAL_PORT
= 61141
MAL_INST_HOST
= 192.168.6.68
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.6.78
MAL_PORT
= 61142
MAL_INST_HOST
= 192.168.6.78
MAL_INST_PORT
= 5237
MAL_DW_PORT
= 52142
MAL_INST_DW_PORT
= 33142
~
4.3配置dmarch.ini
[ARCHIVE_REALTIME
]
ARCH_TYPE
= REALTIME
ARCH_DEST
= GRP1_RT_01
[ARCHIVE_LOCAL1
]
ARCH_TYPE
=LOCAL
ARCH_DEST
=/home
/dmdba
/dmdbms
/dmarch
ARCH_FILE_SIZE
=1024
ARCH_SPACE_LIMIT
=10240
4.4配置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
/DAMENG
/dm
.ini
INST_AUTO_RESTART
= 1
INST_STARTUP_CMD
= /home
/dmdba
/dmdbms
/bin
/dmserver
RLOG_APPLY_THRESHOLD
= 0
4.5启动备库
./dmserver
/home
/dmdba
/dmdbms
/DAMENG
/dm
.ini mount
file dm
.key not found
, use default license
!
version info: develop
Use normal os_malloc instead
of HugeTLB
Use normal os_malloc instead
of HugeTLB
DM
Database Server x64 V8
1-1-76-20.04.21-120616-ENT startup
...
Database mode = 0, oguid
= 0
License will expire
on 2021-04-21
file lsn:
54025
ndct db
load finished
ndct fill fast pool finished
nsvr_startup
end.
aud sys init success
.
aud rt sys init success
.
systables
desc init success
.
ndct_db_load_info success
.
SYSTEM
IS READY
.
4.6设置oguid
./disql SYSDBA
/SYSDBA:
5237
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);
4.7修改数据库模式
./disql SYSDBA
/SYSDBA:
5237
SQL>SP_SET_PARA_VALUE
(1, 'ALTER_MODE_STATUS', 1);
SQL>alter database standby
;
SQL>SP_SET_PARA_VALUE
(1, 'ALTER_MODE_STATUS', 0);
5.配置监视器dmmonitor.ini–确认网络。防火墙
vi dmmonitor
.ini
MON_DW_CONFIRM
= 1
MON_LOG_PATH
= /home
/dmdba
/dmdbms
/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.6.68:
52141
MON_DW_IP
= 192.168.6.78:
52142
6.启动守护进程
启动主库实例
./dmserver
/home
/dmdba
/dmdbms
/DAMENG
/dm
.ini
启动备库实例
./dmserver
/home
/dmdba
/dmdbms
/DAMENG
/dm
.ini
启动主库dmwatcher
./dmwatcher
/home
/dmdba
/dmdbms
/DAMENG
/dmwatcher
.ini
启动备库dmwatcher
./dmwatcher
/home
/dmdba
/dmdbms
/DAMENG
/dmwatcher
.ini
7.启动监视器
./dmmonitor
/home
/dmdba
/dmdbms
/data/dmdb
/dmmonitor
.ini
8.注册
root: ./dm_service_installer.sh -dm_ini /home/dmdba/dmdbms/DAMENG/dm.ini -t dmserver -p dm1 ./dm_service_installer.sh -watcher_ini /home/dmdba/dmdbms/DAEMNG/dmwatcher.ini -t dmwatcher -p dmwatcher1 dmdba: ./DmServicedm1 start ./DmWatcherServicedmwatcher1 start
./dmmonitor /home/dmdba/dmdbms/data/dmdb/dmmonitor.ini