DM7数据文件迁移方案

一、背景

在现场使用数据库的过程中,由于前期规划不太合理,或者客户数据量超过预期,有可能导致存放数据文件的目录磁盘空间紧张,若磁盘空间满,则会导致数据库无法写入数据,进而影响业务,因此,如果出现磁盘空间不足的问题,我们有可能需要重新规划或者添加磁盘,然后将数据全部迁移到新规划的数据目录。

二、迁移数据文件

1、停止数据库

cd /home/dmdba/dm/dmdbms/bin/service_template
./DmService stop

2、使用dmctlcvt工具,将数据库ctl控制文件转为txt文件,并保存重命名bak文件

cd /home/dmdba/dm/dmdbms/bin
./dmctlcvt TYPE=1 SRC=/dbbata/dmdata/DAMENG/dm.ctl DEST=/dbdata/dmdata/DAMENG/dm.txt
mv /dbdata/dmdata/DAMENG/dm.ctl /dbdata/dmdata/DAMENG/dm.ctl_bak

3、vim修改文件内容,将里面的数据文件路径,调整为需要迁移到的目的路径

首先文件内容如下:

[root@dmhs1 ~]# cat /dbdata/dmdata/DAMENG/dm.txt 
##############################################################################
## please do not adjust parameter order, ensure the ctl have no difference ###
##########################################################################


# database name
dbname=DAMENG
# server mode
svr_mode=0
#OGUID
oguid=0
# db server version
version=117508180
# database version
db_version=458764
# pseg version
pseg_version=0
#SGUID
sguid=679222253
#NEXT_TS_ID
next_ts_id=5
#RAC_NODES
rac_nodes=1
#NEXT_HTS_ID
next_htsid=129
#TIME_FLAG
time_flag=170
#MDIR_FLAG
mdir_flag=31
#STARTUP_CNT
startup_cnt=2
#LAST_STARTUP_TIME
last_startup_time=DATETIME '2022-1-18 0:30:32'
#DM7_DCT_VERSION
dm7_dct_version=11
#DM8_DCT_VERSION
dm8_dct_version=38

#===============================================
#===============================================

# table space name
ts_name=SYSTEM
 # table space ID
ts_id=0
# table space status
ts_state=0
# table space cache
ts_cache=
# DSC node number
ts_nth=0
# DSC optimized node number
ts_opt_node=0
# table space create time
ts_create_time=DATETIME '2021-12-31 0:6:4'
# table space modify time
ts_modify_time=DATETIME '2021-12-31 0:6:4'
# table space encrypt flag
ts_encrypt_flag=0
# table space copy num
ts_copy_num=0
# table space region size flag
ts_size_flag=0

#-----------------------------------------------

# file path
fil_path=/dbdata/dmdata/DAMENG/SYSTEM.DBF
# mirror path
mirror_path=
# file id
fil_id=0
# whether the file is auto extend
autoextend=1
# file create time
fil_create_time=DATETIME '2021-12-31 0:6:4'
# file modify time
fil_modify_time=DATETIME '2021-12-31 0:6:4'
# the max size of file
fil_max_size=0
# next size of file
fil_next_size=0


#===============================================

# table space name
ts_name=ROLL
 # table space ID
ts_id=1
# table space status
ts_state=0
# table space cache
ts_cache=
# DSC node number
ts_nth=0
# DSC optimized node number
ts_opt_node=0
# table space create time
ts_create_time=DATETIME '2021-12-31 0:6:4'
# table space modify time
ts_modify_time=DATETIME '2021-12-31 0:6:4'
# table space encrypt flag
ts_encrypt_flag=0
# table space copy num
ts_copy_num=0
# table space region size flag
ts_size_flag=0

#-----------------------------------------------

# file path
fil_path=/dbdata/dmdata/DAMENG/ROLL.DBF
# mirror path
mirror_path=
# file id
fil_id=0
# whether the file is auto extend
autoextend=1
# file create time
fil_create_time=DATETIME '2021-12-31 0:6:4'
# file modify time
fil_modify_time=DATETIME '2021-12-31 0:6:4'
# the max size of file
fil_max_size=0
# next size of file
fil_next_size=0


