首页 > 其他分享 >neon serverless postgres 简单试用

neon serverless postgres 简单试用

时间:2023-01-08 12:44:06浏览次数:80  
标签:serverless http postgres -- storage neon broker minio

内容来自官方的docker-compose 内容,主要是测试试用

参考架构

 

 

从以上图可以看出,neon 应该包含了几个组件,safekeeper,pageserver,计算节点,以及对象存储,运行的服务也是参考此部署的,safekeeper 需要至少3个节点
实现了选举机制,内部试用了

部署docker-compose

  • docker-compose 文件
 
version: '3'
# minio s3 服务
services:
  minio:
    image: minio/minio:RELEASE.2022-10-20T00-55-09Z
    ports:
      - 9000:9000
      - 9001:9001
    environment:
      - MINIO_ROOT_USER=minio
      - MINIO_ROOT_PASSWORD=password
    command: server /data --address :9000 --console-address ":9001"
# 初始化桶创建
  minio_create_buckets:
    image: minio/mc
    environment:
      - MINIO_ROOT_USER=minio
      - MINIO_ROOT_PASSWORD=password
    entrypoint:
      - "/bin/sh"
      - "-c"
    command:
      - "until (/usr/bin/mc alias set minio http://minio:9000 $$MINIO_ROOT_USER $$MINIO_ROOT_PASSWORD) do
             echo 'Waiting to start minio...' && sleep 1;
         done;
         /usr/bin/mc mb minio/neon --region=eu-north-1;
         exit 0;"
    depends_on:
      - minio
# pageserver 
  pageserver:
    image: ${REPOSITORY:-neondatabase}/neon:${TAG:-latest}
    environment:
      - BROKER_ENDPOINT='http://storage_broker:50051'
      - AWS_ACCESS_KEY_ID=minio
      - AWS_SECRET_ACCESS_KEY=password
      #- RUST_BACKTRACE=1
    ports:
       #- 6400:6400  # pg protocol handler
       - 9898:9898 # http endpoints
    entrypoint:
      - "/bin/sh"
      - "-c"
    command:
      - "/usr/local/bin/pageserver -D /data/.neon/
                                   -c \"broker_endpoint=$$BROKER_ENDPOINT\"
                                   -c \"listen_pg_addr='0.0.0.0:6400'\"
                                   -c \"listen_http_addr='0.0.0.0:9898'\"
                                   -c \"remote_storage={endpoint='http://minio:9000',
                                                        bucket_name='neon',
                                                        bucket_region='eu-north-1',
                                                        prefix_in_bucket='/pageserver/'}\""
    depends_on:
      - storage_broker
      - minio_create_buckets
# safekeeper 服务
  safekeeper1:
    image: ${REPOSITORY:-neondatabase}/neon:${TAG:-latest}
    environment:
      - SAFEKEEPER_ADVERTISE_URL=safekeeper1:5454
      - SAFEKEEPER_ID=1
      - BROKER_ENDPOINT=http://storage_broker:50051
      - AWS_ACCESS_KEY_ID=minio
      - AWS_SECRET_ACCESS_KEY=password
      #- RUST_BACKTRACE=1
    ports:
      #- 5454:5454 # pg protocol handler
      - 7676:7676 # http endpoints
    entrypoint:
      - "/bin/sh"
      - "-c"
    command:
      - "safekeeper --listen-pg=$$SAFEKEEPER_ADVERTISE_URL
                    --listen-http='0.0.0.0:7676'
                    --id=$$SAFEKEEPER_ID
                    --broker-endpoint=$$BROKER_ENDPOINT
                    -D /data
                    --remote-storage=\"{endpoint='http://minio:9000',
                                        bucket_name='neon',
                                        bucket_region='eu-north-1',
                                        prefix_in_bucket='/safekeeper/'}\""
    depends_on:
      - storage_broker
      - minio_create_buckets
# safekeeper 服务
  safekeeper2:
    image: ${REPOSITORY:-neondatabase}/neon:${TAG:-latest}
    environment:
      - SAFEKEEPER_ADVERTISE_URL=safekeeper2:5454
      - SAFEKEEPER_ID=2
      - BROKER_ENDPOINT=http://storage_broker:50051
      - AWS_ACCESS_KEY_ID=minio
      - AWS_SECRET_ACCESS_KEY=password
      #- RUST_BACKTRACE=1
    ports:
      #- 5454:5454 # pg protocol handler
      - 7677:7676 # http endpoints
    entrypoint:
      - "/bin/sh"
      - "-c"
    command:
      - "safekeeper --listen-pg=$$SAFEKEEPER_ADVERTISE_URL
                    --listen-http='0.0.0.0:7676'
                    --id=$$SAFEKEEPER_ID
                    --broker-endpoint=$$BROKER_ENDPOINT
                    -D /data
                    --remote-storage=\"{endpoint='http://minio:9000',
                                        bucket_name='neon',
                                        bucket_region='eu-north-1',
                                        prefix_in_bucket='/safekeeper/'}\""
    depends_on:
      - storage_broker
      - minio_create_buckets
# safekeeper 服务
  safekeeper3:
    image: ${REPOSITORY:-neondatabase}/neon:${TAG:-latest}
    environment:
      - SAFEKEEPER_ADVERTISE_URL=safekeeper3:5454
      - SAFEKEEPER_ID=3
      - BROKER_ENDPOINT=http://storage_broker:50051
      - AWS_ACCESS_KEY_ID=minio
      - AWS_SECRET_ACCESS_KEY=password
      #- RUST_BACKTRACE=1
    ports:
      #- 5454:5454 # pg protocol handler
      - 7678:7676 # http endpoints
    entrypoint:
      - "/bin/sh"
      - "-c"
    command:
      - "safekeeper --listen-pg=$$SAFEKEEPER_ADVERTISE_URL
                    --listen-http='0.0.0.0:7676'
                    --id=$$SAFEKEEPER_ID
                    --broker-endpoint=$$BROKER_ENDPOINT
                    -D /data
                    --remote-storage=\"{endpoint='http://minio:9000',
                                        bucket_name='neon',
                                        bucket_region='eu-north-1',
                                        prefix_in_bucket='/safekeeper/'}\""
    depends_on:
      - storage_broker
      - minio_create_buckets
