本地虚拟机centos7安装达梦8数据库
在产品下载 | 达梦数据库可以下载docker文件
如下:dm8_20240715_x86_rh6_rq_single.tar文件
在linux可以
[root@localhost dm8]# docker load -i dm8_20240715_x86_rh6_rq_single.tar
4a1518ebc26e: Loading layer [==================================================>] 75.19 MB/75.19 MB
b8a4238f8cd3: Loading layer [==================================================>] 16.14 MB/16.14 MB
78f411f0a3f4: Loading layer [==================================================>] 16.87 MB/16.87 MB
ee7e3338d636: Loading layer [==================================================>] 1.185 MB/1.185 MB
ad2c3a0ea0ae: Loading layer [==================================================>] 354.8 kB/354.8 kB
f238a8da5f88: Loading layer [==================================================>] 1.035 GB/1.035 GB
29bea1477fed: Loading layer [==================================================>] 5.12 kB/5.12 kB
d9d4efb7df38: Loading layer [==================================================>] 4.608 kB/4.608 kB
a4d32f2d669a: Loading layer [==================================================>] 3.072 kB/3.072 kB
407cb6f411e4: Loading layer [==================================================>] 2.56 kB/2.56 kB
27fc5e1a3138: Loading layer [==================================================>] 2.56 kB/2.56 kB
b17f6a378f4d: Loading layer [==================================================>] 4.096 kB/4.096 kB
80c94e424fcb: Loading layer [==================================================>] 4.096 kB/4.096 kB
Loaded image: dm8_single:dm8_20240715_rev232765_x86_rh6_64
安装好后可以用docker images看到
[root@localhost dm8]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
dm8_single dm8_20240715_rev232765_x86_rh6_64 0880e3256f92 8 weeks ago 1.14 GB
registry.cn-shanghai.aliyuncs.com/primeton-pub/eoslowcode 8.3.0 c83d3e13d0fd 5 months ago 1.26 GB
docker.io/xuxueli/xxl-job-admin 2.4.0 add65eeff2e1 17 months ago 235 MB
docker.io/redis 3.2 87856cc39862 5 years ago 76 MB
docker.io/mysql 5.7.21 5195076672a7 6 years ago 371 MB
同时按照下面运行
[root@localhost dm8]# docker run -d -p 5236:5236 --name dm8 --privileged=true \
> -e PAGE_SIZE=16 \
> -e LD_LIBRARY_PATH=/opt/dmdbms/bin \
> -e CASE_SENSITIVE=0 \
> -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 /home/mydata/dm8:/opt/dmdbms/data dm8_single:dm8_20240715_rev232765_x86_rh6_64
63161e1b396ca333996f40e9cddf2319d204512f493cde7489e080af8881865e
使用 -e 命令指定数据库初始化参数时,需要注意的是 页大小 (page_size)、簇大小 (extent_size)、大小写敏感 (case_sensitive,为0表示不敏感)、字符集 (UNICODE_FLAG) 、VARCHAR 类型以字符为单位 (LENGTH_IN_CHAR)、空格填充模式 (BLANK_PAD_MODE) 、页检查模式(PAGE CHECK) 等部分参数
注意
1.如果使用 docker 容器里面的 disql,进入容器后,先执行 source /etc/profile 防止中文乱码。
2.新版本 Docker 镜像中数据库默认用户名/密码为 SYSDBA/SYSDBA001。
可以使用 docker inspect dm8 看ENV模块的密码
可以看运行日志,如下,这样就成功了。
[root@localhost dm8]# docker logs dm8
Script start.
length_in_char is no longer supported in this version, and this setting will not take effect.
file dm.key not found, use default license!
License will expire on 2025-06-21
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLLlog file path: /opt/dmdbms/data/DAMENG/DAMENG01.loglog file path: /opt/dmdbms/data/DAMENG/DAMENG02.log
write to dir [/opt/dmdbms/data/DAMENG].
create dm database success. 2024-09-13 05:44:13
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 not OK, please wait...
DM Database is not OK, please wait...
DM Database is not OK, please wait...
DM Database is OK
Start DMSERVER success!
Dmserver is running.
DM Database is OK
Finished soft link DM current dm_DM8_202409.log to dm_DMSERVER.log
2024-09-13 05:45:14.820 [INFO] database P0000000146 T0000000000000000339 dthrd_info_add nth:146, dthrd_info:0x7fc8472ede40, thrd_name:dm_lsnr_thd
2024-09-13 05:45:14.820 [INFO] database P0000000146 T0000000000000000337 dthrd_info_add nth:144, dthrd_info:0x7fc8474efe40, thrd_name:nlgn_task_thread
2024-09-13 05:45:14.820 [INFO] database P0000000146 T0000000000000000146 backup control file /opt/dmdbms/data/DAMENG/dm.ctl to file /opt/dmdbms/data/DAMENG/ctl_bak/dm_20240913054514_820218.ctl succeed
2024-09-13 05:45:14.820 [INFO] database P0000000146 T0000000000000000146 local instance name is DM8, mode is NORMAL, status is OPEN.
2024-09-13 05:45:14.820 [INFO] database P0000000146 T0000000000000000146 SYSTEM IS READY.
2024-09-13 05:45:14.820 [INFO] database P0000000146 T0000000000000000146 [for dem]SYSTEM IS READY.
2024-09-13 05:45:14.820 [INFO] database P0000000146 T0000000000000000146 set g_dw_stat from UNDEFINED to NONE success, g_dw_recover_stop is 0
2024-09-13 05:45:15.821 [INFO] database P0000000146 T0000000000000000215 trx4_min_tid_collect set min_active_id_opt, min_active_id: 6753, first_tid: 6006
2024-09-13 05:45:20.293 [INFO] database P0000000146 T0000000000000000351 dthrd_info_add nth:158, dthrd_info:0x7fc8471ece40, thrd_name:dm_sql_thd
2024-09-13 05:45:20.340 [INFO] database P0000000146 T0000000000000000371 dthrd_info_add nth:178, dthrd_info:0x7fc8471ece40, thrd_name:dm_sql_thd
通过下面方式可以测试数据库是否可以正常连接
[root@localhost dm8]# docker exec -it dm8 /bin/bash
root@63161e1b396c:/# cd /opt/dmdbms/bin
root@63161e1b396c:/opt/dmdbms/bin# ^C
root@63161e1b396c:/opt/dmdbms/bin# ./disql SYSDBA/SYSDBA001@192.168.199.151:5236
[-70028]:Create SOCKET connection failure.
disql V8
username:SYSDBA
password:Server[LOCALHOST:5236]:mode is normal, state is open
login used time : 5.432(ms)
SQL>
常用的一些命令如下:
6.常用命令
创建表空间 OA,文件为 OA.DBF,大小 128 MB
CREATE TABLESPACE OA DATAFILE 'OA.DBF' size 128;
创建用户 OA,密码 aaaaaaaaa,默认表空间和索引表空间均为
OA CREATE USER OA IDENTIFIED by aaaaaaaaa DEFAULT TABLESPACE OA DEFAULT INDEX TABLESPACE OA;
授权 VIT 权限给 OA GRANT VTI TO OA;
授权 PUBLIC 权限给 OA GRANT PUBLIC TO OA;
授权 RESOURCE 权限给 OA GRANT RESOURCE TO OA;
修改用户OA的密码为bbbbbbbbb ALTER USER OA IDENTIFIED BY bbbbbbbbb;
#查看达梦数据库运行状态
SELECT status$ as 状态 FROM v$instance;
#查看版本
SELECT banner as 版本信息 FROM v$version;
#使用 conn 命令切换用户。
conn DM/dameng123;
#使用 user 关键字返回当前登录用户。
SELECT user FROM DUAL;
#查看所有模式名
SELECT DISTINCT object_name FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'SCH';
#根据模式名查询表名
SELECT table_name FROM dba_tables WHERE owner = '模式名';
#根据模式和表名查询表字段
SELECT COLUMN_NAME FROM all_tab_columns WHERE onwer = '模式名' AND Table_Name = '表名';
可以考虑安装win的DM管理工具