DM数据库的版本一直在不断的的迭代。 对于DM 的数据库版本,分大版本和小版本。
因此达梦数据库的升级需要根据不同的版本来操作。
达梦数据库版本升级的三种方式:
版本 | 安装目录 | 数据目录 | 归档目录 | 账号密码 | 端口 | |
---|---|---|---|---|---|---|
迁移前 | 20230417 | /dmdb8/dmdbms/bin | /dmdb8/dmdata | /dmdb8/dmarch | SYSDBA/SYSDBA | 5237 |
迁移后 | 20231116 | /dmdb8/dmdbms/bin | /dmdb8/dmdata | SYSDBA/SYSDBA | 5237 | |
|
| 迁移前 | 迁移后 |
| — | — | — |
| 操作系统版本 | | |
| 内存 | | |
| 数据库版本 | 2023.04.17 | |
| 数据库对象数量(用户,表) | 用户表 | |
| 数据库安装位置 | /dmdb8/dmdbms | |
| 数据库实例位置 | /dmdb8/dmdata | |
--登录数据库
/dmdb8/dmdbms/bin/disql SYSDBA:5237
--查看版本
SQL> select * from v$version;
LINEID BANNER
---------- ---------------------------------
1 DM Database Server 64 V8
2 DB Version: 0x7000c
3 03134284044-20230417-187846-20040 #着重看该值
或
SQL> select svr_version,db_version,build_version from v$instance;
LINEID svr_version db_version build_version
---------- -------------------------- ------------------- -----------------------------------
1 DM Database Server x64 V8 DB Version: 0x7000c 1-3-12-2023.04.17-187846-20040-ENT
--查看所有表空间大小及其使用情况
SELECT F.TABLESPACE_NAME,
(T.TOTAL_SPACE - F.FREE_SPACE) / 1024 "USED (GB)",
F.FREE_SPACE / 1024 "FREE (GB)",
T.TOTAL_SPACE / 1024 "TOTAL(GB)",
(ROUND((F.FREE_SPACE / T.TOTAL_SPACE) * 100)) || '% ' PER_FREE
FROM (SELECT TABLESPACE_NAME,
ROUND(SUM(BLOCKS *
(SELECT PARA_VALUE / 1024
FROM V$DM_INI
WHERE PARA_NAME = 'GLOBAL_PAGE_SIZE') / 1024)) FREE_SPACE
FROM DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) F,
(SELECT TABLESPACE_NAME, ROUND(SUM(BYTES / 1048576)) TOTAL_SPACE
FROM DBA_DATA_FILES
GROUP BY TABLESPACE_NAME) T
WHERE F.TABLESPACE_NAME = T.TABLESPACE_NAME;
--查看指定用户占用的空间大小,如查看SYSDBA用户占用的空间大小
SELECT USER_USED_SPACE('SYSDBA') * PARA_VALUE / 1024 / 1024 "USER_USED_SPACE(MB)"
FROM V$DM_INI
WHERE PARA_NAME LIKE 'GLOBAL_PAGE_SIZE';
https://eco.dameng.com/download/官网下载,示例
新旧版本相差太大,只替换bin目录,可能会导致客户端工具localhost连接报错等问题。但是若版本相差不大,这种方式最为简单方便。
数据库升级过程中建议对旧版本数据库实例关闭,升级期间数据库暂时无法对外提供服务
--查看版本
[dmdba@localhost ~]$ /dmdb8/dmdbms/bin/disql SYSDBA:5237
SQL> select * from v$version;
LINEID BANNER
---------- ---------------------------------
1 DM Database Server 64 V8
2 DB Version: 0x7000c
3 03134284044-20230417-187846-20040 #着重看该值
或
SQL> select svr_version,db_version,build_version from v$instance;
LINEID svr_version db_version build_version
---------- -------------------------- ------------------- -----------------------------------
1 DM Database Server x64 V8 DB Version: 0x7000c 1-3-62-2023.04.17-208042-20067-ENT
--非归档场景下全库备份
[dmdba@top132 ~]$ dexp USERID=SYSDBA/[email protected]:5237 FILE=db_`date +%F`.dmp LOG=db_exp_`date +%F`.log FULL=Y DIRECTORY=/dmdb8/dmtmp
或dmrman备份
/dmdb8/dmdbms/bin/dmrman
RMAN> backup database '/dmdb8/dmdata/fuwa/dm.ini' full backupset '/dmdb8/dmdata/fuwa/bak/db_fuwa_full_bak_02';
##FULL参数表示执行的备份为完全备份
--归档场景下全库备份
SQL>backup database full backupset '/dmdb8/dmtmp/db_full_bak_01';
补充:如果用dexp 参数文件,示例如下:
[dmdba@localhost dmtmp]$ dexp USERID=SYSDBA/[email protected]:5237 parfile=/dmdb8/dmtmp/dimp.txt
[dmdba@localhost dmtmp]$ cat /dmdb8/dmtmp/dimp.txt
FILE=db_fuwa_20231127.dmp LOG=db_fuwa_exp_20231127.log FULL=Y DIRECTORY=/dmdb8/dmtmp
--查进程(确认正在用的数据库安装目录和数据目录位置,避免多个目录混淆)
[dmdba@localhost ~]$ ps -ef | grep dm
....
dmdba 941 1 0 13:19 ? 00:00:00 /dmdb8/dmdbms/bin/dmap
dmdba 971 1 0 07:46 ? 00:00:08 /dmdb8/dmdbms/bin/dmserver path=/dmdb8/dmdata/fuwa/dm.ini -noconsole
dmdba 5142 1360 0 09:22 pts/1 00:00:00 grep --color=auto dmserver
...
--停止进程
su - root
systemctl stop DmAPService
systemctl stop DmServicefuwa
--再次确认服务已停止
[dmdba@localhost ~]$ ps -ef | grep dm
dmdba 5268 1360 0 09:23 pts/1 00:00:00 grep --color=auto dmserver
[dmdba@localhost ~]$ cd /dmdb8/dmdbms/
[dmdba@localhost dmdbms]$ mv bin bin_bak_`date +%F` 或tar -czvf bin_bak_`date +%F` bin
[dmdba@localhost dmdbms]$ ls -l
total 52
drwxr-xr-x. 10 dmdba dinstall 8192 Oct 16 15:43 bin
drwxr-xr-x. 2 dmdba dinstall 30 Oct 16 14:56 bin2
drwxr-xr-x 10 dmdba dinstall 8192 Nov 25 09:28 bin_bak_2023-11-25
[dmdba@localhost dmdbms]$ du -sh bin
367M bin
[dmdba@localhost dmdbms]$ du -sh bin_bak_2023-11-25/
367M bin_bak_2023-11-25/
[dmdba@localhost dmdbms]$
--备份当前归档目录
[dmdba@localhost ~]$ cd /dmdb8/
[dmdba@localhost dmdb8]$ mv dmarch dmarch_bak_`date +%F`
--创建归档目录
[dmdba@localhost dmdb8]$ mkdir -p dmarch
[root@localhost etc]# mv /etc/dm_svc.conf /etc/dm_svc.conf_bak_`date +%F`
[root@localhost etc]# ls -l dm*
-rw-r--r--. 1 dmdba dinstall 30 Oct 16 14:56 dm_svc.conf_bak_2023-11-27
su - root
mkdir -p /dm8/dmdbms8
chown -R dmdba:dinstall /dm8/dmdbms8/
chmod -R 755 /dm8/dmdbms8/
上传安装介质dm8_20231116_x86_rh6_64.iso至/opt下
su - root
cd /opt
mount dm8_20231116_x86_rh6_64.iso /mnt
cp /mnt/DMInstall.bin /home/dmdba
chown dmdba:dinstall /home/dmdba/DMInstall.bin
su - dmdba -c '/home/dmdba/DMInstall.bin -i'
注意:
不要执行/dm8/dmdbms8/script/root/root_installer.sh
详细过程:
[root@localhost opt]# su - dmdba -c '/home/dmdba/DMInstall.bin -i'
Please select the installer's language (E/e:English C/c:Chinese) [E/e]:
Extract install files.........
Welcome to DM DBMS Installer
Whether to input the path of Key File? (Y/y:Yes N/n:No) [Y/y]:n
Whether to Set The TimeZone? (Y/y:Yes N/n:No) [Y/y]:
TimeZone:
[ 1]: GTM-12=West Date Line
[ 2]: GTM-11=Samoa
[ 3]: GTM-10=Hawaii
[ 4]: GTM-09=Alaska
[ 5]: GTM-08=Pacific(America and Canada)
[ 6]: GTM-07=Arizona
[ 7]: GTM-06=Central(America and Canada)
[ 8]: GTM-05=East(America and Canada)
[ 9]: GTM-04=Atlantic(America and Canada)
[10]: GTM-03=Brasilia
[11]: GTM-02=Middle Atlantic
[12]: GTM-01=Azores
[13]: GTM=Greenwich Mean Time
[14]: GTM+01=Sarajevo
[15]: GTM+02=Cairo
[16]: GTM+03=Moscow
[17]: GTM+04=AbuDhabi
[18]: GTM+05=Islamabad
[19]: GTM+06=Dakar
[20]: GTM+07=BangKok,Hanoi
[21]: GTM+08=China
[22]: GTM+09=Seoul
[23]: GTM+10=Guam
[24]: GTM+11=Solomon
[25]: GTM+12=Fiji
[26]: GTM+13=Nukualofa
[27]: GTM+14=Kiribati
Please Select the TimeZone [21]:
Installation Type:
1 Typical
2 Server
3 Client
4 Custom
Please Input the number of the Installation Type [1 Typical]:
Require Space: 1815M
Please Input the install path [/home/dmdba/dmdbms]:/dm8/dmdbms8
Available Space:23G
Please Confirm the install path(/dm8/dmdbms8)? (Y/y:Yes N/n:No) [Y/y]:
Pre-Installation Summary
Installation Location: /dm8/dmdbms8
Require Space: 1815M
Available Space: 23G
Version Information:
Expire Date:
Installation Type: Typical
Confirm to Install? (Y/y:Yes N/n:No):y
2023-11-25 14:03:11
[INFO] Installing BASE Module...
2023-11-25 14:03:11
[INFO] Installing DM DBMS...
2023-11-25 14:03:13
[INFO] Installing SERVER Module...
2023-11-25 14:03:14
[INFO] Installing CLIENT Module...
2023-11-25 14:03:16
[INFO] Installing DRIVERS Module...
2023-11-25 14:03:20
[INFO] Installing MANUAL Module...
2023-11-25 14:03:20
[INFO] Installing SERVICE Module...
2023-11-25 14:03:21
[INFO] Move log file to log directory.
2023-11-25 14:03:21
[INFO] Installed DM DBMS completely.
Please execute the commands by root:
/dm8/dmdbms8/script/root/root_installer.sh --不执行
End
将新安装目录下的bin目录移动 到原安装目录下
[dmdba@localhost]$ cd /dmdb8/dmdbms
[dmdba@localhost dmdbms]$ cp -r /dm8/dmdbms8/bin /dmdb8/dmdbms/
[dmdba@top132 dmdbms]$ cp bin_bak_2023-11-27/DmAPService bin/
[dmdba@top132 dmdbms]$ cp bin_bak_2023-11-27/DmServicefuwa bin/
[dmdba@top132 dmdbms]$ cp bin_bak_2023-11-27/dm.key /bin/
--前提启动数据库
[dmdba@localhost]$ cd /dmdb8/dmdbms
[dmdba@localhost dmdbms]$ bin/dmserver /dmdb8/dmdata/fuwa/dm.ini
显示system is ready,则启动成功,输入exit关闭数据库。
--新开一窗口,查数据库版本
[dmdba@localhost ~]$ /dmdb8/dmdbms/bin/disql SYSDBA:5237
password:
Server[LOCALHOST:5237]:mode is normal, state is open
login used time : 3.941(ms)
disql V8
SQL> select * from v$version;
LINEID BANNER
---------- ---------------------------------
1 DM Database Server 64 V8
2 DB Version: 0x7000c
3 03134284094-20231109-208042-20067
或
SQL> select svr_version,db_version,build_version from v$instance;
LINEID svr_version db_version build_version
---------- -------------------------- ------------------- -----------------------------------
1 DM Database Server x64 V8 DB Version: 0x7000c 1-3-62-2023.11.09-208042-20067-ENT
前台启动详细过程:
[dmdba@localhost dmdbms]$ bin/dmserver /dmdb8/dmdata/fuwa/dm.ini
file dm.key not found, use default license!
version info: develop
DM Database Server 64 V8 03134284094-20231109-208042-20067 startup... ##日期已变
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
Database mode = 0, oguid = 0
License will expire on 2024-11-09
file lsn: 40003
ndct db load finished, code:0
ndct second level fill fast pool finished
ndct third level fill fast pool finished
ndct second level fill fast pool finished
ndct third level fill fast pool finished
ndct fill fast pool finished
pseg_set_gtv_trxid_low next_trxid in mem:[10025]
pseg_collect_mgr_items, total collect 0 active_trxs, 0 cmt_trxs, 0 pre_cmt_trxs, 0 to_release_trxs, 0 active_pages, 0 cmt_pages, 0 pre_cmt_pages, 0 to_release_pages, 0 mgr pages, 0 mgr recs!
next_trxid in mem:[12027]
next_trxid = 14029.
pseg recv finished
nsvr_startup end.
uthr_pipe_create, create pipe[read:12, write:13]
uthr_pipe_create, create pipe[read:14, write:15]
uthr_pipe_create, create pipe[read:16, write:17]
uthr_pipe_create, create pipe[read:18, write:19]
uthr_pipe_create, create pipe[read:20, write:21]
uthr_pipe_create, create pipe[read:22, write:23]
uthr_pipe_create, create pipe[read:24, write:25]
uthr_pipe_create, create pipe[read:26, write:27]
uthr_pipe_create, create pipe[read:28, write:29]
uthr_pipe_create, create pipe[read:30, write:31]
uthr_pipe_create, create pipe[read:32, write:33]
uthr_pipe_create, create pipe[read:34, write:35]
uthr_pipe_create, create pipe[read:36, write:37]
uthr_pipe_create, create pipe[read:38, write:39]
uthr_pipe_create, create pipe[read:40, write:41]
uthr_pipe_create, create pipe[read:42, write:43]
aud sys init success.
aud rt sys init success.
systables desc init success.
ndct_db_load_info finished, code:0.
nsvr_process_before_open begin.
nsvr_process_before_open success.
SYSTEM IS READY.
--后台启动数据库
[dmdba@localhost ~]$ /dmdb8/dmdbms/bin/DmServicefuwa start
数据库版本升级完成
这种方式相对前面2种,最为安全,出现错误的几率也小,但是迁移数据比较耗费时间,在数据量比较大的情况下,不推荐使用这种方式。迁移方式有:
新建工程qianyi–>新建迁移test–>选择迁移方式–>配置数据源–>配置目标–>迁移选项–>指定模式–>指定对象–>审阅迁移任务–>完成
导出数据库的所有对象 (FULL=Y),导出文件为 dexp01.dmp ,导出日志为 dexp01.log,导出文件和日志文件都存放在/dmdb8/dmexp 目录中。
dexp sysdba/sysdba@localhost:5237 file=fuwa_`date +%F`.dmp log=fuwa_exp_`date +%F`.log directory=/dmdb8/dmexp/ full=y
##若使用加密参数对备份进行加密,可使用加密参数 ENCRYPT、ENCRYPT_PASSWORD、ENCRYPT_NAME 。
##具体使用方法如下:
./dexp SYSDBA/[email protected]:5236 FILE=dexp03.dmp LOG=dexp03.log DIRECTORY=/emc_2/data/dexp FULL=Y ENCRYPT=Y ENCRYPT_PASSWORD=damengren ENCRYPT_NAME= DES_CBC
##导出数据库的所有对象 (FULL=Y),导出文件为 dexp03.dmp,导出日志为 dexp03.log,导出文件和日志文件都存放在 /dmdb8/dmexp 目录中。
##将逻辑备份采用 FULL 方式完全导入到用户名和密码为 SYSDBA,IP 地址为 192.168.183.107,端口号为 5237 的数据库。导入文件名为 fuwa_2023-11-25.dmp,导入的日志文件名为 db_str.log,路径为/dmdb8/dmexp
dimp USERID=SYSDBA/[email protected]:5237 FILE=fuwa_2023-11-25.dmp DIRECTORY=/dmdb8/dmexp LOG=db_fuwa_imp_`date +%F`.log FULL=Y
或
##参数文件
cat > /dmdb8/dimp.txt << "EOF"
USERID=SYSDBA/[email protected]:5237
FILE=fuwa_2023-11-25.dmp
LOG=db_fuwa_imp_`date +%F`.log
DIRECTORY=/dmdb8/dmexp
FULL=Y
EOF
dimp PARAMETER=/dmdb8/dimp.txt
--查看版本
[dmdba@localhost ~]$ /dmdb8/dmdbms/bin/disql SYSDBA:5237
SQL> select * from v$version;
LINEID BANNER
---------- ---------------------------------
1 DM Database Server 64 V8
2 DB Version: 0x7000c
3 03134284094-20231109-208042-20067 #着重看该值
或
SQL> select svr_version,db_version,build_version from v$instance;
LINEID svr_version db_version build_version
---------- -------------------------- ------------------- -----------------------------------
1 DM Database Server x64 V8 DB Version: 0x7000c 1-3-62-2023.11.09-208042-20067-ENT
--查进程(确认正在用的数据库安装目录和数据目录位置,避免多个目录混淆)
[dmdba@localhost ~]$ ps -ef | grep dm
....
dmdba 941 1 0 13:19 ? 00:00:00 /dmdb8/dmdbms/bin/dmap
dmdba 971 1 0 07:46 ? 00:00:08 /dmdb8/dmdbms/bin/dmserver path=/dmdb8/dmdata/fuwa/dm.ini -noconsole
dmdba 5142 1360 0 09:22 pts/1 00:00:00 grep --color=auto dmserver
...
--停止进程
su - root
systemctl stop DmAPService
systemctl stop DmServicefuwa
--再次确认服务已停止
[dmdba@localhost ~]$ ps -ef | grep dm
dmdba 5268 1360 0 09:23 pts/1 00:00:00 grep --color=auto dmserver
--备份新bin
[dmdba@localhost ~]$ cd /dmdb8/dmdbms/
[dmdba@localhost dmdbms]$ mv bin bin_newbak_2023-11-27
--复原旧bin
[dmdba@localhost dmdbms]$ mv bin_bak_2023-11-27 bin
--备份新dmarch
[dmdba@localhost dmdbms]$ cd /dmdb8/
[dmdba@localhost dmdbms]$ mv bin bin_newbak_2023-11-27
[dmdba@localhost dmdb8]$ ls
--复原旧dmarch
[dmdba@localhost dmdb8]$ mv dmarch_bak_2023-11-27 dmarch
[dmdba@localhost dmdb8]$ ls
--数据库参数CHECK_SVR_VERSION调整为0
[dmdba@localhost dmtmp]$ vi /dmdb8/dmdata/fuwa/dm.ini
CHECK_SVR_VERSION = 1 改为0
--启动数据库
su - root
systemctl start DmAPService
systemctl start DmServicefuwa
--查看版本
[dmdba@localhost dmtmp]$ /dmdb8/dmdbms/bin/disql SYSDBA:5237
SQL> select * from v$version;
LINEID BANNER
---------- ---------------------------------
1 DM Database Server 64 V8
2 DB Version: 0x7000c
3 03134284044-20230417-187846-20040 #着重看该值
或
SQL> select svr_version,db_version,build_version from v$instance;
LINEID svr_version db_version build_version
---------- -------------------------- ------------------- -----------------------------------
1 DM Database Server x64 V8 DB Version: 0x7000c 1-3-12-2023.04.17-187846-20040-ENT
--问题描述:升级回退后启动数据库报错
[root@localhost dmdbms]# systemctl start DmServicefuwa.service
Job for DmServicefuwa.service failed because the control process exited with error code. See "systemctl status DmServicefuwa.service" and "journalctl -xe" for details.
[root@localhost dmdbms]# cd /dmdb8/dmdbms/log/
[root@localhost log]# tail -200f dm_FUWA_202311.log
2023-11-27 14:03:54.974 [INFO] database P0000008072 T0000000000000008072 ndct_db_load_info success.
2023-11-27 14:03:54.974 [INFO] database P0000008072 T0000000000000008072 nsvr_process_before_open begin.
2023-11-27 14:03:54.974 [INFO] database P0000008072 T0000000000000008072 Update DM8_DCT_VERSION from 79 to 68, rebuild dynamic tables begin...
2023-11-27 14:03:54.975 [WARNING] database P0000008072 T0000000000000008072 Server DM8_DCT_VERSION mismatch, version of data is 79, server version is 68.
2023-11-27 14:03:54.975 [ERROR] database P0000008072 T0000000000000008072 Please use the correct version of server or set the CHECK_SVR_VERSION=0 in dm.ini
2023-11-27 14:03:54.975 [FATAL] database P0000008072 T0000000000000008072 [for dem]SYSTEM SHUTDOWN ABORT.
2023-11-27 14:03:54.975 [FATAL] database P0000008072 T0000000000000008072 alter database open; nsvr_check_version failed
2023-11-27 14:03:54.975 [FATAL] database P0000008072 T0000000000000008072 code = -109, dm_sys_halt now!!!
2023-11-27 14:03:54.975 [INFO] database P0000008072 T0000000000000008072 total 2 rfil opened!
解决办法
--数据库参数CHECK_SVR_VERSION调整为0
[dmdba@localhost dmtmp]$ vi /dmdb8/dmdata/fuwa/dm.ini
CHECK_SVR_VERSION = 1 改为0
启动数据库
[root@localhost log]# systemctl start DmServicefuwa
启动成功
补充:CHECK_SVR_VERSION参数说明
缺省值: 1
属性: 静态
说明: 数据库记录的执行码版本比当前 SERVER 版本高时,是否报错。0:不报错;1:报错,服务
器不能启动成功
降级完成
参考链接:https://blog.csdn.net/qq_39181479/article/details/125789501
新建工程qianyi–>新建迁移test–>选择迁移方式–>配置数据源–>配置目标–>迁移选项–>指定模式–>指定对象–>审阅迁移任务–>完成
导出数据库的所有对象 (FULL=Y),导出文件为 dexp01.dmp ,导出日志为 dexp01.log,导出文件和日志文件都存放在/dmdb8/dmexp 目录中。
dexp sysdba/sysdba@localhost:5237 file=fuwa_`date +%F`.dmp log=fuwa_exp_`date +%F`.log directory=/dmdb8/dmexp/ full=y
##若使用加密参数对备份进行加密,可使用加密参数 ENCRYPT、ENCRYPT_PASSWORD、ENCRYPT_NAME 。
##具体使用方法如下:
./dexp SYSDBA/[email protected]:5236 FILE=dexp03.dmp LOG=dexp03.log DIRECTORY=/emc_2/data/dexp FULL=Y ENCRYPT=Y ENCRYPT_PASSWORD=damengren ENCRYPT_NAME= DES_CBC
##导出数据库的所有对象 (FULL=Y),导出文件为 dexp03.dmp,导出日志为 dexp03.log,导出文件和日志文件都存放在 /dmdb8/dmexp 目录中。
##将逻辑备份采用 FULL 方式完全导入到用户名和密码为 SYSDBA,IP 地址为 192.168.183.107,端口号为 5237 的数据库。导入文件名为 fuwa_2023-11-25.dmp,导入的日志文件名为 db_str.log,路径为/dmdb8/dmexp
dimp USERID=SYSDBA/[email protected]:5237 FILE=fuwa_2023-11-25.dmp DIRECTORY=/dmdb8/dmexp LOG=db_fuwa_imp_`date +%F`.log FULL=Y
或
##参数文件
cat > /dmdb8/dimp.txt << "EOF"
USERID=SYSDBA/[email protected]:5237
FILE=fuwa_2023-11-25.dmp
LOG=db_fuwa_imp_`date +%F`.log
DIRECTORY=/dmdb8/dmexp
FULL=Y
EOF
dimp PARAMETER=/dmdb8/dimp.txt