Giter Site home page Giter Site logo

data-mesh's Introduction

data-mesh

Tests

A cloud native data mesh implementation

Introduction

This repo will set up a vagrant box (fredrikhgrelland/hashistack) on your local machine with HashiStack software and an integrated suite of tools;

Requirements

Installed software:

  • Vagrant
  • Make
  • Virtualbox
  • Consul

See fredrikhgrelland/vagrant-hashistack for installation of prerequisites. This stack requires at least 4 cpu cores and 16GB memory to run stable. This can be tweaked in Vagrantfile. It has been tested to run on linux and macos.

If you are behind a transparent proxy

If you find yourself behind a transparent proxy for any reason , you need to set the environment variables SSL_CERT_FILE and CURL_CA_BUNDLE. You have three options:

  • Prefix vagrant up; SSL_CERT_FILE=<path/to/ca-certificates-file> CURL_CA_BUNDLE=<path/to/ca-certificates-file> vagrant up.
  • Set the environment variables in your current session by running export SSL_CERT_FILE=<path/to/ca-certificates-file> and export CURL_CA_BUNDLE=<path/to/ca-certificates-file> in the terminal. Eg:export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt.
  • Set the environment variables permanently by adding the above export commands to your ~/.bashrc or gedit ~/.profile in the terminal Window.

How does this work

Data is stored in MinIO, an S3 compliant object storage. Data in S3 can be accessed by Presto, a "SQL on anything" distributed database through table definitions stored in hive-metastore. You may use Presto-CLI to send queries to Presto, or you may use the integrated SQL-interface called SQLPad. In this interface you can write and visualize SQL-queries executed by Presto or other SQL-engines. SQLPad has a default connection to our Presto.

Under is a fairly high-level view of the whole system.

overall_architecture

How to use

Setup

  1. From the same folder that contains this README, run make up. This will start the process of provisioning a vagrant box on your machine. Everything is automated, and it will set up the components mentioned in the introduction.

After everything is set up you need to establish connections to the components inside your vagrant box. There are four commands, and they will all need their own terminal-window as long as you want the connection to stay open. You can choose what components you want to open a connection to. If you don't need to go into the presto-dashboard, you don't have to open a connection.

  1. make connect-to-minio
  2. make connect-to-hive
  3. make connect-to-presto
  4. make connect-to-sqlpad

After running the commands above, the URL to access their respective components are:

  1. MinIO: localhost:8090
  2. Hive: localhost:8070
  3. Presto: localhost:8080
  4. SQLPad: localhost:3000

Consul-dashboard

To access the consul-dashboard open the URL localhost:8500 in your browser (you do not need to run any make connect-to-something command). In this dashboard you can see all your services, and whether they are ready or not. The consul-dashboard will be available shortly after running make up.

Nomad-dashboard

To access the nomad-dashboard open the URL localhost:4646 in your browser (you do not need to run any make connect-to-something command). This dashboard shows all your running services, and gives an overview of which hosts the containers run on, their use of resources, their logs, etc.. You do not need to check this dashboard unless you want to know about the inner workings of the data-mesh system.

Presto-dashboard

To access the presto-dashboard open the URL localhost:8080 in your browser (NB: make connect-to-presto must be run first). Here you can see every query that has been executed by Presto, both failed and successful ones. You can also see general statistics of the Presto instance.

Minio-dashboard

To access the minio-dashboard open the URL localhost:8090 in your browser (NB: make connect-to-minio must be run first). The username and password is minioadmin. This dashboard shows all files you have stored, and they will be organised in what is called buckets. You can treat these as normal directories. There will already be two existing buckets, hive and default. To upload your own files you need to create a new bucket to put it in, which can be done by pressing the plus sign in the right hand corner, then the button looking like a hard drive, which is create bucket . You can now access your new bucket by clicking the name of your new bucket in the left hand column.

SQLPad-dashboard

To access the SQLPad-dashboard open the URL localhost:3000 in your browser (NB: make connect-to-sqlpad must be run first). Default mail and password is [email protected], admin. This is an interface where you can write and run sql queries that will be executed by our Presto instance. To begin using it you need to select a connection in the top left corner. There is a default connection to our Presto you can use, called Presto - hiveCatalog - defaultSchema. After selecting the connection you can see an example table already laying in our schema in the visualisation on the left hand side. To query it you can run SELECT * FROM iris.

Presto-cli

If you want to use a local presto-cli and connect that directly to presto, instead of using a sql-interface like SQLPad, you can do that by running these commands in sequence (NB: make connect-to-presto must be run first):

  1. make download-presto-cli
  2. make presto-cli

There will now be a live-connection to presto in your terminal. Write show tables; in the terminal and hit enter. You will see there is one table available. This can be queried with select * from iris;.

