本站总访问量 达梦数据库搭建 - Jerry的小站

Jerry Gao

上帝就是真理,真理就是上帝

国产数据库,由武汉达梦数据库股份有限公司研发。

  • 支持自动故障切换
  • 支持事务级读写负载分离
  • 支持读写分配比例可调整
  • 读多写少业务场景下的性能近线性提升

选择镜像

1
docker pull dm8_single:v8.1.2.128_ent_x86_64_ctm_pack4

Kubernetes 部署

service和pvc都以部署在Google Cloud的Kubernetes平台为例

  1. 创建PVC
1
2
3
4
5
6
7
8
9
10
11
12
13
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: dm-data
namespace: stable-db
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
storageClassName: standard-rwo
volumeMode: Filesystem
  1. 创建StatefulSet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: dm
namespace: stable-db
labels:
app: dm
spec:
replicas: 1
selector:
matchLabels:
app: dm
template:
metadata:
labels:
app: dm
spec:
volumes:
- name: dm-data
persistentVolumeClaim:
claimName: dm-data
containers:
- name: dm
image: dm8_single:v8.1.2.128_ent_x86_64_ctm_pack4
ports:
- name: tcp-5236
containerPort: 5236
protocol: TCP
env:
- name: PAGE_SIZE
value: '16'
- name: LD_LIBRARY_PATH
value: /opt/dmdbms/bin
- name: INSTANCE_NAME
value: dm8_01
resources:
limits:
cpu: "1"
memory: 2Gi
ephemeral-storage: 10Gi
requests:
cpu: "1"
memory: 2Gi
ephemeral-storage: 10Gi
volumeMounts:
- name: dm-data
mountPath: /opt/dmdbms/data
livenessProbe:
tcpSocket:
port: 5236
initialDelaySeconds: 10
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
readinessProbe:
tcpSocket:
port: 5236
initialDelaySeconds: 10
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
startupProbe:
tcpSocket:
port: 5236
initialDelaySeconds: 10
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
  • PAGE_SIZE:数据库页大小,单位KB,取值范围为4-64,建议取值16
  • INSTANCE_NAME:数据库实例名,建议取值dm8_01
  • LD_LIBRARY_PATH:库文件路径,固定值/opt/dmdbms/bin
  • mountPath:数据库数据文件路径,固定值/opt/dmdbms/data
  • tcp-5236:数据库端口,固定值5236
  1. 创建Service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
apiVersion: v1
kind: Service
metadata:
name: dm
namespace: stable-db
annotations:
cloud.google.com/l4-rbs: "enabled"
labels:
app: dm
spec:
loadBalancerIP: <your-ip>
type: LoadBalancer
externalTrafficPolicy: Cluster
ports:
- port: <your-port>
nodePort: <your-port>
targetPort: 5236
protocol: TCP
selector:
app: dm

docker-compose 部署

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
version: '3.0'
services:
dm:
image: ghcr.io/tapdata/dm8_single:v8.1.2.128_ent_x86_64_ctm_pack4
restart: always
ports:
- "5236:5236"
environment:
- PAGE_SIZE=16
- LD_LIBRARY_PATH=/opt/dmdbms/bin
- INSTANCE_NAME=dm8_01
deploy:
resources:
limits:
cpus: "1"
memory: 2G
reservations:
cpus: "1"
memory: 2G
volumes:
- /data/dm:/opt/dmdbms/data

连接测试

评论