最近参加了达梦数据库的培训,由于是MacOS系统使用docker安装踩了一些坑,在这里记录一下,希望能对大家有所帮助。
达梦数据库是纯国产新一代大型通用关系型数据库,全面支持 ANSI SQL 标准和主流编程语言接口/开发框架。行列融合存储技术,在兼顾 OLAP 和 OLTP 的同时,满足 HTAP 混合应用场景。
下面是安装步骤:
1.下载安装包
到官方网站上下载相应的安装包。
2.执行下面命令,将安装文件映射进系统并安装centos7环境
docker run -itd --name dm8 --privileged=true -p 5236:5236 -v /Users/zdm/Downloads/dm8_20210712_x86_rh6_64_ent/dm8_20210712_x86_rh6_64_ent_8.1.2.38_pack1.iso:/usr/dm8.iso centos:7 /usr/sbin/init
解释一下这段命令
--name docker容器对应的名称
-p 映射端口
--privileged=true privileged启动的容器,可以看到很多host上的设备,并 且可以执行mount。
-v 安装包本地路径
:/usr/dm8.iso 容器路径
centos:7 安装环境
/usr/sbin/init shell 授权(很重要)
3.使用docker ps查看启动的容器
docker ps
4.通过已设置的容器name进入容器内
docker exec -it dm8 bash
5.开始安装达梦数据库
添加达梦数据库安装用户组和用户
groupadd dinstall
useradd -g dinstall -m -d /home/dmdba -s /bin/bash dmdba
准备安装目录并授权
mkdir /dm8
chown dmdba:dinstall /dm8
挂载安装的ISO镜像文件
mkdir /mnt/dm
mount /usr/dm8.iso /mnt/dm
下面是执行以上命令的过程:
MacBook-Pro:~ zdm$ docker run -itd --name dm8 --privileged=true -p 5236:5236 -v /Users/zdm/Downloads/dm8_20210712_x86_rh6_64_ent/dm8_20210712_x86_rh6_64_ent_8.1.2.38_pack1.iso:/usr/dm8.iso centos:7 /usr/sbin/init
8b90a2a7e06dc492917473fede579e05af5eea06473e0276aa78e9a70fbf2cc7
MacBook-Pro:~ zdm$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8b90a2a7e06d centos:7 "/usr/sbin/init" 10 seconds ago Up 9 seconds 0.0.0.0:5236->5236/tcp dm8
MacBook-Pro:~ zdm$ docker exec -it dm8 bash
[root@8b90a2a7e06d /]# groupadd dinstall
[root@8b90a2a7e06d /]# useradd -g dinstall -m -d /home/dmdba -s /bin/bash dmdba
[root@8b90a2a7e06d /]# mkdir /dm8
[root@8b90a2a7e06d /]# chown dmdba:dinstall /dm8
[root@8b90a2a7e06d /]# mkdir /mnt/dm
[root@8b90a2a7e06d /]# mount /usr/dm8.iso /mnt/dm
mount: /dev/loop0 is write-protected, mounting read-only
[root@8b90a2a7e06d /]# cd /mnt/dm
[root@8b90a2a7e06d dm]# ll
total 743807
-r-xr-xr-x 1 root root 2783507 Jul 11 2021 DM8 Install.pdf
-r-xr-xr-x 1 root root 758874391 Jul 11 2021 DMInstall.bin
[root@8b90a2a7e06d dm]# ./DMInstall.bin -i
进入安装包目录
cd /mnt/dm
执行安装文件
./DMInstall.bin -i
安装过程如下:
[root@8b90a2a7e06d dm]# ./DMInstall.bin -i
Please select the installer's language (E/e:English C/c:Chinese) [E/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]: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 [13]:21
Installation Type:
1 Typical
2 Server
3 Client
4 Custom
Please Input the number of the Installation Type [1 Typical]:1
Require Space: 1181M
Please Input the install path [/opt/dmdbms]:/dm8
Available Space:51G
Please Confirm the install path(/dm8)? (Y/y:Yes N/n:No) [Y/y]:y
Pre-Installation Summary
Installation Location: /dm8
Require Space: 1181M
Available Space: 51G
Version Information:
Expire Date:
Installation Type: Typical
Confirm to Install? (Y/y:Yes N/n:No):y
2022-03-28 09:07:32
[INFO] Installing DM DBMS...
2022-03-28 09:07:33
[INFO] Installing BASE Module...
2022-03-28 09:07:35
[INFO] Installing SERVER Module...
2022-03-28 09:07:35
[INFO] Installing CLIENT Module...
2022-03-28 09:07:37
[INFO] Installing DRIVERS Module...
2022-03-28 09:07:37
[INFO] Installing MANUAL Module...
2022-03-28 09:07:38
[INFO] Installing SERVICE Module...
2022-03-28 09:07:39
[INFO] Move log file to log directory.
2022-03-28 09:07:39
[INFO] Change the power of installtion directory successfully.
2022-03-28 09:07:40
[INFO] Starting DmAPService service...
2022-03-28 09:07:40
[INFO] Installed DM DBMS completely.
End
安装完毕,是不是很简单。
6.cd /dm8/bin目录下创建数据库实例
./dminit
执行过程如下:
[root@ff72f9aa12e1 dm]# cd /dm8/bin
[root@ff72f9aa12e1 bin]# ./dminit
initdb V8
db version: 0x7000c
file dm.key not found, use default license!
License will expire on 2022-07-09
input system dir: /dm8/data
input db name: DM
input port num: 5236
input page size(4, 8, 16, 32): 16
input extent size(16, 32, 64): 32
input sec priv mode(0, 1, 2): 0
input time zone(-12:59,+14:00): +8
string case sensitive? ([Y]es, [N]o): y
which charset to use? (0[GB18030], 1[UTF-8], 2[EUC-KR]): 1
length in char? ([Y]es, [N]o): y
enable database encrypt? ([Y]es, [N]o): n
input slice size(0, 512, 4096): 512
page check mode? (0/1/2): 0
input elog path: /dm8/data
only create huge table with delta? (0/1): 0
rlog generate for huge? (0/1): 0
pseg_mgr_flag (0/1): 0
auto_overwrite mode? (0/1/2): 0
CHARACTER type fixed storage ? ([Y]es/1, [N]o/0): 0
SQL log forbid ? ([Y]es/1, [N]o/0): 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
log file path: /dm8/data/DM/DM01.log
log file path: /dm8/data/DM/DM02.log
write to dir [/dm8/data/DM].
create dm database success. 2022-03-28 11:37:42
7.cd dm8/script/root目录下注册数据库服务
./dm_service_installer.sh -t dmserver -p DMSVR -dm_ini /dm8/data/DM/dm.ini
执行过程如下:
[root@ff72f9aa12e1 root]# ./dm_service_installer.sh -t dmserver -p DMSVR -dm_ini /dm8/data/DM/dm.ini
Finished to create the service (DmServiceDMSVR)
8.dm8/bin 目录下启动数据库
./DmServiceDMSVR start
执行会花一定时间,执行完毕显示状态[OK]
[root@ff72f9aa12e1 root]# cd /dm8/bin
[root@ff72f9aa12e1 bin]# ./DmServiceDMSVR start
Starting DmServiceDMSVR: [ OK ]
9.cd /dm8/bin目录下连接数据库
./disql sysdba/SYSDBA:5236
连接成功!
[root@ff72f9aa12e1 bin]# ./disql sysdba/SYSDBA:5236
Server[LOCALHOST:5236]:mode is normal, state is open
login used time : 3.838(ms)
disql V8
SQL>
接下来可以使用命令行进行操作或者用第三方软件进行操作。
我使用了DBeaver创建了连接进行操作,下面是步骤:
1.docker启动达梦数据库;
[root@ff72f9aa12e1 root]# cd /dm8/bin
[root@ff72f9aa12e1 bin]# ./DmServiceDMSVR start
Starting DmServiceDMSVR: [ OK ]
2.配置DBeaver连接,编辑驱动
DBeaver的连接创建好了,可以进行数据库操作了。