data-mesh's People

Contributors

aditisharma77 avatar fredrikhgrelland avatar pdmthorsrud avatar zhenik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

data-mesh's Issues

Remove unused HCL and rules in Makefile

From what I can gather these are no longer in use. Please correct me if I'm wrong.

  • Delete presto-connect.hcl file. Has been replaced by presto.hcl.
  • Deletebuild certificate-handler rule in Makefile
  • Delete presto rule in Makefile. Has been replaced by rule presto1.
  • Change name of presto1 rule in Makefile to presto, and change make presto1 to make presto in README.md

Could potentially leave presto-connect.hcl as an example of a setup with more than one presto. If so, refactor so that its function as an example is obvious.

Change socket timeout to a sensible value while allowing inserts to run "for a while"

Sorry, yes I meant socket-timeout. It is required to be at least as long as any insert statement we will run. ( it governs how long we eill keep the multipart upload running. It will not fail until all files are uploaded, when it will fail because the first connection wich holds the multipart upload to minio has been ended and thus is nonexisting. Maybe set it to 15 minutes?

Originally posted by @fredrikhgrelland in #10

hive-server occasionally shows as unhealthy after starting up

Even though hive-server starts successfully and is marked as healthy in consul, it occasionally goes back to unhealthy for a second, before going back to healthy. Looks to be stable after one "blip" of unhealthy.

Steps to reproduce:

  1. vagrant up in data-mesh root

hive-server-create-table task fail with exit:0

Needs better trigger

Logs

tail: can't open '/tmp/root/hive.log': No such file or directory
Connecting to jdbc:hive2://localhost:10000/default;auth=noSasl
20/05/28 06:33:50 [main]: ERROR jdbc.HiveConnection: Error opening session
org.apache.thrift.transport.TTransportException: null
	at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:132) ~[hive-exec-3.1.0.jar:3.1.0]
	at org.apache.thrift.transport.TTransport.readAll(TTransport.java:86) ~[hive-exec-3.1.0.jar:3.1.0]
	at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:429) ~[hive-exec-3.1.0.jar:3.1.0]
	at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:318) ~[hive-exec-3.1.0.jar:3.1.0]
	at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:219) ~[hive-exec-3.1.0.jar:3.1.0]
	at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:77) ~[hive-exec-3.1.0.jar:3.1.0]
	at org.apache.hive.service.rpc.thrift.TCLIService$Client.recv_OpenSession(TCLIService.java:176) ~[hive-exec-3.1.0.jar:3.1.0]
	at org.apache.hive.service.rpc.thrift.TCLIService$Client.OpenSession(TCLIService.java:163) ~[hive-exec-3.1.0.jar:3.1.0]
	at org.apache.hive.jdbc.HiveConnection.openSession(HiveConnection.java:715) [hive-jdbc-3.1.0.jar:3.1.0]
	at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:228) [hive-jdbc-3.1.0.jar:3.1.0]
	at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107) [hive-jdbc-3.1.0.jar:3.1.0]
	at java.sql.DriverManager.getConnection(DriverManager.java:664) [?:1.8.0_212]
	at java.sql.DriverManager.getConnection(DriverManager.java:208) [?:1.8.0_212]
	at org.apache.hive.beeline.DatabaseConnection.connect(DatabaseConnection.java:145) [hive-beeline-3.1.0.jar:3.1.0]
	at org.apache.hive.beeline.DatabaseConnection.getConnection(DatabaseConnection.java:209) [hive-beeline-3.1.0.jar:3.1.0]
	at org.apache.hive.beeline.Commands.connect(Commands.java:1641) [hive-beeline-3.1.0.jar:3.1.0]
	at org.apache.hive.beeline.Commands.connect(Commands.java:1536) [hive-beeline-3.1.0.jar:3.1.0]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
	at org.apache.hive.beeline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:56) [hive-beeline-3.1.0.jar:3.1.0]
	at org.apache.hive.beeline.BeeLine.execCommandWithPrefix(BeeLine.java:1384) [hive-beeline-3.1.0.jar:3.1.0]
	at org.apache.hive.beeline.BeeLine.dispatch(BeeLine.java:1423) [hive-beeline-3.1.0.jar:3.1.0]
	at org.apache.hive.beeline.BeeLine.connectUsingArgs(BeeLine.java:900) [hive-beeline-3.1.0.jar:3.1.0]
	at org.apache.hive.beeline.BeeLine.initArgs(BeeLine.java:795) [hive-beeline-3.1.0.jar:3.1.0]
	at org.apache.hive.beeline.BeeLine.begin(BeeLine.java:1048) [hive-beeline-3.1.0.jar:3.1.0]
	at org.apache.hive.beeline.BeeLine.mainWithInputRedirection(BeeLine.java:538) [hive-beeline-3.1.0.jar:3.1.0]
	at org.apache.hive.beeline.BeeLine.main(BeeLine.java:520) [hive-beeline-3.1.0.jar:3.1.0]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
	at org.apache.hadoop.util.RunJar.run(RunJar.java:308) [hadoop-common-3.1.0.jar:?]
	at org.apache.hadoop.util.RunJar.main(RunJar.java:222) [hadoop-common-3.1.0.jar:?]
20/05/28 06:33:50 [main]: WARN jdbc.HiveConnection: Failed to connect to localhost:10000
Error: Could not open client transport with JDBC Uri: jdbc:hive2://localhost:10000/default;auth=noSasl: Could not establish connection to jdbc:hive2://localhost:10000/default;auth=noSasl: null (state=08S01,code=0)

Screenshots

16

17

Makefile `example-csv` command fail

 ~/src/github.com/zhenik/data-mesh │ master *2 !1 ?2  make example-csv                                                                                                                                            2 х │ 20s │ 14:06:12 
NOMAD_ADDR=http://172.17.0.1:4646 nomad stop -purge example-csv | true
No job(s) with prefix or id "example-csv" found
sleep 2
NOMAD_ADDR=http://172.17.0.1:4646 nomad run nomad-jobs/example-csv.hcl
Error submitting job: Unexpected response code: 500 (1 error occurred:
        * Task group test validation failed: 1 error occurred:
        * Task group service validation failed: 1 error occurred:
        * Check testdata-available-via-beeline invalid: refers to non-existent task beeline





)
Makefile:187: recipe for target 'example-csv' failed
make: *** [example-csv] Error 1

Add presto

Add presto (standalone) to current stack

Update hive image on dockerhub

I think fredrikhgrelland/hive:3.1.0 image on docker hub was pushed with wrong entrypoint.sh or outdated.

It fails on line 90. Latest entrypoint.sh has 46 lines total.

Logs:

...
hive-metastore    |  - Setting hive.metastore.warehouse.dir=s3a://hive/warehouse
hive-metastore    | Configuring hivemetastore
hive-metastore    | Configuring metastore
hive-metastore    | /usr/local/bin/entrypoint.sh: line 90: exec: hivemetastore: not found
hive-metastore exited with code 127

steps to reproduce

  1. Pull fredrikhgrelland/hive:3.1.0 from dockerhub
  2. Execute make hive

steps to fix

  1. Rebuild image locally
  2. Push image to dockerhub

Makefile `presto` command conflicts

Makefile. Names collision and presto1 does not exist

https://github.com/fredrikhgrelland/data-mesh/blob/master/Makefile#L75-L83

presto: presto presto-service-update

presto:
	NOMAD_ADDR=http://${HOST_DOCKER}:4646 nomad stop -purge presto | true
	sleep 2
	NOMAD_ADDR=http://${HOST_DOCKER}:4646 nomad run nomad-jobs/presto-connect.hcl
	sleep 10
	curl -s -H X-Consul-Token:${CONSUL_MASTER_TOKEN} -X POST -d '{"SourceName": "presto", "DestinationName": "hive-metastore", "SourceType": "consul", "Action": "allow"}' http://127.0.0.1:8500/v1/connect/intentions
	curl -s -H X-Consul-Token:${CONSUL_MASTER_TOKEN} -X POST -d '{"SourceName": "presto", "DestinationName": "minio", "SourceType": "consul", "Action": "allow"}' http://127.0.0.1:8500/v1/connect/intentions

and here https://github.com/fredrikhgrelland/data-mesh/blob/master/Makefile#L203

up: minio hive presto1 example-csv

Test data

  • Upload test data to minio
  • Create external table with beeline service
  • Query via presto (cli) (@fredrikhgrelland healthcheck or manual ?)

hive-database unhealthy in consul

Hive-database is unhealthy at random intervals in consul. Might because pg_isready has a timeout of 2s, which might be too short because the system is fairly slow atm with everything provisioned.

[fix] dockerhub auto-build

