yugabyte 做为hasura graphql-engine的pg数据引擎

今天看了下yugabyte 的更新 ,ysql 基本可以生产可用,刚好测试了下与hasura graphql-engine的集成,发现很不错,可以直接运行

环境准备

  • docker-compose
version: '2'
services:
  graphql-engine:
    image: hasura/graphql-engine:v1.0.0-beta.6
    ports:
    - "8080:8080"
    environment:
      HASURA_GRAPHQL_DATABASE_URL: postgres://postgres@yb-tserver2:5433/postgres
      HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
      HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
  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
 
 
  • 初始化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"

启动&&效果

  • 启动
docker-compose up -d
  • 创建测试数据库
CREATE TABLE users (name text, pass text, id int, primary key (id));
  • 访问效果

 

 

说明

目前官方在运行的时候都添加了遥测功能,这个选项可以禁用,但是实际中可能会因为网络的问题造成启动问题,hasura 目前的变化还是挺大的

参考资料

https://docs.yugabyte.com/latest/releases/

posted on 2019-10-18 10:21  荣锋亮  阅读(411)  评论(0编辑  收藏  举报

导航