Apache Presto 简明教程
Apache Presto - Installation
本章将解释如何在您的机器上安装 Presto。让我们了解 Presto 的基本要求,
This chapter will explain how to install Presto on your machine. Let’s go through the basic requirements of Presto,
-
Linux or Mac OS
-
Java version 8
现在,让我们继续执行以下步骤在您的机器上安装 Presto。
Now, let’s continue the following steps to install Presto on your machine.
Verifying Java installation
希望您现在已在您的机器上安装了 Java 8,您只需使用以下命令对其进行验证。
Hopefully, you have already installed Java version 8 on your machine right now, so you just verify it using the following command.
$ java -version
如果 Java 已成功安装在您的机器上,您将看到已安装的 Java 版本。如果未安装 Java,请按照后续步骤在您的机器上安装 Java 8。
If Java is successfully installed on your machine, you could see the version of installed Java. If Java is not installed, follow the subsequent steps to install Java 8 on your machine.
下载 JDK。访问以下链接下载最新版本的 JDK。
Download JDK. Download the latest version of JDK by visiting the following link.
最新版本是 JDK 8u 92,文件为 “jdk-8u92-linux-x64.tar.gz”。请在您的机器上下载该文件。
The latest version is JDK 8u 92 and the file is “jdk-8u92-linux-x64.tar.gz”. Please download the file on your machine.
然后,解压文件并移动到指定目录。
After that, extract the files and move to the specific directory.
然后设置 Java 替代项。最终,Java 将安装在您的机器上。
Then set Java alternatives. Finally Java will be installed on your machine.
Apache Presto Installation
访问以下链接下载最新版本的 Presto,
Download the latest version of Presto by visiting the following link,
现在,“presto-server-0.149.tar.gz” 的最新版本将下载到您的机器上。
Now the latest version of “presto-server-0.149.tar.gz” will be downloaded on your machine.
Configuration Settings
Create “data” directory
在安装目录之外创建一个数据目录,该目录将用于存储日志、元数据等,以便在升级 Presto 时可以轻松保存。可使用以下代码定义该目录 −
Create a data directory outside the installation directory, which will be used for storing logs, metadata, etc., so that it is to be easily preserved when upgrading Presto. It is defined using the following code −
$ cd
$ mkdir data
要查看它的位置路径,请使用命令“pwd”。此位置将在次の节点配置文件中分配。
To view the path where it is located, use the command “pwd”. This location will be assigned in the next node.properties file.
Create “etc” directory
使用以下代码在 Presto 安装目录内创建一个等目录 −
Create an etc directory inside Presto installation directory using the following code −
$ cd presto-server-0.149
$ mkdir etc
该目录将保存配置文件。让我们逐个创建每个文件。
This directory will hold configuration files. Let’s create each file one by one.
Node Properties
Presto 节点配置文件包含特定于每个节点的环境配置。使用以下代码在等目录 (etc/node.properties) 中创建该文件 −
Presto node properties file contains environmental configuration specific to each node. It is created inside etc directory (etc/node.properties) using the following code −
$ cd etc
$ vi node.properties
node.environment = production
node.id = ffffffff-ffff-ffff-ffff-ffffffffffff
node.data-dir = /Users/../workspace/Presto
完成所有更改后,保存文件并退出终端。其中 node.data 是上述创建的 data 目录的位置路径。 node.id 表示每个节点的唯一标识符。
After making all the changes, save the file, and quit the terminal. Here node.data is the location path of the above created data directory. node.id represents the unique identifier for each node.
JVM Config
在 etc 目录中创建一个文件 “jvm.config”(etc/jvm.config)。此文件包含用于启动 Java 虚拟机的命令行选项列表。
Create a file “jvm.config” inside etc directory (etc/jvm.config). This file contains a list of command line options used for launching the Java Virtual Machine.
$ cd etc
$ vi jvm.config
-server
-Xmx16G
-XX:+UseG1GC
-XX:G1HeapRegionSize = 32M
-XX:+UseGCOverheadLimit
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:OnOutOfMemoryError = kill -9 %p
完成所有更改后,保存文件并退出终端。
After making all the changes, save the file, and quit the terminal.
Config Properties
在 etc 目录中创建一个文件 “config.properties”(etc/config.properties)。此文件包含 Presto 服务器的配置。如果设置一台机器用于测试,Presto 服务器只能充当使用以下代码定义的协调进程 −
Create a file “config.properties” inside etc directory(etc/config.properties). This file contains the configuration of Presto server. If you are setting up a single machine for testing, Presto server can function only as the coordination process as defined using the following code −
$ cd etc
$ vi config.properties
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://localhost:8080
在此,
Here,
-
coordinator − master node.
-
node-scheduler.include-coordinator − Allows scheduling work on the coordinator.
-
http-server.http.port − Specifies the port for the HTTP server.
-
query.max-memory=5GB − The maximum amount of distributed memory.
-
query.max-memory-per-node=1GB − The maximum amount of memory per node.
-
discovery-server.enabled − Presto uses the Discovery service to find all the nodes in the cluster.
-
discovery.uri − he URI to the Discovery server.
如果设置多台机器 Presto 服务器,Presto 将充当协调进程和工作进程。使用此配置设置在多台机器上测试 Presto 服务器。
If you are setting up multiple machine Presto server, Presto will function as both coordination and worker process. Use this configuration setting to test Presto server on multiple machines.
Configuration for Coordinator
$ cd etc
$ vi config.properties
coordinator = true
node-scheduler.include-coordinator = false
http-server.http.port = 8080
query.max-memory = 50GB
query.max-memory-per-node = 1GB
discovery-server.enabled = true
discovery.uri = http://localhost:8080
Configuration for Worker
$ cd etc
$ vi config.properties
coordinator = false
http-server.http.port = 8080
query.max-memory = 50GB
query.max-memory-per-node = 1GB
discovery.uri = http://localhost:8080
Log Properties
在 etc 目录中创建一个文件 “log.properties”(etc/log.properties)。此文件包含命名日志记录程序层次结构的最低日志级别。它使用以下代码定义 −
Create a file “log.properties” inside etc directory(etc/log.properties). This file contains minimum log level for named logger hierarchies. It is defined using the following code −
$ cd etc
$ vi log.properties
com.facebook.presto = INFO
保存文件并退出终端。在此,使用了 DEBUG、INFO、WARN 和 ERROR 四个日志级别。默认日志级别为 INFO。
Save the file and quit the terminal. Here, four log levels are used such as DEBUG, INFO, WARN and ERROR. Default log level is INFO.
Catalog Properties
在 etc 目录中创建一个目录 “catalog”(etc/catalog)。这将用于装载数据。例如,使用以下内容创建 etc/catalog/jmx.properties ,以将 jmx connector 装载为 jmx 目录 −
Create a directory “catalog” inside etc directory(etc/catalog). This will be used for mounting data. For example, create etc/catalog/jmx.properties with the following contents to mount the jmx connector as the jmx catalog −
$ cd etc
$ mkdir catalog
$ cd catalog
$ vi jmx.properties
connector.name = jmx
Start Presto
可以使用以下命令启动 Presto,
Presto can be started using the following command,
$ bin/launcher start
然后,您将看到类似于此的响应,
Then you will see the response similar to this,
Started as 840
Run Presto
若要启动 Presto 服务器,请使用以下命令 −
To launch Presto server, use the following command −
$ bin/launcher run
在成功启动 Presto 服务器后,您可在 “var/log” 目录中找到日志文件。
After successfully launching Presto server, you can find log files in “var/log” directory.
-
launcher.log − This log is created by the launcher and is connected to the stdout and stderr streams of the server.
-
server.log − This is the main log file used by Presto.
-
http-request.log − HTTP request received by the server.
到目前为止,您已在自己的计算机上成功安装了 Presto 配置设置。让我们继续执行步骤来安装 Presto CLI。
As of now, you have successfully installed Presto configuration settings on your machine. Let’s continue the steps to install Presto CLI.
Install Presto CLI
Presto CLI 提供了基于终端的交互式 shell,用于运行查询。
The Presto CLI provides a terminal-based interactive shell for running queries.
通过访问以下链接下载 Presto CLI,
Download the Presto CLI by visiting the following link,
现在,您的计算机上将安装“presto-cli-0.149-executable.jar”。
Now “presto-cli-0.149-executable.jar” will be installed on your machine.
Run CLI
在下载 presto-cli 后,将其复制到要从中运行它的位置。此位置可以是具有到协调器网络访问权限的任何节点。首先将 Jar 文件的名称更改为 Presto。然后使用以下代码通过 chmod + x 命令使其可执行 −
After downloading the presto-cli, copy it to the location which you want to run it from. This location may be any node that has network access to the coordinator. First change the name of the Jar file to Presto. Then make it executable with chmod + x command using the following code −
$ mv presto-cli-0.149-executable.jar presto
$ chmod +x presto
现在使用以下命令执行 CLI,
Now execute CLI using the following command,
./presto --server localhost:8080 --catalog jmx --schema default
Here jmx(Java Management Extension) refers to catalog and default referes to schema.
您将看到以下响应,
You will see the following response,
presto:default>
现在,在您的终端上键入“jps”命令,您将看到正在运行的守护程序。
Now type “jps” command on your terminal and you will see the running daemons.