Step 8/17 : COPY ca_certificates/* /usr/local/share/ca-certificates/
COPY failed: no source files were specified

Add dummy source so builds auto-run

Presto and S3 credentials

Steps to reproduce

  1. Run consul & nomad
  2. Run
make minio
make hive
make presto
  1. Try different options with presto.hcl templates

Option 1

template {
        destination = "/local/presto/catalog/hive.properties"
        data = <<EOH
...
hive.s3.aws-access-key=$MINIO_ACCESS_KEY
hive.s3.aws-secret-key=$MINIO_SECRET_KEY
...
EOH
      }

Result
2

Option 2

template {
        destination = "/local/presto/catalog/hive.properties"
        data = <<EOH
...
hive.s3.aws-access-key={{ env "MINIO_ACCESS_KEY" }}
hive.s3.aws-secret-key={{ env "MINIO_SECRET_KEY" }}
...
EOH
      }

Result
3

Option 3 (works)

template {
        destination = "/local/presto/catalog/hive.properties"
        data = <<EOH
...
hive.s3.aws-access-key=adminminio
hive.s3.aws-secret-key=adminminio
...
EOH
      }

Make simple visualisation of data in hue

I can't create a visualisation of data in hue.

I am not allowed to choose anything for the y-axis (no matter if I select everything form the table or not).
image

@zhenik, could you please look into this when you have time before the presentation?

To get the same setup use the code from #71

proxy-user-to-* [token issue]

Relevant to commands in Makefile which create proxy for user to any service using CONSUL_USER_TOKEN

403 with CONSUL_USER_TOKEN

Steps to reproduce

  1. Up platform
  2. Up minio
  3. proxy to minio (make connect-allow-user-to-minio, make proxy-user-to-minio)

PS> works fine with CONSUL_MASTER_TOKEN

Logs

 ~/src/github.com/zhenik/data-mesh │ feature/add-presto  make connect-allow-user-to-minio                                                                                                                                 ✔ │ 12:03:11 
curl -s -H X-Consul-Token:b6e29626-e23d-98b4-e19f-c71a96fbdef7 -X POST -d '{"SourceName": "user", "DestinationName": "minio", "SourceType": "consul", "Action": "allow"}' http://127.0.0.1:8500/v1/connect/intentions
{
    "ID": "ad438dcc-6f46-dce8-0e5a-32bebd8f7e68"
}
 ~/src/github.com/zhenik/data-mesh │ feature/add-presto  make proxy-user-to-minio                                                                                                                                         ✔ │ 12:04:14 
consul connect proxy -token 47ec8d90-bf0a-4c18-8506-8d492b131b6d -service user -upstream minio:8090 -log-level debug
==> Consul Connect proxy starting...
    Configuration mode: Flags
               Service: user
              Upstream: minio => :8090
       Public listener: Disabled

==> Log data will now stream in as it occurs:

    2020-05-25T12:04:22.455+0200 [DEBUG] proxy: got new config
    2020-05-25T12:04:22.456+0200 [INFO]  proxy: Starting listener: listener=127.0.0.1:8090->service:default/minio bind_addr=127.0.0.1:8090
    2020-05-25T12:04:22.458+0200 [ERROR] proxy.connect.watch: Watch errored: service=user type=connect_leaf error="Unexpected response code: 403 (ACL not found)" retry=5s
    2020-05-25T12:04:27.459+0200 [ERROR] proxy.connect.watch: Watch errored: service=user type=connect_leaf error="Unexpected response code: 403 (ACL not found)" retry=20s
    2020-05-25T12:04:47.460+0200 [ERROR] proxy.connect.watch: Watch errored: service=user type=connect_leaf error="Unexpected response code: 403 (ACL not found)" retry=45s
    2020-05-25T12:05:32.462+0200 [ERROR] proxy.connect.watch: Watch errored: service=user type=connect_leaf error="Unexpected response code: 403 (ACL not found)" retry=1m20s
    2020-05-25T12:06:52.464+0200 [ERROR] proxy.connect.watch: Watch errored: service=user type=connect_leaf error="Unexpected response code: 403 (ACL not found)" retry=2m5s
    2020-05-25T12:08:57.467+0200 [ERROR] proxy.connect.watch: Watch errored: service=user type=connect_leaf error="Unexpected response code: 403 (ACL not found)" retry=3m0s

Wait for with `alioygur/wait-for` is controversial in consul-connect context

I suspect that alioygur/wait-for as a prestart hook does not work as we expect in nomad context.

Steps to reproduce.
0. Use vagrant box

  1. run minio-connect.hcl
  2. run hive-connect.hcl

While hive-connect groups in process of downloading the image, prestart hook (with image run minio-connect.hcl) are exited with 0.

I think nomad allocate ports at allocation time, and ports become available. But it does not mean that applications starts and available on those ports.

waitfor-minio-has-required-bucket exits with 0 without buckets existing

The task waitfor-minio-has-required-bucket in hive-connect.hcl exits with code 0 immediately after starting up, even though the bucket has not been created in minio. This causes metastore to fail further down the road becuase of missing buckets, but will fix itself by restarting the whole job after 2 retries, at which point waitfor-minio-has-required-bucket correctly creates the hive bucket, and metastore spins up successfully. Creates a huge delay in the provisioning time, needs to be fixed before demo on friday.
image
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.