Presto集群搭建
环境说明
主机 | coordinator | worker |
---|---|---|
data-repo-03 | √ | × |
data-repo-04 | × | √ |
data-repo-05 | × | √ |
data-repo-06 | × | √ |
data-repo-07 | × | √ |
1.下载presto
wget https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.242/presto-server-0.242.tar.gz
2.解压presto
tar -zxvf presto-server-0.242.tar.gz.gz
mv presto-server-0.242 presto-0.242
3.设置环境变量
vim /etc/profile
export PRESTO_HOME=/app/hadoop/software/presto-0.242
export PATH=$PRESTO/bin:$PATH
source /etc/profile
4.创建目录
mkdir -p {data,etc,etc/catalog}
5.生成node.properties配置文件
# 配置工作节点
vim etc/node.properties
配置内容:
node.environment=production
node.id=node1
node.data-dir=/app/hadoop/software/presto-0.242/data
6.生成jvm.config配置文件
vim etc/jvm.config
配置内容:
-server
-Xmx8G
-XX:+UseG1GC
-XX:G1HeapRegionSize=32M
-XX:+UseGCOverheadLimit
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:+ExitOnOutOfMemoryError
7.生成config.properties配置文件
vim etc/config.properties
配置内容:
在data-repo-03节点(coordinator)配置:
# 允许此Presto实例充当协调器(接受来自客户端的查询并管理查询执行,正式环境协调者应该为单独一台机器会比较高效)
coordinator=true
# 允许在协调器上安排工作。对于较大的集群,协调器上的处理工作可能会影响查询性能,因为计算机的资源不可用于调度,管理和监视查询执行的关键任务。(true:协调器节点上作为worker节点,false:协调器节点只负责协调)
node-scheduler.include-coordinator=false
# 指定HTTP服务器的端口。Presto使用HTTP进行内部和外部的所有通信。
http-server.http.port=5100
# 表示单个查询在分布在所有相关节点上能用的内存之和的最大值,默认小于query.max-memory-per-node * worker
query.max-memory=7GB
# 表示单个查询在单个节点上用户内存能用的最大值,默认jvm * 0.1
query.max-memory-per-node=2GB
# 表示单个查询在单个节点上用户内存能用的最大值和系统内存量。其中系统内存是读取器、写入器和网络缓冲区等在执行期间使用的内存,默认大于query.max-memory-per-node
query.max-total-memory-per-node=3GB
# Presto使用Discovery服务查找群集中的所有节点。每个Presto实例都会在启动时使用Discovery服务注册自己。为了简化部署并避免运行其他服务,Presto协调器可以运行Discovery服务的嵌入式版本。它与Presto共享HTTP服务器,因此使用相同的端口。
discovery-server.enabled=true
# Discovery服务器的URI。因为我们在Presto协调器中启用了Discovery的嵌入式版本,所以它应该是Presto协调器的URI。替换example.net:8080以匹配Presto协调器的主机和端口。此URI不得以斜杠结尾。
discovery.uri=http://data-repo-03:5100
在data-repo-04~data-repo-07节点(worker)配置:
# worker节点设置false
coordinator=false
http-server.http.port=5100
query.max-memory=7GB
query.max-memory-per-node=2GB
query.max-total-memory-per-node=3GB
discovery.uri=http://data-repo-03:5100
8.修改log.properties配置文件
vim etc/log.properties
配置内容:
com.facebook.presto = INFO
9.配置hive连接器
vim etc/catalog/hive.properties
配置内容:
# 连接器名称(不要修改)
connector.name=hive-hadoop2
# hive metastore的ip和端口
hive.metastore.uri=thrift://data-repo-01:9083,thrift://data-repo-02:9083
# 可选,选择hdfs-site.xml和core-site.xml(hive中有配置暂不配该选项)
#hive.config.resources=/app/hadoop/software/hadoop-2.9.2/etc/hadoop/core-site.xml,/app/hadoop/software/hadoop-2.9.2/etc/hadoop/hdfs-site.xml
10.将Presto目录copy到worker节点
scp -r presto-0.242/ hadoop@data-repo-04:~/software/
scp -r presto-0.242/ hadoop@data-repo-05:~/software/
scp -r presto-0.242/ hadoop@data-repo-06:~/software/
scp -r presto-0.242/ hadoop@data-repo-07:~/software/
11.配置worker节点
- 修改
vim etc/node.properties
的node.id属性 - 修改
vim etc/config.properties
,配置内容见第7步
12.启动Presto(所有Presto节点上执行)
./bin/launcher start
13.使用Presto cli连接Presto server
# 下载cli
wget https://repo1.maven.org/maven2/com/facebook/presto/presto-cli/0.242/presto-cli-0.242-executable.jar
# 添加执行权限
chmod +x presto-cli-0.242-executable.jar
# 连接presto
./presto-cli-0.242-executable.jar --server data-repo-03:5100 --catalog hive --schema default
# 查看所有数据库,相当于hive中的show databases
show schemas;
14.Presto webui
web ui:http://data-repo-03:5100/ui/
常见问题
1.java.net.UnknownHostException: hadoop-cluster
解决办法:
vim etc/catalog/hive.properties
添加配置:
hive.config.resources=/app/hadoop/software/hadoop-2.9.2/etc/hadoop/core-site.xml,/app/hadoop/software/hadoop-2.9.2/etc/hadoop/hdfs-site.xml
版权属于:版权归 bbmax.cc 所有,转载请注明出处
本文链接:https://www.bbmax.cc/index.php/archives/25/
转载时须注明出处及本声明