Skip to content
Snippets Groups Projects
Commit 07b727f9 authored by Etxaniz Errazkin, Iñaki's avatar Etxaniz Errazkin, Iñaki
Browse files

M30 version

parent 1742440c
Branches main
No related tags found
No related merge requests found
presto-cli
\ No newline at end of file
DBTechnologyStack.png

17.5 KiB

# dataBases
# Database
Database architecture required to support the data storage and retrieval component.
## Getting started ## Table of Contents
1. [Proposed Architecture](#proposed-architecture)
2. [Configuration](#configuration)
1. [Docker](#docker)
2. [Presto](#presto)
1. [Catalogs](#catalogs)
1. [MySQL](#mysql)
2. [MongoDB](#mongodb)
3. [Run](#configuration)
4. [Presto CLI](#presto-cli)
To make it easy for you to get started with GitLab, here's a list of recommended next steps. ## Proposed Architecture
A three level architecture is proposed:
- Databases: both SQL (MySQL) and NoSQL (MongoDB)
- A "SQL-like" system for accessing these databases through an API ([Presto](https://prestodb.io/docs/current/index.html))
- An upper layer of processing (Spark...)
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! ![image info](DBTechnologyStack.png)
## Add your files ## Configuration
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files ### Docker
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: Apart from the ports on which the different components listen, you have to configure the users that Presto will use to make the connection with the different databases, in our case, only for MySQL:
``` | Variable| Description |
cd existing_repo | :--- | :--- |
git remote add origin https://git.code.tecnalia.com/urbanite/public/data-management-platform/storage/databases.git | `MYSQL_ROOT_PASSWORD` | The password for ROOT user, to create this user in MYSQL configuration.|
git branch -M main | `MYSQL_USER` | A user to be used by Presto. |
git push -uf origin main | `MYSQL_PASSWORD` | The password for MYSQL_USER. |
```
## Integrate with your tools
- [ ] [Set up project integrations](https://git.code.tecnalia.com/urbanite/public/data-management-platform/storage/databases/-/settings/integrations) ### Presto
Presto has four configuration files:
- Node Properties: environmental configuration specific to each node. A _node_ is a single installed instance of Presto on a machine.
- JVM Config: contains a list of command line options used for launching the Java Virtual Machine. The format of the file is a list of options, one per line.
- Config Properties: configuration for the Presto server. Every Presto server can function as both a coordinator and a worker, but dedicating a single machine to only perform coordination work provides the best performance on larger clusters.
- Log Properties (optional): allows setting the minimum log level for named logger hierarchies.
## Collaborate with your team Presto accesses data via _connectors_, which are mounted in catalogs. The connector provides all of the schemas and tables inside of the catalog.
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) More info: [Presto configuration](https://prestodb.io/docs/current/installation/deployment.html#configuring-presto)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy #### Catalogs
Catalogs are registered by creating a catalog properties file, in the `config/catalog` folder.
There are a lot of available connectors, the full list can be checked [here](https://prestodb.io/docs/current/connector.html).
Use the built-in continuous integration in GitLab. ##### MySQL
MySQL only needs the connection properties:
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) | Variable| Description | Example |
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) | :--- | :--- | :--- |
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) | `connector.name` | Type of the connector| Must be `mysql` |
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) | `connection-url` | JDBC connection URL| `jdbc:mysql://mysql:3306`|
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) | `connection-user` | JDBC connection user| `root` |
| `connection-password` | JDBC connection pasword| [password set in docker-compose file] |
*** More info: [Presto - MySQL Connector](https://prestodb.io/docs/current/connector/mysql.html)
# Editing this README ##### MongoDB
MongoDB has a set of configuration properties, but at least we need:
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. | Variable| Description | Example |
| :--- | :--- | :--- |
| `connector.name` | Type of the connector| Must be `mongodb` |
| `mongodb.seeds` | List of all mongod servers| `mongodb` (name of the container set in docker-compose file)|
| `mongodb.socket-keep-alive` | Enable keep-alive on each socket (recommended)| `true`|
## Suggestions for a good README More info: [Presto - MongoDB Connector](https://prestodb.io/docs/current/connector/mongodb.html)
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name ## Run
Choose a self-explaining name for your project.
## Description `$ sudo docker-compose up -d`
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges ## Presto CLI
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. The Presto Command Line Interface provides a terminal-based interactive shell (self-executing JAR file) for running queries.
To use it:
## Visuals 1. Download the [presto-cli-0.251-executable.jar](https://repo1.maven.org/maven2/com/facebook/presto/presto-cli/0.251/presto-cli-0.251-executable.jar) (latest version: 0.251)
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. 2. Rename it to `presto-cli` and make it executable with `chmod +x`
3. Run the client. For example, to access to the collection `urbanite` in MongoDB, we should run:
`$ ./presto --server localhost:8080 --catalog mongodb --schema urbanite`
## Installation More info: [Presto CLI ](https://prestodb.io/docs/current/installation/cli.html)
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. \ No newline at end of file
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
---
# brings up the dependencies
version: '2'
services:
presto:
container_name: urbanite_presto
build:
context: ./presto
dockerfile: Dockerfile
image: presto
links:
- mongodb
- mysql
depends_on:
- mongodb
- mysql
ports:
- "8080:8080"
- "8889:8889"
mysql:
container_name: urbanite_mysql
image: mysql:8.0.24
environment:
MYSQL_ROOT_PASSWORD: 'vNYTpUGmAP3786nu'
MYSQL_USER: 'presto'
MYSQL_PASSWORD: 'VUeqhwQ47pjA3aaL'
ports:
- "3306:3306"
volumes:
- /opt/mysql_data:/var/lib/mysql
mongodb:
container_name: urbanite_mongodb
image: mongo:4.0.24
ports:
- "27017:27017"
volumes:
- /opt/mongo_data:/data/db
FROM ahanaio/prestodb:0.251
ENV HOME=/opt/presto-server \
MYSQL_HOST=mysql \
MYSQL_ROOT_PASSWORD=vNYTpUGmAP3786nu \
MONGO_HOST=mongo
WORKDIR $HOME
# copy default set of config
COPY config/ $HOME/etc/
# copy the configuration customization script
COPY entrypoint.sh /opt/entrypoint.sh
# adding the config mounting point
VOLUME $HOME/etc/
# adding the data mounting point
VOLUME $HOME/data/
EXPOSE 8080
connector.name=mongodb
mongodb.seeds=MONGO_HOST
mongodb.socket-keep-alive=true
\ No newline at end of file
connector.name=mysql
connection-url=jdbc:mysql://MYSQL_HOST:3306
connection-user=root
connection-password=MYSQL_ROOT_PASSWORD
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8080
query.max-memory=5GB
query.max-memory-per-node=1GB
discovery-server.enabled=true
discovery.uri=http://presto:8080
-server
-Xmx16G
-XX:+UseG1GC
-XX:G1HeapRegionSize=32M
-XX:+UseGCOverheadLimit
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:OnOutOfMemoryError=kill -9 %p
com.facebook.presto=INFO
node.environment=urbanite
node.id=a7413702-23b4-11e6-bb6e-600308a67678
node.data-dir=/opt/presto/presto-server-0.157/data
#!/bin/sh
set -e
# customize presto config
find /opt/presto-server/etc/catalog -name "*.properties" -exec sed -i -e "s/MYSQL_HOST/$MYSQL_HOST/g" {} +
find /opt/presto-server/etc/catalog -name "*.properties" -exec sed -i -e "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/g" {} +
find /opt/presto-server/etc/catalog -name "*.properties" -exec sed -i -e "s/MONGO_HOST/$MONGO_HOST/g" {} +
# start presto as started in the dockerfile
echo "node.id=$HOSTNAME" >> $PRESTO_HOME/etc/node.properties
$PRESTO_HOME/bin/launcher run
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment