以下内容均来自个人笔记并重新梳理,如有错误欢迎指正!
如果对您有帮助,烦请点赞、关注、转发!如果您有其他想要了解的,欢迎私信联系我~
背景介绍
近期,团队研发同学向笔者提出搭建达梦数据库以进行适配的需求,笔者完成调研后着手搭建了一套测试环境,本文详细介绍达梦数据库的搭建步骤。
搭建过程
X86_64 架构的服务器 1 台,并安装 Docker 19.03.14 版本。
2、准备工作
# 下载镜像
wget https://download.dameng.com/eco/dm8/dm8_20230808_rev197096_x86_rh6_64_single.tar
# 导入镜像
docker load -i dm8_20230808_rev197096_x86_rh6_64_single.tar
# 查看镜像
docker images | grep dm8
# 创建数据目录
mkdir /data/dm8
3、运行容器
docker run -d \
-p 5236:5236 \
--restart=always \
--name dm8 \
--privileged=true \
-e PAGE_SIZE=16 \
-e LD_LIBRARY_PATH=/opt/dmdbms/bin \
-e EXTENT_SIZE=32 \
-e BLANK_PAD_MODE=1 \
-e LOG_SIZE=1024 \
-e UNICODE_FLAG=1 \
-e LENGTH_IN_CHAR=1 \
-e INSTANCE_NAME=dm8 \
-v /data/dm8:/opt/dmdbms/data \
dm8_single:dm8_20230808_rev197096_x86_rh6_64
🔔 页大小 (PAGE_SIZE)、簇大小 (EXTENT_SIZE)、大小写敏感 (CASE_SENSITIVE)、字符集 (UNICODE_FLAG) 、VARCHAR 类型以字符为单位 (LENGTH_IN_CHAR)、空格填充模式 (BLANK_PAD_MODE) 、页检查模式(PAGE CHECK) 等部分参数,一旦确定无法修改,在初始化实例时确认需求后谨慎设置!!
docker ps -a | grep dm8
4、等待就绪
docker logs -f dm8
# 显示如下内容时服务就绪
file dm.key not found, use default license!
License will expire in 14 day(s) on 2024-04-25
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
log file path: /opt/dmdbms/data/DAMENG/DAMENG01.log
log file path: /opt/dmdbms/data/DAMENG/DAMENG02.log
write to dir [/opt/dmdbms/data/DAMENG].
create dm database success. 2024-04-11 16:28:00
initdb V8
db version: 0x7000c
Init DM success!
Start DmAPService...
Starting DmAPService: [ OK ]
/opt/dmdbms/conf/dm.ini does not exist, use default dm.ini
Start DMSERVER success!
Dmserver is running.
DM Database is not OK, please wait...
DM Database is OK
Finished soft link DM current dm_DMSERVER_202404.log to dm_DMSERVER.log
* Starting periodic command scheduler cron
...done.
2024-04-11 16:28:20.450 [INFO] database P0000000047 T0000000000000000092 total 0 active crash trx, pseg_crash_trx_rollbacksys_only(0) begin ...
2024-04-11 16:28:20.450 [INFO] database P0000000047 T0000000000000000092 pseg_crash_trx_rollback end, total 0 active crash trx, include 0 empty_trxs, 0 empty_pages which only need to delete mgr recs.
2024-04-11 16:28:20.450 [INFO] database P0000000047 T0000000000000000092 pseg_crash_trx_rollback end
2024-04-11 16:28:20.450 [INFO] database P0000000047 T0000000000000000092 hpc_clear_active_trx adjust n_crash_active_trx from 0 to 0.
2024-04-11 16:28:20.451 [INFO] database P0000000047 T0000000000000000047 backup control file /opt/dmdbms/data/DAMENG/dm.ctl to file /opt/dmdbms/data/DAMENG/dm_20240411162820_450967.ctl
2024-04-11 16:28:20.452 [INFO] database P0000000047 T0000000000000000047 backup control file /opt/dmdbms/data/DAMENG/dm.ctl to file /opt/dmdbms/data/DAMENG/ctl_bak/dm_20240411162820_451609.ctl succeed
2024-04-11 16:28:20.452 [INFO] database P0000000047 T0000000000000000047 local instance name is DMSERVER, mode is NORMAL, status is OPEN.
2024-04-11 16:28:20.452 [INFO] database P0000000047 T0000000000000000047 SYSTEM IS READY.
2024-04-11 16:28:20.452 [INFO] database P0000000047 T0000000000000000047 set g_dw_stat from UNDEFINED to NONE success, g_dw_recover_stop is 0
2024-04-11 16:28:21.450 [INFO] database P0000000047 T0000000000000000094 trx4_min_tid_collect set min_active_id_opt, min_active_id: 3643, first_tid: 3006
2024-04-11 16:30:06.671 [INFO] database P0000000047 T0000000000000000158 socket_err_should_retry errno:104
5、登录数据库
docker exec -it dm8 bash
./opt/dmdbms/bin/disql SYSDBA/SYSDBA001:5236
# 使用默认的用户名、密码,登录数据库后显示如下:
Server[LOCALHOST:5236]:mode is normal, state is open
login used time : 2.315(ms)
disql V8
SQL>
附录
技术文档:快速上手 | 达梦技术文档
安装文档:Docker 安装 | 达梦技术文档
下载地址:Docker 安装包