当前位置:网站首页>Cloud native essay using Hana expression database service on Google kubernetes cluster

Cloud native essay using Hana expression database service on Google kubernetes cluster

2022-06-26 09:53:00 51CTO

We know ,Cluster yes Google Kubernetes Engine ( abbreviation GKE) The basis of , Represents a container application Kubernetes Objects are running on the cluster .

Google Kubernetes Engine (GKE) Provides a managed environment , Developers can use Google Infrastructure on GKE Deployment in China 、 Management and expansion of containerized applications .GKE The environment includes multiple Compute Engine example , These instances are combined to form Google Kubernetes Cluster.
# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_Kubernetes

SAP HANA Expression yes SAP HANA Simplified version of , Designed for use on laptops and other mainframe computers ( Including cloud hosted virtual machines ) Up operation , Of course, it supports the Google Kubernetes Cluster Up operation . This version supports SAP HANA In addition to the traditional memory database function , Also provide bring-your-own-language And so on , Support microservices 、 Predictive analysis and machine learning algorithms , And geospatial processing for building insight driven applications .

# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_docker_02

This article will describe in detail how to Google Kubernetes Cluster Deploy and use HANA Expression Database Service.

stay Google Cloud Platform To create a Google Kubernetes Cluster example

Sign in Google Cloud Platform Console :

# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_Kubernetes_03

Click... In the upper left corner of the console Hamburger menu , Create a new Kubernetes Cluster:
# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_gcp_04

# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_ Command line _05

maintain Cluster The name of , Choose the right version , Click on Customize customize :
# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_ Command line _06

by Cluster Appoint CPU And memory parameters , selected Ubuntu As an operating system .Cluster The size of is set to 1.
# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_gcp_07

Cluster After creation and successful deployment , Click on Connect Button to connect .

# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_ Command line _08

After successful connection , You can use Cloud Shell Operate the cluster :
# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_docker_09

Cloud Shell The command line is provided in the same way as Cluster Interact .

# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_Kubernetes_10

stay Google Kubernetes Cluster Upper Department HANA Expression Database Service

Use the following command to create a secret In order to get Docker Mirror image :

kubectl create secret docker-registry docker-secret --docker-server=https://index.docker.io/v1/ --docker-username=xxx --docker-password=yyyyyy [email protected]

Create a yaml Deployment configuration file in (Deployment Configuration File), Save as hxe.yaml file :

kind: ConfigMap
apiVersion: v1
metadata:
  creationTimestamp: 2022-06-25T19:14:38Z
  name: hxe-pass
data:
  password.json: |+
    {"master_password" : "JERRYHana1"}
---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: persistent-vol-hxe
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 150Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/data/hxe_pv"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: hxe-pvc
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 50Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hxe
  labels:
    name: hxe
spec:
  selector:
    matchLabels:
      run: hxe
      app: hxe
      role: master
      tier: backend
  replicas: 1
  template:
    metadata:
      labels:
        run: hxe
        app: hxe
        role: master
        tier: backend
    spec:
      initContainers:
        - name: install
          image: busybox
          command: [ 'sh', '-c', 'chown 12000:79 /hana/mounts' ]
          volumeMounts:
            - name: hxe-data
              mountPath: /hana/mounts
      volumes:
        - name: hxe-data
          persistentVolumeClaim:
             claimName: hxe-pvc
        - name: hxe-config
          configMap:
             name: hxe-pass
      imagePullSecrets:
      - name: docker-secret
      containers:
      - name: hxe-container
        image: "store/saplabs/hanaexpress:2.00.030.00.20180403.2"
        ports:
          - containerPort: 39013
            name: port1
          - containerPort: 39015
            name: port2
          - containerPort: 39017
            name: port3
          - containerPort: 8090
            name: port4
          - containerPort: 39041
            name: port5
          - containerPort: 59013
            name: port6
        args: [ "--agree-to-sap-license", "--dont-check-system", "--passwords-url", "file:///hana/hxeconfig/password.json" ]
        volumeMounts:
          - name: hxe-data
            mountPath: /hana/mounts
          - name: hxe-config
            mountPath: /hana/hxeconfig
      - name: sqlpad-container
        image: "sqlpad/sqlpad"
        ports:
        - containerPort: 3000

---
apiVersion: v1
kind: Service
metadata:
  name: hxe-connect
  labels:
    app: hxe
spec:
  type: LoadBalancer
  ports:
  - port: 39013
    targetPort: 39013
    name: port1
  - port: 39015
    targetPort: 39015
    name: port2
  - port: 39017
    targetPort: 39017
    name: port3
  - port: 39041
    targetPort: 39041
    name: port5
  selector:
    app: hxe
---
apiVersion: v1
kind: Service
metadata:
  name: sqlpad
  labels:
    app: hxe
