• yugabyte 安装pg_hashids 扩展


    主要目的比较简单,就是测试下yugabyte 对于pg 扩展的支持,今天在测试plv8的时候发现有问题(以及提交issue了,很期待官方的解决)
    所以测试下一个其他的扩展,看看是否像官方介绍的那样

    环境准备

    • 说明
      环境基于docker 运行,同时pg_hashids 扩展也基于docker 构建,之后copy yugabyte 扩展安装目录
    • pg_hashids dockerfile
     
    FROM postgres:11.2
    ENV PG_HASHIDS=v1.2.1
    LABEL EMAIL="1141591465@qq.com"
    LABEL AUTHOR="dalongrong"
    RUN buildDependencies="curl build-essential ca-certificates git pkg-config postgresql-server-dev-$PG_MAJOR" 
      && apt-get update 
      && apt-get install -y --no-install-recommends libc++1 ${buildDependencies} 
      && mkdir -p /tmp/build 
      && cd /tmp/build 
      && git clone https://github.com/iCyberon/pg_hashids.git /tmp/build/pg_hashids 
      && cd /tmp/build/pg_hashids 
      && make && make install 
      && cd / 
      && apt-get clean 
      && apt-get remove -y ${buildDependencies} 
      && apt-get autoremove -y 
      && rm -rf /tmp/build /var/lib/apt/lists/*
    • yugabyte 集群
      基于docker-compose 运行
     
    version: '2'
    services:
      yb-master:
          image: yugabytedb/yugabyte:latest
          container_name: yb-master-n1
          command: [ "/home/yugabyte/bin/yb-master", 
                    "--fs_data_dirs=/mnt/disk0,/mnt/disk1", 
                    "--master_addresses=yb-master-n1:7100", 
                    "--replication_factor=1"]
          ports:
          - "7000:7000"
          environment:
            SERVICE_7000_NAME: yb-master
      yb-tserver:
          image: yugabytedb/yugabyte:latest
          container_name: yb-tserver-n1
          command: [ "/home/yugabyte/bin/yb-tserver", 
                    "--fs_data_dirs=/mnt/disk0,/mnt/disk1",
                    "--start_pgsql_proxy", 
                    "--tserver_master_addrs=yb-master-n1:7100"]
          ports:
          - "9042:9042"
          - "6379:6379"
          - "5433:5433"
          - "9000:9000"
          environment:
            SERVICE_5433_NAME: ysql
            SERVICE_9042_NAME: ycql
            SERVICE_6379_NAME: yedis
            SERVICE_9000_NAME: yb-tserver
          depends_on:
          - yb-master
      yb-tserver2:
          image: yugabytedb/yugabyte:latest
          container_name: yb-tserver-n2
          command: [ "/home/yugabyte/bin/yb-tserver", 
                    "--fs_data_dirs=/mnt/disk0,/mnt/disk1",
                    "--start_pgsql_proxy", 
                    "--tserver_master_addrs=yb-master-n1:7100"]
          ports:
          - "9043:9042"
          - "6380:6379"
          - "5434:5433"
          - "9001:9000"
          environment:
            SERVICE_5433_NAME: ysql
            SERVICE_9042_NAME: ycql
            SERVICE_6379_NAME: yedis
            SERVICE_9000_NAME: yb-tserver
          depends_on:
          - yb-master

    启动&&扩展copy

    • 启动服务
    docker-compose up -d
    • 启用ysql

      新版本的好像默认,就启用了,后边在仔细测试下

    docker-compose exec yb-master bash -c "YB_ENABLED_IN_POSTGRES=1 FLAGS_pggate_master_addresses=yb-master-n1:7100 /home/yugabyte/postgres/bin/initdb -D /tmp/yb_pg_initdb_tmp_data_dir -U postgres"
    • copy 扩展

      为了测试,我已经copy 出构建好的扩展到本地

    docker cp hashids/pg_hashids.so yb-tserver-n1:/home/yugabyte/postgres/lib
    docker cp hashids/pg_hashids.so yb-tserver-n2:/home/yugabyte/postgres/lib
    docker cp hashids/extension/. yb-tserver-n1:/home/yugabyte/postgres/share/extension
    docker cp hashids/extension/. yb-tserver-n2:/home/yugabyte/postgres/share/extension

    扩展测试

    • 启动扩展
    CREATE EXTENSION pg_hashids;
    • 调用函数
    SELECT id_encode(1001);
    • 效果

    参考资料

    https://github.com/iCyberon/pg_hashids
    https://github.com/rongfengliang/yugabytedb-jaeger-docker-compose
    https://github.com/rongfengliang/pg_hashids_docker
    https://docs.yugabyte.com/latest/api/ysql/extensions/
    https://hashids.org/

  • 相关阅读:
    VGA Vesa DDC显示接口
    sourceinsight 技巧
    framebuffer 相关
    Windows Live Writer 粘贴表格的使用技巧
    The Linux Kernel API
    XBAP and Silverlight : Product Lining in .NET 3.0/WPF
    DDC and EDID
    cmem模块,cmemk
    Linux Platform Device and Driver,platform_add_devices()>platform_driver_register()
    platform设备驱动全透析
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/11838636.html
Copyright © 2020-2023  润新知