#===============================================

# table space name
ts_name=RLOG
 # table space ID
ts_id=2
# table space status
ts_state=0
# table space cache
ts_cache=
# DSC node number
ts_nth=0
# DSC optimized node number
ts_opt_node=0
# table space create time
ts_create_time=DATETIME '2021-12-31 0:6:4'
# table space modify time
ts_modify_time=DATETIME '2021-12-31 0:6:4'
# table space encrypt flag
ts_encrypt_flag=0
# table space copy num
ts_copy_num=0
# table space region size flag
ts_size_flag=0

#-----------------------------------------------

# file path
fil_path=/dbdata/dmdata/DAMENG/DAMENG01.log
# mirror path
mirror_path=
# file id
fil_id=0
# whether the file is auto extend
autoextend=1
# file create time
fil_create_time=DATETIME '2021-12-31 0:6:4'
# file modify time
fil_modify_time=DATETIME '2021-12-31 0:6:4'
# the max size of file
fil_max_size=0
# next size of file
fil_next_size=0

# file path
fil_path=/dbdata/dmdata/DAMENG/DAMENG02.log
# mirror path
mirror_path=
# file id
fil_id=1
# whether the file is auto extend
autoextend=1
# file create time
fil_create_time=DATETIME '2021-12-31 0:6:4'
# file modify time
fil_modify_time=DATETIME '2021-12-31 0:6:4'
# the max size of file
fil_max_size=0
# next size of file
fil_next_size=0


#===============================================

# table space name
ts_name=MAIN
 # table space ID
ts_id=4
# table space status
ts_state=0
# table space cache
ts_cache=
# DSC node number
ts_nth=0
# DSC optimized node number
ts_opt_node=0
# table space create time
ts_create_time=DATETIME '2021-12-31 0:6:4'
# table space modify time
ts_modify_time=DATETIME '2021-12-31 0:6:4'
# table space encrypt flag
ts_encrypt_flag=0
# table space copy num
ts_copy_num=0
# table space region size flag
ts_size_flag=0

#-----------------------------------------------

# file path
fil_path=/dbdata/dmdata/DAMENG/MAIN.DBF
# mirror path
mirror_path=
# file id
fil_id=0
# whether the file is auto extend
autoextend=1
# file create time
fil_create_time=DATETIME '2021-12-31 0:6:4'
# file modify time
fil_modify_time=DATETIME '2021-12-31 0:6:4'
# the max size of file
fil_max_size=0
# next size of file
fil_next_size=0


#===============================================

# HUGE table space name
htsname=HMAIN
# HUGE table space id
htsid=128
#HUGE table space share flag
htsflag=0
# HUGE table space copy num
hts_copy_num=0
# HUGE table space region size flag
hts_size_flag=0
# HUGE table space create time
hts_create_time=DATETIME '2021-12-31 0:6:4'
# HUGE table space modify time
hts_modify_time=DATETIME '2021-12-31 0:6:4'
# HUGE table space path
htspath=/dbdata/dmdata/DAMENG/HMAIN

#===============================================

[root@dmhs1 ~]# 

vim /dbdata/dmdata/DAMENG/dm.txt

所有 fil_path=/dbdata/dmdata/DAMENG/ROLL.DBF 这样的内容,路径调整为(假设目的路径为/dbdata1/dmdata1/DAMENG/):
fil_path=/dbdata1/dmdata1/DAMENG/ROLL.DBF

4、mv数据文件到新的数据目录
mv /dbdata/dmdata/DAMENG/ROLL.DBF  /dbdata1/dmdata1/DAMENG

5、将修改后的txt文件,再通过dmctlcvt工具,转换成ctl控制文件
cd /home/dmdba/dm/dmdbms/bin
./dmctlcvt TYPE=2 SRC=/dbbata/dmdata/DAMENG/dm.txt DEST=/dbdata/dmdata/DAMENG/dm.ctl

6、启动数据库,验证数据

cd /home/dmdba/dm/dmdbms/bin/service_template
./DmService start

了解更多达梦数据库相关技术,可访问达梦官网学习
DM 数据库快速上手指南 | 达梦技术文档

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值