Kubernetes 部署
service和pvc都以部署在Google Cloud的Kubernetes平台为例
- 创建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
|
- 创建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
- 创建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
|