首页 > 其他分享 >openGauss在kubernetes集群环境上的部署

openGauss在kubernetes集群环境上的部署

时间:2024-04-17 11:15:03浏览次数:18  
标签:kubectl kubernetes omm 集群 openGauss k8s root opengauss

opengauss 实践总结学习心
openGauss 是一款开源关系型数据库管理系统 , 深度融合华为在数据库领域多年的经验,结合企业级场景需求,持续构建竞争力特性;kubernetes 也是一个开源的,用于管理云平台中多个主机上的容器化的应用,Kubernetes 的目标是让部署容器化的应用简单并且高效,Kubernetes 提供了应用部署,规划,更新,维护的一种机制, 本篇文章将介绍 openGauss 在 kubernetes 集群环境上的部署探索。

1.检查 k8s 运行环境
[root@n-k8s-m ~]# kubectl get node

NAME STATUS ROLES AGE VERSION
n-k8s-m Ready master 349d v1.18.0
2.查看准备好的 openGauss 的 docker 镜像
[root@n-k8s-m ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4cdc5dd7eaad 36 hours ago 133MB
opengauss 2.0.0 757bf74560e3 5 weeks ago 639MB
3.安装 NFS 服务器存储

安装依赖包

[root@n-k8s-m ~]#yum -y install nfs-utils rpcbind

开机启动

[root@n-k8s-m ~]#systemctl enable rpcbind.service
[root@n-k8s-m ~]#systemctl enable nfs-server.service
[root@n-k8s-m ~]#systemctl start rpcbind.service #端口是111
[root@n-k8s-m ~]#systemctl start nfs-server.service # 端口是 2049

配置NFS

[root@n-k8s-m ~]#mkdir /home/pv1
[root@n-k8s-m ~]#chown nfsnobody:nfsnobody /home/pv1
[root@n-k8s-m ~]#cat /etc/exports

/home/pv1 ***.***.***.***/24(rw,async,all_squash)

[root@n-k8s-m ~]#exportfs -rv

exporting ***.***.***.***/24:/home/pv1

/home/pv1 .../24(rw,async,all_squash)

[root@n-k8s-m ~]#exportfs -rv
exporting .../24:/home/pv1
4.创建 openGauss 所使用的存储 pv

编写yaml文件

[root@n-k8s-m ~]# cat opengauss_pv.yml
apiVersion: v1
kind: PersistentVolume
metadata:
name: opengauss-pv
labels:
type: nfs001
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Recycle
nfs:
path: "/home/pv1"
server: ... readOnly: false

创建pv

[root@n-k8s-m opengauss]# kubectl create -f opengauss_pv.yml
persistentvolume/opengauss-pv created

查看创建pv

[root@n-k8s-m opengauss]# kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM                            STORAGECLASS          REASON   AGE

opengauss-pv 1Gi RWX Recycle Available
5.创建 openGauss 所使用的存储 pvc

编写yaml文件

[root@n-k8s-m ~]# cat opengauss_pvc.yml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: opengauss-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi

创建pvc

[root@n-k8s-m opengauss]# kubectl create -f opengauss_pvc.yml
persistentvolumeclaim/opengauss-pv created

查看创建pvc

[root@n-k8s-m opengauss]# kubectl get pvc
NAME                     STATUS   VOLUME                  CAPACITY   ACCESS MODES   STORAGECLASS          AGE

opengauss-pvc Bound opengauss-pv 1Gi RWX 4s
6.创建 openGauss 的 Deployment

编写yaml文件

apiVersion: apps/v1
kind: Deployment
metadata:
name: opengauss-deployment
spec:
selector:
matchLabels:
app: opengauss
strategy:
type: Recreate
template:
metadata:
labels:
app: opengauss
spec:
containers:
- image: opengauss:2.0.0
name: opengauss-service
imagePullPolicy: IfNotPresent
env:
- name: GS_PASSWORD
value: Gauss@123
ports:
- containerPort: 5432
name: opengauss
volumeMounts: # 挂载Pod上的卷到容器
- name: opengauss-persistent-storage # Pod上卷的名字,与“volumes”名字匹配
mountPath: /var/lib/opengauss # 挂载的Pod的目录
volumes: # 挂载持久卷到Pod
- name: opengauss-persistent-storage # 持久卷名字, 与“volumMounts”名字匹配
persistentVolumeClaim:
claimName: opengauss-pvc # 持久卷申请名字

创建Deployment[root@n-k8s-m opengauss]# kubectl create -f opengauss_deploy.yaml

 deployment.apps/opengauss-deployment create

查看创建Deploymen

 [root@n-k8s-m opengauss]# kubectl get deploy
 NAME                            READY   UP-TO-DATE   AVAILABLE   AGEopengauss-deployment     1/1                 1            1           110s

创建Deployment

[root@n-k8s-m opengauss]# kubectl create -f opengauss_deploy.yaml
deployment.apps/opengauss-deployment created

查看创建Deployment

[root@n-k8s-m opengauss]# kubectl get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
opengauss-deployment 1/1 1 1 110s​
7.创建 openGauss 的 Service 提供集群内部和外部的高可用访问

编写yaml文件

apiVersion: v1
kind: Service
metadata:
name: opengauss-service
labels:
app: opengauss
spec:
type: NodePort
selector:
app: opengauss
ports:

  • protocol : TCP
    nodePort: 32222
    port: 5432
    targetPort: 5432

创建openGauss的Service

[root@n-k8s-m opengauss]# kubectl create -f opengauss_svc.yaml
>service/opengauss-service created

查看创建Service

[root@n-k8s-m opengauss]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
opengauss-service NodePort 10.101.64.232 <none> 5432:32222/TCP 6s
8.连接 openGauss 数据库

使用kubectl内部连接数据库

[root@n-k8s-m opengauss]# kubectl get pod
NAME READY STATUS RESTARTS AGE
opengauss-deployment-6b8b4645f8-bfk4w 1/1 Running 0 15m
[root@n-k8s-m opengauss]# kubectl exec -it opengauss-deployment-6b8b4645f8-bfk4w sh
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl kubectl exec [POD] -- [COMMAND] instead.
sh-4.2# su - omm
[omm@opengauss-deployment-6b8b4645f8-bfk4w ~]$ gsql
gsql ((openGauss 2.0.0 build 78689da9) compiled at 2021-03-31 21:04:03 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
omm=# \c
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "omm" as user "omm".
omm=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-------+----------+------------+------------+-------------------
omm | omm | UTF8 | en_US.utf8 | en_US.utf8 |
postgres | omm | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | omm | UTF8 | en_US.utf8 | en_US.utf8 | =c/omm +
| | | | | omm=CTc/omm
template1 | omm | UTF8 | en_US.utf8 | en_US.utf8 | =c/omm +
| | | | | omm=CTc/omm
(4 rows)
使用 pgadmin4 外部连接数据库

image.pngimage.png

标签:kubectl,kubernetes,omm,集群,openGauss,k8s,root,opengauss
From: https://www.cnblogs.com/helloopenGauss/p/18140104

相关文章

  • 如何使用pgloader迁移MySQL数据库至openGauss
    pgloader介绍pgloader是一个数据导入工具,使用COPY命令将数据导入到PostgreSQL。pgloader有两种工作模式,一种是从文件导入,一种是迁移数据库。pgloader在两种情况下都使用PostgreSQL的COPY协议高效的传输数据。openGauss兼容PostgreSQL的通信协议以及绝大部分语法,可......
  • MapReduce:简化集群上的大数据处理.18139822
    本文是论文《MapReduce:SimplifiedDataProcessingonLargeClusters》的翻译。原作者:JeffreyDeanandSanjayGhemawat@Google,Inc.为了刷MIT6.8242021,分布式系统课程,可以去B站看下,也有Lab可以刷概述MapReduce是一个针对处理大数据集的编程模型以及关联实现。用户......
  • redis自学(35)搭建分片集群
    分片集群结构主从和哨兵可以解决高可用、高并发读的问题。但是依然有两个问题没有解决:l 海量数据存储问题l 高并发写的问题使用分片集群可以解决上述问题,分片集群特征:l 集群中有多个master,每个master保存不同数据,因此能存多少取决于master节点的数量,解决了海量数据存储的......
  • 教你解决CCE集群中容器出网
    本文分享自华为云社区《CCE集群中容器出网总结》,作者:可以交个朋友。一背景针对CCE集群和CCEturbo集群中的容器访问外部网络进行总结 二容器出网简介使用EIP服务绑定特定节点、容器IP地址或者使用SNAT网关对特定子网进行NAT源地址进行转换从而实现容器出网。 2.1CCE......
  • VMware Tanzu Kubernetes Grid Integrated Edition (TKGI) 1.19 - 运营商 Kubernetes
    VMwareTanzuKubernetesGridIntegratedEdition(TKGI)1.19-运营商Kubernetes解决方案Kubernetes-basedcontainersolutionwithadvancednetworking,aprivatecontainerregistry,andlifecyclemanagement请访问原文链接:https://sysin.org/blog/vmware-tkgi/,查......
  • Nacos高可用集群搭建与使用
    参考:https://blog.csdn.net/Alwayszmx/article/details/122291741一、Nacos简介Nacos致力于帮助您发现、配置和管理微服务。Nacos提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据及流量管理。Nacos帮助您更敏捷和容易地构建、交付和管理微服务......
  • Docker容器配置redis集群
    前言Redis集群是一种分布式数据库解决方案,旨在提供高性能、高可用性、可扩展性的数据存储服务。目前比较普遍流行的搭配则是三主三从配置,共6台redis服务进行集群配置。Redis的三主三从配置是一种集群模式,其中包含三个主节点和三个从节点。每个从节点对应一个主节点,当主......
  • StarRocks 集群安装
    当前按照官网上的提供的安装包方式安装,版本是3.2.2,部署模式为存算一体,安装的操作系统是Ubuntu22.04,JDK版本为OpenJDK11,这里选择3个节点进行安装,节点的hosts定义如下:10.0.1.25ec2510.0.1.26ec2610.0.1.27ec27由于StarRocks安装包比较大,所以选择在每个节点上都......
  • 5.CentOS-7-Minimal 安装KubernetesV1.23.17&DockerV20.10.23
    1.环境准备主节点IP:192.168.254.130node1IP:192.168.254.131node2IP:192.168.254.132OSversion:CentOS7miniCPUArchitecture:x86_64/amd64K8sversion:v1.23.17Dockerversion:20.10.232.安装前准备#安装依赖yuminstall-ycurlwgetsystemdbash-completi......
  • 消息中间件RabbitMQ_RabbitMQ集群搭建8
    一、集群搭建概述摘要:实际生产应用中都会采用消息队列的集群方案,如果选择RabbitMQ那么有必要了解下它的集群方案原理一般来说,如果只是为了学习RabbitMQ或者验证业务工程的正确性那么在本地环境或者测试环境上使用其单实例部署就可以了,但是出于MQ中间件本身的可靠性、并发性......