主要是根据官网内容配置,Presto详细的内容可参考官网
单机安装
1、下载presto-server-0.56.tar.gz,解压后在文件夹里创建etc目录
在etc下创建一下文件与目录:
config.properties : Presto 服务配置
jvm.config : Java虚拟机的命令行选项
log.properties : 日志信息
node.properties : 环境变量配置,每个节点特定配置
catalog目录 : 每个连接者配置(data sources)
(1)相关文件配置信息
config.properties
coordinator=true datasources=jmx,hive http-server.http.port=8080 presto-metastore.db.type=h2 presto-metastore.db.filename=var/db/MetaStore task.max-memory=1GB discovery-server.enabled=true discovery.uri=http://localhost:8080
datasources:指定多个catalog names,通过逗号分割,coordinator 与 workers均含有JMX来读取Java相关配置信息,另外可以配置hive等信息,当然coordinator最好不配置hive,减少协调器的负载
http-server.http.port:Presto通过Http协议进行交互,则配置该端口进行信息交互
presto-metastore.db.filename:Presto使用h2保存metadata,该配置是h2保存的本地文件存储
task.max-memory:节点中任务使用最大的内存,该参数对查询操作有一定的约束
discovery-server.enabled:Presto使用 Discovery service来定位集群中所有的节点。启动实例后向Discovery service注册。coordinator运行在嵌入式的Discovery service
discovery.uri:Discovery server的URI,单机版配置自身就OK
jvm.config
-server -Xmx16G -XX:+UseConcMarkSweepGC -XX:+ExplicitGCInvokesConcurrent -XX:+CMSClassUnloadingEnabled -XX:+AggressiveOpts -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError=kill -9 %p -XX:PermSize=150M -XX:MaxPermSize=150M -XX:ReservedCodeCacheSize=150M -Xbootclasspath/p:/home/hadoop/presto/lib/floatingdecimal-0.1.jar -Dhive.config.resources=/home/hadoop/presto/etc/hadoop/conf/core-site.xml,/home/hadoop/presto/etc/hadoop/conf/hdfs-site.xml
JVM相关参数配置,这些参数在编译时使用,不导入到shell,每个参数设置为一行,行尾切勿有空格
log.properties
com.facebook.presto=DEBUG
配置日志等级,类似于log4j。四个等级: DEBUG, INFO, WARN , ERROR
node.properties
node.environment=production node.id=e256ec90-e1ef-4fc6-8eb0-378f58e05987 node.data-dir=/data2/presto/datanode.environment:Presto的名称,所有节点在集群环境必须具有相同的名称
node.id:安装的唯一标识,在每个节点必须唯一,若一台机器含有多个实例,则 其id是一致的,linux可使用uuidgen命令生成32位的UUID
node.data-dir:本地文件路径,存放日志或其他数据
catalog目录
配置presto访问数据源的渠道
在etc目录下创建catalog目录
创建jmx.properties
connector.name=jmx创建hive.properties
connector.name=hive-hadoop1 hive.metastore.uri=thrift://localhost:9083 hive.config.resources=/home/hadoop/presto/etc/hadoop/conf/core-site.xml,/home/hadoop/presto/etc/hadoop/conf/hdfs-site.xml,/home/hadoop/presto/etc/hadoop/conf/mapred-site.xmlconnector.name:若hadoop集群是使用2.x系列,则为hive-cdh4,hive.metastore.uri则为hive server 后台进程,两种形式:
(1)metastore形式
hive --service metastore &默认端口是9083
(2)server形式
hive --service hiveserver -p 9083 &指定端口 配置完相关信息,则下载 presto-cli-0.56-executable.jar,presto交互接口,把jar包更名为presto(建议使用link方式) 启动presto服务
bin/launcher start 后台运行,日志信息为node.preperties配置的node.data-dir run为前台运行,使用help查看更多的选项 常用(start/run/stop/restart)使用jsp -ml 命令查看到,服务已经开启
29546 com.facebook.presto.server.PrestoServer打开交互接口
./presto --server localhost:8080 --catalog hive --schema default
presto:default> show tables; Table ----------------------------------------------- cw_a cw_b具体语法: http://prestodb.io/docs/current/sql.html 至今,单机部署成功。 2、集群配置 worker配置,即节点配置基本跟以上一致 (1)单独部署discovery server 下载: discovery-server-1.16.tar.gz 解压后在discovery下新建etc目录,etc目录下创建以下文件
config.properties : Presto 服务配置
http-server.http.port=8411
jvm.config : Java虚拟机的命令行选项
-server -Xmx1G -XX:+UseConcMarkSweepGC -XX:+ExplicitGCInvokesConcurrent -XX:+AggressiveOpts -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError=kill -9 %p
node.properties : 环境变量配置,每个节点特定配置
node.environment=production node.id=ffffffff-ffff-ffff-ffff-ffffffffffff node.data-dir=/data2/presto-server/data运行
bin/launcher startdiscovery运行与presto运行相似
查看进程
24064 io.airlift.discovery.server.DiscoveryServer
(2)修改presto的config.properties
coordinator节点
coordinator=true discovery-server.enabled=true discovery.uri=http://discovery.server.node.com:8411
worker节点
coordinator=false #discovery-server.enabled=true discovery.uri=http://discovery.server.node.com:8411coordinator,worker节点配置修改为以上 (3)运行
- 运行discovery-server
$DISCOVERY_SERVER_HOME/bin/launcher start
- 运行presto实例
$PRESTO_HOME/bin/launcher start
- 运行用户接口
./presto --server localhost:8080 --catalog hive --schema default
查看presto的log可以看到
discovery.uri连接信息:2014-01-11T13:36:30.120+0800 INFO main Bootstrap discovery.uri null http://183.61.2.158:8411 hadoop配置相关信息:2014-01-11T13:36:30.120+0800 INFO main Bootstrap hive.config.resources null [/home/hadoop/presto/etc/hadoop/conf/core-site.xml, /home/hadoop/presto/etc/hadoop/conf/hdfs-site.xml] 配置的node.id:2014-01-11T13:36:30.123+0800 INFO main Bootstrap node.id null e256ec90-e1ef-4fc6-8eb0-378f58e05987 hive-server信息:2014-01-11T13:36:30.120+0800 INFO main Bootstrap hive.metastore.uri null thrift://localhost:9083
成功启动的信息 2014-01-11T13:36:30.696+0800 DEBUG main com.facebook.presto.hive.RebindSafeMBeanServer io.airlift.node:name=NodeInfo already bound to io.airlift.node.NodeInfo[io.airlift.node:name=NodeInfo] 2014-01-11T13:36:30.753+0800 DEBUG main com.facebook.presto.hive.RebindSafeMBeanServer io.airlift.http.client:type=AsyncHttpClient,name=ForDiscoveryClient already bound to io.airlift.http.client.netty.NettyAsyncHttpClient[io.airlift.http.client:type=AsyncHttpClient,name=ForDiscoveryClient] 2014-01-11T13:36:30.755+0800 DEBUG main com.facebook.presto.hive.RebindSafeMBeanServer io.airlift.discovery.client:name=ServiceInventory already bound to io.airlift.discovery.client.ServiceInventory[io.airlift.discovery.client:name=ServiceInventory] 2014-01-11T13:36:30.927+0800 INFO main io.airlift.bootstrap.LifeCycleManager Life cycle starting... 2014-01-11T13:36:30.927+0800 INFO main io.airlift.bootstrap.LifeCycleManager Life cycle startup complete. System ready. 2014-01-11T13:36:30.935+0800 INFO main com.facebook.presto.metadata.CatalogManager Added catalog hive using connector hive-hadoop1 2014-01-11T13:36:30.939+0800 INFO main com.facebook.presto.metadata.CatalogManager Added catalog jmx using connector jmx 2014-01-11T13:36:30.987+0800 INFO main com.facebook.presto.server.PrestoServer ======== SERVER STARTED ========