# 存储broker,safekeeper 需要依赖此服务
  storage_broker:
    image: ${REPOSITORY:-neondatabase}/neon:${TAG:-latest}
    ports:
      - 50051:50051
    command:
      - "storage_broker"
      - "--listen-addr=0.0.0.0:50051"
 # 计算节点,实际进行查询的入口,依赖pageserver以及safekeeper
  compute:
    build:
      context: ./compute_wrapper/
      args:
        - COMPUTE_IMAGE=compute-node-v${PG_VERSION:-14}
        - TAG=${TAG:-latest}
        - http_proxy=$http_proxy
        - https_proxy=$https_proxy
    environment:
      - PG_VERSION=${PG_VERSION:-14}
      #- RUST_BACKTRACE=1
    # Mount the test files directly, for faster editing cycle.
    volumes:
      - ./compute_wrapper/var/db/postgres/specs/:/var/db/postgres/specs/
      - ./compute_wrapper/shell/:/shell/
    ports:
      - 55433:55433 # pg protocol handler
      - 3080:3080 # http endpoints
    entrypoint:
      - "/shell/compute.sh"
    depends_on:
      - safekeeper1
      - safekeeper2
      - safekeeper3
      - pageserver
 # 测试客户端
  compute_is_ready:
    image: postgres:latest
    entrypoint:
      - "/bin/bash"
      - "-c"
    command:
      - "until pg_isready -h compute -p 55433 ; do
            echo 'Waiting to start compute...' && sleep 1;
         done"
    depends_on:
      - compute

使用

可以直接基于pg 客户端链接

  • 效果

 

 

说明

以上是一个简单的试用,实际上neon 还支持分支,以及不少其他pg 扩展,后边试用下

参考资料

https://neon.tech/docs/introduction/architecture-overview/
https://github.com/neondatabase/neon/blob/main/docs/docker.md
https://github.com/rongfengliang/neon-docker-compose-learning
https://github.com/neondatabase/neon
https://neon.tech/docs/reference/compatibility/

标签:serverless,http,postgres,--,storage,neon,broker,minio
From: https://www.cnblogs.com/rongfengliang/p/17034409.html

相关文章

  • Fission:基于 Kubernetes 的 Serverless 函数框架
    原文为Platform9的软件工程师SoamVasani所写,讲解了一个基于Kubernetes的Serverless函数(FaaS)框架——Fission。简单的来讲,Fission是一个构建在 ​​Kubernetes​......
  • neon serverless postgres 服务
    neon是开源的基于rust开发的serverlesspostgres服务支持的特性计算存储隔离分支无限存储自动缩放架构包含pageserver,计算节点的处理safekeepers,进行wal服......
  • 通知:PostgreSQL证书领取(初级)
    PCA7天训练营第13营、PCA7天训练营第14营、PCA7天训练营第15营、PCA7天训练营第16营证书已由工业和信息化部教育与考试中心进行制作。​ 该批次证书发放事宜通知如下:......
  • 基于Patroni的PostgreSQL高可用实践
    因环境有限,本文在一台机器上实现基于Patroni的PostgreSQL高可用服务测试。1、安装软件包[root@lee~]#yum-yinstallhttps://mirrors.tuna.tsinghua.edu.cn/postgresql/r......
  • PostgreSQL(02): PostgreSQL常用命令
    目录PostgreSQL(01):Ubuntu20.04/22.04PostgreSQL安装配置记录PostgreSQL(02):PostgreSQL常用命令PostgreSQL常用命令满足验证条件的用户,可以用psql命令进入p......
  • PostgreSQL数据类型-boolean
    PostgreSQL支持SQL标准的​​boolean​​​数据类型。​​boolean​​只能有"true"(真)或"false"(假)两个状态之一,第三种"unknown"(未知)状态,用NULL表示。真值的有效......
  • PG中级证书到手,PostgreSQL(PG)认证
    PGCCC的PCA(初级)第13营、14营、15营、16营和PCP(中级)第13营参加PostgreSQL能力认证的学员,已经陆续能够查到并下载证书,恭喜他们获得“工业和信息化部与考试中心(软考权威发证......
  • mybatis使用postgresql中的jsonb数据类型
    最近新开发的一个功能使用到postgresql中的jsonb数据类型。架构师可能考虑到这种数据格式更加便于存储json格式的数据,因此考虑使用这种数据类型。自己以前未曾使用过这......
  • 硅基仿生业务全面 Serverless 容器化,14万+问答库助力糖尿病科普
    作者:宁佑章(硅基仿生科技)、元毅(阿里云容器服务)“使用阿里云容器服务Knative,解决了开发迭代慢的问题,加速了深度学习模型的性能提升;同时提供了弹性可伸缩的资源配置,满足网络服......
  • 硅基仿生业务全面 Serverless 容器化,14万+问答库助力糖尿病科普
    作者:宁佑章(硅基仿生科技)、元毅(阿里云容器服务)“使用阿里云容器服务Knative,解决了开发迭代慢的问题,加速了深度学习模型的性能提升;同时提供了弹性可伸缩的资源配置,满足网络......