Presto-[2]-Installation-Deploying Presto and Command Line Interface

来源:互联网 发布:软件测试的基本理论 编辑:程序博客网 时间:2024/06/08 04:21

Installing Presto

现在压缩包presto-server-0.191.tar.gz,

Presto需要一个文件夹存日志logs,etc,建议在安装问价外部新建一个文件夹,便于升级

 

Configuring Presto

在安装文件夹下建立一个etc文件夹,存如下配置文件:

  • Node Properties: 每个node的环境配置
  • JVM Config: command line options for the Java Virtual Machine
  • Config Properties: configuration for the Presto server
  • Catalog Properties: configuration for Connectors (data sources)

Node Properties

etc/node.properties:

node.environment=productionnode.id=ffffffff-ffff-ffff-ffff-ffffffffffffnode.data-dir=/var/presto/data
具体:
  • node.environment: environment名字.
  • node.id: 唯一标识Presto实例
  • node.data-dir: data文件夹,这里存 logs和其他数据.

JVM Config

etc/jvm.config:

-server-Xmx16G-XX:+UseG1GC-XX:G1HeapRegionSize=32M-XX:+UseGCOverheadLimit-XX:+ExplicitGCInvokesConcurrent-XX:+HeapDumpOnOutOfMemoryError-XX:+ExitOnOutOfMemoryError

Config Properties

etc/config.properties,server配置,Presto server可以作为coordinator和worker服务,Server配置样例:

coordinator=truenode-scheduler.include-coordinator=falsehttp-server.http.port=8080query.max-memory=50GBquery.max-memory-per-node=1GBdiscovery-server.enabled=truediscovery.uri=http://example.net:8080

 workers配置样例:

coordinator=falsehttp-server.http.port=8080query.max-memory=50GBquery.max-memory-per-node=1GBdiscovery.uri=http://example.net:8080

Alternatively, if you are setting up a single machine for testing that will function as both a coordinator and worker, use this configuration:

coordinator=truenode-scheduler.include-coordinator=truehttp-server.http.port=8080query.max-memory=5GBquery.max-memory-per-node=1GBdiscovery-server.enabled=truediscovery.uri=http://example.net:8080
具体说明:
  • coordinator: 将该节点作为coordinator.
  • node-scheduler.include-coordinator: 是否允许在coordinator服务中进行调度工作。对于大型的集群,在一个节点上的Presto server即作为coordinator又作为worke将会降低查询性能。因为如果一个服务器作为worker使用,那么大部分的资源都不会被worker占用,那么就不会有足够的资源进行关键任务调度、管理和监控查询执行
  • http-server.http.port:  HTTP server.的port
  • query.max-memory:  query的最大分布式内存
  • query.max-memory-per-node: 每个机器最大的内存
  • discovery-server.enabled: Discovery service用于感知集群中所有节点。每个 Presto instance将自己注册到Discovery service 。为了简化部署,避免运行一个额外的服务。 Presto coordinator 可以运行一个内嵌的 Discovery service
  • discovery.uri: Discovery server的URI,这里和coordinator的URI一样

其他 properties:

  • jmx.rmiregistry.port: JMX RMI registry的port ,JMX clients 连接这个port
  • jmx.rmiserver.port: JMX RMI server 的port. Presto exports many metrics that are useful for monitoring via JMX.

See also Resource Groups.

Log Levels

 etc/log.properties,在这个配置文件中允许根据不同的日志结构设置不同的日志级别。每个logger都有一个名字(通常是使用logger的类的全标示类名). Loggers通过名字中的“.“来表示层级和集成关系。 (像java里面的包). 如下面的log配置信息:

com.facebook.presto=INFO

这会同时为 com.facebook.presto.server and com.facebook.presto.hive配置日志级别INFO,一共有4个日志级别:DEBUGINFOWARN and ERROR.

Catalog Properties

Presto通过connectors 获取数据,connectors在catalogs配置。connector提供schemas and tables,例如Hive connector 将hive database 映射到schema。例如hive connector 组织在hive catalog中,Hive的web库下中含有一张clicks表,Presto以hive.web.clicks.识别这张表。 Connectors 中详细说明各种类型的connectors

Running Presto

启动脚本 bin/launcher. 以后台形式运行:

bin/launcher start

也可以在前台运行, 日志和相关输出将会写入stdout/stderr(可以使用类似daemontools的工具捕捉这两个数据流):

bin/launcher run
运行bin/launcher–help,Presto将会列出支持的命令和命令行选项。 另外可以通过运行bin/launcher --verbose命令,来调试安装是否正确

启动后日志文件在 var/log:

  • launcher.log: 这个日志文件由launcher创建,并且server的stdout和stderr都被重定向到了这个日志文件中。 这份日志文件中只会有很少的信息,包括在server日志系统初始化的时候产生的日志和JVM产生的诊断和测试信息
  • server.log:  Presto的主要日志文件.
  • http-request.log: server接收到的http log  

Command Line Interface

Presto CLI为用户提供了一个用于查询的可交互终端窗口。CLI是一个可执行JAR文件, 这也就意味着你可以像UNIX终端窗口一样来使用CLI。

下载 presto-cli-0.191-executable.jar,重名名为 presto , 使用 chmod +x 命令设置可执行权限,然后执行:

./presto --server localhost:8080 --catalog hive --schema default

使用 --help 选项运行CLI,可以看到可用的选项

默认情况下,查询的结果是分页的。而这种分页的实现不需要你去编写什么代码,而是通过配置一系列的配置信息来实现的。你也可以通过将环境变量:PRESTO_PAGER 设置为你自己的程序名称来自己实现分页或者也可以PRESTO_PAGER 的值设置为空,从而禁止分页

原创粉丝点击