Docker安装达梦数据库8

Docker安装达梦数据库8

软件版本

  • 数据库镜像,dm8_single:dm8_20230808_rev197096_x86_rh6_64,官网下载最新版,地址

  • Docker版本,Docker version 24.0.6, build ed223bc

  • 操作系统,Ubuntu 20.04

导入镜像

docker load -i dm8_20230808_rev197096_x86_rh6_64_single.tar

数据库实例参数

# 如果只有docker镜像,没有在物理机上安装数据库
docker run --rm -it dm8_single:dm8_20230808_rev197096_x86_rh6_64 bash
# 查看数据库实例创建参数
cd /opt/dmdbms/bin
./dminit help

initdb V8
db version: 0x7000c
file dm.key not found, use default license!
License will expire on 2024-07-26
version: 03134284058-20230726-197096-20046 Pack4
Format:  ./dminit         KEYWORD=value

Example: ./dminit         PATH=/public/dmdb/dmData PAGE_SIZE=16

Keyword                     Explanation(default value)
--------------------------------------------------------------------------------
INI_FILE                    dm.ini path
PATH                        database path
CTL_PATH                    control file path
LOG_PATH                    log file path
EXTENT_SIZE                 extent size of data file(16), optional value: 16, 32, 64, unit: PAGE
PAGE_SIZE                   page size(8), optional value: 4, 8, 16, 32, unit: K
LOG_SIZE                    log file size(256), unit: M, range: 256M ~ 8G
CASE_SENSITIVE              whether case is sensitive(Y), optional value: Y/N or 1/0
CHARSET/UNICODE_FLAG        CHARSET(0), optional value:0[GB18030],1[UTF-8],2[EUC-KR]
SEC_PRIV_MODE               security privilege mode(0), optional value£º0[TRADITION], 1[BMJ], 2[EVAL], 3[ZB]
LENGTH_IN_CHAR              whether LENGTH for VARCHAR is in characters(N), optional value: Y/N, 1/0
SYSDBA_PWD                  set SYSDBA password(SYSDBA)
SYSAUDITOR_PWD              set SYSAUDITOR password(SYSAUDITOR)
DB_NAME                     database name(DAMENG)
INSTANCE_NAME               instance name(DMSERVER)
PORT_NUM                    listener port(5236)
BUFFER                      System buffer size(100), unit: M
TIME_ZONE                   set time zone(+08:00)
PAGE_CHECK                  page check mode(3), optional value: 0/1/2/3
PAGE_HASH_NAME              set page check hash algorithm
EXTERNAL_CIPHER_NAME        set default encrypt/decrypt algorithm
EXTERNAL_HASH_NAME          set default hash algorithm
EXTERNAL_CRYPTO_NAME        set crypto name to encrypt svr key
RLOG_ENCRYPT_NAME           encrypt cipher name of redo log
RLOG_ENCRYPT_POSTFIX        Postfix name of redo log, max length is 10. Default name is log, e.g. DAMENG01.log
USBKEY_PIN                  set usbkey pin
PAGE_ENC_SLICE_SIZE         slice size for page encryption, optional value: 0, 512, 4096, unit: Byte
ENCRYPT_NAME                set algorithm for encrypt the whole database
BLANK_PAD_MODE              set blank padding mode(0), optional value:0/1
SYSTEM_MIRROR_PATH          mirror path of system data file
MAIN_MIRROR_PATH            mirror path of main file
ROLL_MIRROR_PATH            mirror path of roll file
MAL_FLAG                    MAL_INI flag(0) in dm.ini
ARCH_FLAG                   ARCH_INI(0) flag in dm.ini
MPP_FLAG                    MPP_INI(0) flag in dm.ini
CONTROL                     control file path!
AUTO_OVERWRITE              whether overwrite all files with the same name(0) 0: no 1: part 2: all
USE_NEW_HASH                whether use new hash algorithm for string. (default 1)
DCP_MODE                    whether is DM CLUSTER PROXY mode(default 0)
DCP_PORT_NUM                in DCP mode, set dcp_port_num
ELOG_PATH                   set the path of log file recording the contents during initialization
AP_PORT_NUM                 listener port for cooperative worker in distribution environment
DFS_FLAG                    DFS_INI flag(0) in dm.ini
DFS_PATH                    default path of db file when dfs_flag is true
DFS_HOST                    ip of ddfs(localhost)
DFS_PORT                    port number of ddfs(3332)
DFS_COPY_NUM                copy num of dfs file(3)
DFS_DB_NAME                 database name in ddfs(default same as DB_NAME)
SHARE_FLAG                  database share flag in ddfs(default 0)
REGION_MODE                 system tablespace datafile region policy in ddfs(default 0) 0: MICRO 1: GREAT
HUGE_WITH_DELTA             Only support to create with delta huge table(default 1) 1: YES  0: NO
RLOG_GEN_FOR_HUGE           whether to generate redo log for with delta huge table(default 1) 1: YES  0: NO
PSEG_MGR_FLAG               Only use manager segment to record trx info(default 0) 1: YES  0: NO
CHAR_FIX_STORAGE            whether CHARACTER type stored by fixed length(N), optional value: Y/N, 1/0
SQL_LOG_FORBID              whether forbid SQL log(N), optional value: Y/N, 1/0
DPC_MODE                    specify instance role in DPC cluster(default 0) 0: None 1: MP 2: BP 3: SP, value MP/BP/SP also works
HELP                        print help information