spec:
  type: LoadBalancer
  ports:
  - port: 3000
    targetPort: 3000
    protocol: TCP
    name: sqlpad
  selector:
    app: hxe

     
  • 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.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118.
  • 119.
  • 120.
  • 121.
  • 122.
  • 123.
  • 124.
  • 125.
  • 126.
  • 127.
  • 128.
  • 129.
  • 130.
  • 131.
  • 132.
  • 133.
  • 134.
  • 135.
  • 136.
  • 137.
  • 138.
  • 139.
  • 140.
  • 141.

This yaml The file defines a HANA Expression Of Docker Mirror image :store/saplabs/hanaexpress:2.00.030.00.20180403.2

Use the following command line to run this Docker Image deployment to Kubernetes Cluster On :

  • kubectl create -f hxe.yaml
  • kubectl describe pods

Wait for the deployment to complete successfully :

# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_docker_11

Execute the command line kubectl get pods, Make sure pod Status as Running, Then enter Pod Inside of container :

kubectl exec -it <<pod-name>> bash
# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_docker_12

You can use SQL Command line , The connection runs on Pod Inside HANA Expression The instance :

hdbsql -i 90 -d systemdb -u SYSTEM -p HXEHana1

Add... To the database document store Support for :
alter database HXE add 'docstore';

from SQLPAD service get external IP Address :

kubectl get services

# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_ Command line _13

With this externally accessible IP After the address , Visit its 3000 port , You can log in to the browser SQLPAD 了 :

# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_sql_14

Click on Sign In, Create a Administration account.

# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_docker_15

Use Connections menu , Connect HANA Expression Database tables in the instance :
# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_Kubernetes_16

from kubectl get services Found in the command line results list hxe-connect, Copy its External IP Address :

# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_docker_17

Create a new database connection , Maintain just copied External IP Address , Database user name and password ,Tenant Other login information :

# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_sql_18

After the database connection is established , You can create a new one Query, Read and write it .

# Cloud native essay # stay Google Kubernetes Cluster Upper use HANA Expression Database Service_Kubernetes_19

Create a name quotes Of document store, And insert some test data :

create collection quotes;
--Create a collection for document store and insert JSON values
insert into quotes values ( { "FROM" : 'HOMER',   "QUOTE" :  'I want to share something with you: The three little sentences that will get you through life. Number 1: Cover for me. Number 2: Oh, good idea, Boss! Number 3: It wai like that when I got here.', "MOES_BAR" : 'Point( -86.880306 36.508361 )', "QUOTE_ID" : 1  });
insert into quotes values ( { "FROM" : 'HOMER',   "QUOTE" :  'Wait a minute. Bart''s teacher is named Krabappel? Oh, I''ve been calling her Crandall. Why did not anyone tell me? Ohhh, I have been making an idiot out of myself!', "QUOTE_ID" : 2, "MOES_BAR" : 'Point( -87.182708 37.213414 )' });
insert into quotes values ( { "FROM" : 'HOMER',   "QUOTE" :  'Oh no! What have I done? I smashed open my little boy''s piggy bank, and for what? A few measly cents, not even enough to buy one beer. Weit a minute, lemme count and make sure…not even close.', "MOES_BAR" : 'Point( -122.400690 37.784366 )', "QUOTE_ID" : 3 });

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

Create a Column surface , Turn on Fuzzy Search Support for :

create column table quote_analysis
(
	id integer,
	homer_quote text FAST PREPROCESS ON FUZZY SEARCH INDEX ON,
	lon_lat nvarchar(200)

);

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

Insert into document store collection Copy the data to the above Column table :

insert into quote_analysis
with doc_store as (select quote_id, quote from quotes)
select doc_store.quote_id as id, doc_store.quote as homer_quote, 'Point( -122.676366 45.535889 )'
from doc_store;

     
  • 1.
  • 2.
  • 3.
  • 4.

Query and wait The word with the lowest similarity :

select  id, score() as similarity , lon_lat, TO_VARCHAR(HOMER_QUOTE)
from quote_analysis
where contains(HOMER_QUOTE, 'wait', fuzzy(0.5,'textsearch=compare'))
order by similarity asc

     
  • 1.
  • 2.
  • 3.
  • 4.

summary

thus , We finished in Google Kubernetes Cluster In the operation HANA Expression Database Service Operation steps of . It is not difficult to feel from the whole process , Will include HANA Expression Of Docker The image is deployed in Google Kubernetes Cluster And run in Pod Inside , Realized HANA Expression Service out of the box , Thus avoiding On-Premises In deployment mode HANA Expression Tedious installation and configuration steps .


【 This article is participating in the cloud native prize essay solicitation activity 】, Activity Links : https://ost.51cto.com/posts/12598

原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260933080332.html