prestodb安装配置 —参考prestodb官方文档配置
2016-02-26 14:49
567 查看
# prestodb安装配置 —参考prestodb官方文档配置
# by coco
# 20160225
目前prestodb最新版本已经到了0.139,但是官方给出的配置文档还是0.100的,所以就选取了0.100版本的进行配置测试。
1. 安装环境
操作系统:CentOS release 6.2 (Final)
hadoop集群:CDH-5.5.1-1
JDK版本:jdk1.8.0_73 注意:(jdk1.6.0_31版本的不行,启动会报错,最终导致启动不起来这个已经测试过。)
2. 安装Presto
下载Presto
server tarball, presto-server-0.100.tar.gz,将它解压。
wget https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.100/presto-server-0.100.tar.gz
可以运行
presto:wwn> show tables;
Table
--------------
cm_vip
pdcheck_hlbr
(2 rows)
Query 20160226_062024_00016_92ghf, FINISHED, 1 node
Splits: 2 total, 2 done (100.00%)
0:00 [2 rows, 116B] [22 rows/s, 1.26KB/s]
6. 测试 jdbc
使用 jdbc 连接 Presto,需要下载 jdbc 驱动 presto-jdbc-0.100 并将其加到你的应用程序的 classpath 中。支持以下几种 JDBC URL 格式:
# by coco
# 20160225
目前prestodb最新版本已经到了0.139,但是官方给出的配置文档还是0.100的,所以就选取了0.100版本的进行配置测试。
1. 安装环境
操作系统:CentOS release 6.2 (Final)
hadoop集群:CDH-5.5.1-1
JDK版本:jdk1.8.0_73 注意:(jdk1.6.0_31版本的不行,启动会报错,最终导致启动不起来这个已经测试过。)
2. 安装Presto
下载Presto
server tarball, presto-server-0.100.tar.gz,将它解压。
wget https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.100/presto-server-0.100.tar.gz
tar zxvf presto-server-0.100.tar.gz -C /usr/local/[/code]
ln -s /usr/local/presto-server-0.100/ /usr/local/prestodb
cd prestodb/
3. 配置 Presto
在 presto-server-0.100 目录创建 etc 目录,并创建以下文件:node.properties:每个节点的环境配置
jvm.config:jvm 参数
config.properties:配置 Presto Server 参数
log.properties:配置日志等级
Catalog Properties:Catalog 的配置
etc/node.properties示例配置如下:
node.environment=production node.id=ffffffff-ffff-ffff-ffff-ffffffffffff node.data-dir=/var/presto/data参数说明:
node.environment:环境名称。一个集群节点中的所有节点的名称应该保持一致。
node.id:节点唯一标识的名称。
node.data-dir:数据和日志存放路径。
etc/jvm.config示例配置如下:
-server -Xmx16G -XX:+UseConcMarkSweepGC -XX:+ExplicitGCInvokesConcurrent -XX:+CMSClassUnloadingEnabled -XX:+AggressiveOpts -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError=kill -9 %p -XX:ReservedCodeCacheSize=150M
etc/config.properties包含 Presto Server 相关的配置,每一个 Presto Server 可以通时作为 coordinator 和 worker 使用。你可以将他们配置在一个极点上,但是,在一个大的集群上建议分开配置以提高性能。coordinator 的最小配置:
coordinator=true node-scheduler.include-coordinator=false http-server.http.port=8080 task.max-memory=1GB discovery-server.enabled=true discovery.uri=http://cdh1:8080worker 的最小配置:
coordinator=false http-server.http.port=8080 task.max-memory=1GB discovery.uri=http://cdh1:8080可选的,作为测试,你可以在一个节点上同时配置两者:
coordinator=true node-scheduler.include-coordinator=true http-server.http.port=8080 task.max-memory=1GB discovery-server.enabled=true discovery.uri=http://cdh1:8080参数说明:
coordinator:Presto 实例是否以 coordinator 对外提供服务
node-scheduler.include-coordinator:是否允许在 coordinator 上进行调度任务
http-server.http.port:HTTP 服务的端口
task.max-memory=1GB:每一个任务(对应一个节点上的一个查询计划)所能使用的最大内存
discovery-server.enabled:是否使用 Discovery service 发现集群中的每一个节点。
discovery.uri:Discovery server 的 url
etc/log.properties可以设置某一个 java 包的日志等级:
com.facebook.presto=INFO关于 Catalog 的配置,首先需要创建 etc/catalog 目录,然后根据你想使用的连接器来创建对应的配置文件,比如,你想使用 jmx 连接器,则创建 jmx.properties:
connector.name=jmx如果你想使用 hive 的连接器,则创建 hive.properties:
connector.name=hive-cdh5 hive.metastore.uri=thrift://cdh1:9083 #修改为 hive-metastore 服务所在的主机名称,这里我是安装在 cdh1节点 hive.config.resources=/etc/hadoop/conf/core-site.xml,/etc/hadoop/conf/hdfs-site.xml更多关于连接器的说明,请参考 Connectors 。
4. 运行 Presto
你可以使用下面命令后台启动:bin/launcher start也可以前台启动,观察输出日志:
bin/launcher run另外,你也可以通过下面命令停止:
bin/launcher stop更多命令,你可以通过
--help参数来查看。
[root@cdh1 presto-server-0.100]# bin/launcher --help Usage: launcher [options] command Commands: run, start, stop, restart, kill, status Options: -h, --help show this help message and exit -v, --verbose Run verbosely --launcher-config=FILE Defaults to INSTALL_PATH/bin/launcher.properties --node-config=FILE Defaults to INSTALL_PATH/etc/node.properties --jvm-config=FILE Defaults to INSTALL_PATH/etc/jvm.config --config=FILE Defaults to INSTALL_PATH/etc/config.properties --log-levels-file=FILE Defaults to INSTALL_PATH/etc/log.properties --data-dir=DIR Defaults to INSTALL_PATH --pid-file=FILE Defaults to DATA_DIR/var/run/launcher.pid --launcher-log-file=FILE Defaults to DATA_DIR/var/log/launcher.log (only in daemon mode) --server-log-file=FILE Defaults to DATA_DIR/var/log/server.log (only in daemon mode) -D NAME=VALUE Set a Java system property启动之后,你可以观察 /var/presto/data/ 目录:
[root@cdh1 /var/presto/data/]# tree . ├── etc -> /opt/presto-server-0.90/etc ├── plugin -> /opt/presto-server-0.90/plugin └── var ├── log │ ├── http-request.log │ ├── launcher.log │ └── server.log └── run └── launcher.pid 5 directories, 4 files在 /var/presto/data/var/log 目录可以查看日志:
launcher.log:启动日志
server.log:Presto Server 输出日志
http-request.log:HTTP 请求日志
5. 测试 Presto CLI
Presto CLI为用户提供了一个用于查询的可交互终端窗口。CLI是一个 可执行 JAR文件, 这也就意味着你可以像UNIX终端窗口一样来使用CLI。下载 presto-cli-0.100-executable.jar 并将其重命名为 presto-cli(你也可以重命名为 presto),然后添加执行权限。运行下面命令进行测试:wget https://repo1.maven.org/maven2/com/facebook/presto/presto-cli/0.100/presto-cli-0.100-executable.jar
[root@localhost prestodb]# ./presto-cli --server localhost:8080 --catalog hive --schema wwn presto:wwn> show tables; Table -------- cm_vip (1 row) Query 20160226_064104_00021_92ghf, FINISHED, 1 node Splits: 2 total, 2 done (100.00%) 0:00 [1 rows, 91B] [13 rows/s, 1.18KB/s]
presto:wwn> select * from cm_vip limit 3; vid | uid | username | begintime | endtime | edittime | viptype | aid | status | vipfrom | is_contpay | version | cid | o -----+---------+----------------+------------+------------+------------+---------+-----+--------+---------+------------+---------+-----+-- 1 | 1125693 | dggyth | 1333695600 | 1383062400 | 1383009369 | 2 | 1 | -1 | false | true | true | 0 | 2 | 153 | shibangjq | 1331791200 | 1363276800 | 1383030061 | 0 | 1 | -1 | false | true | true | 0 | 3 | 417604 | Kefidmachinery | 1438358400 | 1469980800 | 1438391633 | 2 | 1 | 1 | true | true | true | 0 | (3 rows)在 执行 show tables 命令之前,你可以查看 http://cdh1:8080/ 页面:
可以运行
--help命令查看更多参数,例如你可以在命令行直接运行下面命令:
[root@localhost prestodb]# ./presto-cli --server localhost:8080 --catalog hive --schema wwn --execute "show tables;" "cm_vip"默认情况下,Presto 的查询结果是使用
less程序分页输出的,你可以通过修改环境变量
PRESTO_PAGER的值将其改为其他命令,如
more,或者将其置为空以禁止分页输出。测试连接mysql:[root@localhost prestodb]# ./presto-cli --server localhost:8080 --catalog mysql --schema wwn
presto:wwn> show tables;
Table
--------------
cm_vip
pdcheck_hlbr
(2 rows)
Query 20160226_062024_00016_92ghf, FINISHED, 1 node
Splits: 2 total, 2 done (100.00%)
0:00 [2 rows, 116B] [22 rows/s, 1.26KB/s]
6. 测试 jdbc
使用 jdbc 连接 Presto,需要下载 jdbc 驱动 presto-jdbc-0.100 并将其加到你的应用程序的 classpath 中。支持以下几种 JDBC URL 格式:
jdbc:presto://host:port jdbc:presto://host:port/catalog jdbc:presto://host:port/catalog/schema连接 hive 数据库中 sales 库,示例如下:
jdbc:presto://cdh1:8080/hive/sales
7. 总结
本文主要记录 Presto 的安装部署过程,并使用 hive-cdh5 连接器进行简单测试。下一步,需要基于一些生产数据做一些功能测试以及和 impala 做一些对比测试。相关文章推荐
- iOS程序猿之图片压缩
- C语言内存管理分析
- ASP.NET MVC RouteExistingFiles
- jquery PrintArea 实现票据的套打
- iptables指令详解
- Java操作Ant压缩和解压文件及批量打包Anroid应用
- iOS UIScrollView无法滑动/偏移的解决方法
- 分区表管理操作
- python处理excel
- freeradius and jradius configuration
- ECSHOP购物车商品自动清空问题解决方法改善会员体验
- 0:编写虚幻引擎中的UC和C++代码
- ZOJ 3870
- MFC的使用技巧(如何彻底删除一个类)
- android:clipChildren属性
- 安装phpMyAdmin图文教程
- 修改应用程序名称
- 268. Missing Number
- [leetcode] 266. Palindrome Permutation 解题报告
- linux中grep使用方法具体解释