关注以下几个参数

  • EXTENT_SIZE,数据文件使用的簇大小,即每次分配新的段空间时连续的页数。只能是 16 页或 32 页或 64 页之一,缺省使用 16 页。
  • PAGE_SIZE,数据文件使用的页大小,可以为 4 KB、8 KB、16 KB 或 32 KB 之一,选择的页大小越大,则 DM 支持的元组长度也越大,但同时空间利用率可能下降,缺省使用 8 KB。
  • CASE_SENSITIVE,标识符大小写敏感,默认值为 Y 。当大小写敏感时,小写的标识符应用双引号括起,否则被转换为大写;当大小写不敏感时,系统不自动转换标识符的大小写,在标识符比较时也不区分大小写,只能是 Y、y、N、n、1、0 之一。
  • CHARSET/UNICODE_FLAG,字符集选项。0 代表 GB18030;1 代表 UTF-8;2 代表韩文字符集 EUC-KR;取值 0、1 或 2 之一。默认值为 0。
  • LENGTH_IN_CHAR,VARCHAR类型是否以字符为单位, 默认字节为单位,Y/N, 1/0。
  • SYSDBA_PWD,SYSDBA用户密码,默认为SYSDBA
  • SYSAUDITOR_PWD,SYSAUDITOR用户密码,默认为SYSAUDITOR
  • DB_NAME,数据库名,默认为DAMENG
  • INSTANCE_NAME,实例名,默认为DMSERVER
  • PORT_NUM,监听端口,默认5236

1.如果使用 docker 容器里面的 disql,进入容器后,先执行 source /etc/profile 防止中文乱码。
2.新版本 Docker 镜像中数据库默认用户名/密码为 SYSDBA/SYSDBA001。

启动数据库实例

所有的数据库实例配置参数以环境变量的方式传入

docker run -d -p 30236:5236 \
        --restart=always \
        --name dm8 \
        -e CASE_SENSITIVE=0 \
        -e PAGE_SIZE=16 \
        -e LD_LIBRARY_PATH='$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

查看启动日志

docker logs -f dm8
# 第一次启动会完成各种初始化工作
Script start.
file dm.key not found, use default license!
License will expire on 2024-07-26
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. 2023-09-22 11:42:41
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.
...

连接数据库

使用disql连接

docker exec -it dm8 bash
cd /opt/dmdbms/bin
./disql

root@4ef790864c50:/opt/dmdbms/bin# ./disql
disql V8
username:SYSDBA
password:

Server[LOCALHOST:5236]:mode is normal, state is open
login used time : 9.221(ms)

使用达梦管理工具连接

你可能感兴趣的:(数据库,国产化,docker,数据库,容器)