openGauss单节点部署

openGauss单节点部署

openGauss是与Mulan PSL v2一起发布的开源关系数据库管理系统。openGauss的内核源自PostgreSQL,是华为在数据库领域积累多年经验的基础上,不断为企业级场景提供具有竞争力的特性。此外,openGauss是一个鼓励社区贡献和协作的开源数据库平台。

如何在Docker上运行opengaus
您可以阅读英文安装指南openGauss-in-Docker-container-installation-guide.md,或者中文安装指南

容器安装

本章节主要介绍通过Docker安装openGauss,方便DevOps用户的安装、配置和环境设置。

支持的架构和操作系统版本

  • x86-64 CentOS 7.6
  • ARM64 openEuler 20.03 LTS

配置准备

使用 buildDockerImage.sh脚本构建docker镜像,buildDockerImage.sh是一个方便使用的shell脚本,提供SHA256的检查。

OpenGauss单机数据库容器安装

创建openGauss docker镜像

说明:

  • 安装前需要提供openGauss二进制安装包,解压后将以bz2结尾的包(openGauss-X.X.X-CentOS-64bit.tar.bz2,X.X.X诶openGauss当前版本号)放到 dockerfiles/文件夹。二进制包可以从 https://www.opengauss.org/zh/download/下载,确保有正确的yum源。

image.png

  • 运行buildDockerImage.sh脚本时,如果不指定-i参数,此时默认提供SHA256检查,需要您手动将校验结果写入sha256_file_amd64文件。
## 修改sha256校验文件内容
cd /home/openGauss-server/docker/dockerfiles/5.0.0  # 如果目录为3.0.0 或者其它请修改成5.0.0
sha256sum openGauss-5.0.0-CentOS-64bit.tar.bz2 > sha256_file_amd64 

image.png

  • 安装前需要从华为开源镜像站获取openEuler_aarch64.repo文件,并放到openGauss-server-master/docker/dockerfiles/3.0.0文件夹下面。openEuler_aarch64.repo获取方法:
[root@localhost dockerfiles]# wget -O openEuler_aarch64.repo https://mirrors.huaweicloud.com/repository/conf/openeuler_aarch64.repo
--2024-03-08 10:38:31--  https://mirrors.huaweicloud.com/repository/conf/openeuler_aarch64.repo
Resolving mirrors.huaweicloud.com (mirrors.huaweicloud.com)... 124.70.125.167, 124.70.125.153
Connecting to mirrors.huaweicloud.com (mirrors.huaweicloud.com)|124.70.125.167|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/octet-stream]
Saving to: ‘openEuler_aarch64.repo’

    [ <=>                                                                                                                           ] 891         --.-K/s   in 0s      

2024-03-08 10:38:32 (78.5 MB/s) - ‘openEuler_aarch64.repo’ saved [891]

在dockerfiles文件夹运行buildDockerImage.sh脚本。

# 脚本说明
Usage: buildDockerImage.sh -v [version] [-i] [Docker build option]
Builds a Docker Image for openGauss
Parameters:
   -v: version to build
       Choose one of: 3.0.0
   -i: ignores the SHA256 checksums

LICENSE UPL 1.0
----------------------------------------------------------
[root@localhost dockerfiles]# ll
total 97588
drwxr-xr-x. 2 root root     4096 Dec 25 14:20 5.0.0
-rwxr-xr-x. 1 root root     5238 Dec 25 11:16 buildDockerImage.sh
-rw-r--r--. 1 root root     4696 Dec 25 11:16 create_master_slave.sh
-rw-r--r--. 1 root root      891 Mar  8 10:38 openEuler_aarch64.repo
-rw-r--r--. 1 root root 99901554 Dec 25 14:19 openGauss-5.0.0-CentOS-64bit.tar.bz2
# 执行脚本编译镜像
[root@localhost dockerfiles]# ./buildDockerImage.sh 5.0.0
Checking Docker version.
Checking if required packages are present and valid...
openGauss-5.0.0-CentOS-64bit.tar.bz2: OK
==========================
DOCKER info:
Client:
 Context:    default
 Debug Mode: false

Server:
 Containers: 2
  Running: 0
  Paused: 0
  Stopped: 2
 Images: 22
 Server Version: 20.10.0
 .......................
 .......................
 Removing intermediate container 9e518e4fb6f6
 ---> 09d75552d133
Successfully built 09d75552d133
Successfully tagged opengauss:5.0.0


  openGauss Docker Image  5.0.0 is ready to be extended: 
    
    --> opengauss:5.0.0

  Build completed in 147 seconds.


  # 编译完成

image.png
image.png

环境变量

为了更灵活的使用openGauss镜像,可以设置额外的参数。未来我们会扩充更多的可控制参数,当前版本支持以下变量的设定。
GS_PASSWORD
使用openGauss镜像的时候,必须设置该参数。该参数值不能为空或者不定义。该参数设置了openGauss数据库的超级用户omm以及测试用户gaussdb的密码。openGauss安装时默认会创建omm超级用户,该用户名暂时无法修改。测试用户gaussdb是在entrypoint.sh中自定义创建的用户。
openGauss镜像配置了本地信任机制,因此在容器内连接数据库无需密码,但是如果要从容器外部(其它主机或者其它容器)连接则必须要输入密码。
openGauss的密码有复杂度要求
密码长度8个字符以上,必须同时包含大写字母、小写字母、数字、以及特殊符号(特殊符号仅包含“#?!@ %^&*-”,并且“! &”需要用转义符“\”进行转义)。
GS_NODENAME
指定数据库节点名称,默认为gaussdb。
GS_USERNAME
指定数据库连接用户名,默认为gaussdb。
GS_PORT
指定数据库端口,默认为5432。

启动OpenGauss单节点实例

mkdir /home/opengauss
cd /home/opengauss
vim docker-compose.yaml
version: '3'

services:
  opengauss:
    image: opengauss:5.0.0
    container_name: opengauss
    restart: unless-stopped
    privileged: true
    volumes:
      - "./data:/var/lib/opengauss/data"
    environment:
      TZ: Asia/Shanghai
      LANG: en_US.UTF-8
      GS_USERNAME: open
      GS_PASSWORD: Open@123
    ports:
      - "5432:5432"

# 保存
# 启动compose文件
docker-compose up -d
[+] Running 2/2
 ⠿ Network opengauss_default  Created                                      0.1s
 ⠿ Container opengauss        Started                                      0.5s

image.png

# 进入opengauss
[root@localhost opengauss]# docker exec -it opengauss bash
[root@80c07efc7cfa /]# su - omm     # 用户为omm,所有需要切换到omm用户下进入数据库
[omm@80c07efc7cfa ~]$ gsql -U open -d postgres -r
Password for user open: 
gsql ((openGauss 5.0.1 build 33b035fd) compiled at 2023-12-15 20:19:06 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=>

image.png

openGauss部署完成,集群部署请参考官网文档。

  • 15
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值