Presto 安装和简单使用
0. 集群工具脚本
ccmd.sh 集群命令执行
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31cd && cat > ccmd.sh << 'EOF' #!/bin/bash if((0==$#)); then echo no args; echo "Usage: $0 cmd1; cmd2; cmd3" # 多个命令用分号隔开 exit; fi # cd -P 透过软连接获取绝对路径 pdir=`cd -P . ; pwd` # 修改seq 范围以覆盖更多节点 for i in $(seq 102 105); do host="hadoop$i" # 对于本机的命令最后再执行 if [ $host = $(hostname) ]; then continue; fi echo -e "====================tt$hosttt====================" echo -e "$pdir $*" ssh $host "cd $pdir ; $*" done # 最后执行本机的命令 echo -e "====================tt$(hostname)tt====================" echo -e "$pdir $*" ssh $(hostname) "cd $pdir ; $*" EOF # 赋予脚本执行权限 chmod +x ccmd.sh # 移到随时可以调用的目录 sudo mv ccmd.sh /usr/local/bin/
xsync.sh 集群文件同步
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36cd && cat > xsync.sh << 'EOF' #!/bin/bash #1 获取输入参数个数,如果没有参数,直接退出 pcount=$# if((pcount==0)); then echo no args; exit; fi #2 获取文件名称 p1=$1 fname=`basename $p1` echo fname=$fname #3 获取上级目录到绝对路径 pdir=`cd -P $(dirname $p1); pwd` echo pdir=$pdir #4 获取当前用户名称 user=`whoami` #5 循环分发,跳过本机,一般是102~104 做集群 for((host=102; host<105; host++)); do echo ------------------- hadoop$host ---------------- if [ hadoop$host != $(hostname) ]; then rsync -rvl $pdir/$fname $user@hadoop$host:$pdir fi done EOF # 赋予脚本执行权限 chmod +x xsync.sh # 移到随时可以调用的目录 sudo mv xsync.sh /usr/local/bin/
1. Presto 下载安装
官网地址:https://prestodb.github.io/
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79# 1. 下载Presto cd && wget https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.196/presto-server-0.196.tar.gz # 2. 解压Presto cd && tar -xf presto-server-0.196.tar.gz -C /opt/modules cd /opt/modules && mv presto-server-0.196 presto-0.196 # 3. 创建文件夹保存数据和配置 mkdir -p /opt/modules/presto-0.196/{data,etc/catalog} # 4. 创建JVM 配置文件 cat > /opt/modules/presto-0.196/etc/jvm.config << 'EOF' -server -Xmx16G -XX:+UseG1GC -XX:G1HeapRegionSize=32M -XX:+UseGCOverheadLimit -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:+ExitOnOutOfMemoryError EOF # 5. 创建Presto 的数据源Catalog cat > /opt/modules/presto-0.196/etc/catalog/hive.properties << 'EOF' # hive-hadoop2 是Presto 的数据源类型 connector.name=hive-hadoop2 # 指定Hive 的metastore 服务地址 hive.metastore.uri=thrift://hadoop113:9083 EOF # 6. 创建节点属性配置文件 ## 每个节点的id 都不一样,后面分发完再修改 cat > /opt/modules/presto-0.196/etc/node.properties << 'EOF' node.id=xxxx node.environment=production node.data-dir=/opt/modules/presto-0.196/data EOF # 7. 创建coordinator 配置 cat > /opt/modules/presto-0.196/etc/config.properties.co << 'EOF' coordinator=true node-scheduler.include-coordinator=false http-server.http.port=8881 query.max-memory=50GB discovery-server.enabled=true discovery.uri=http://hadoop112:8881 EOF # 8. 创建worker 配置 cat > /opt/modules/presto-0.196/etc/config.properties.wo << 'EOF' coordinator=false http-server.http.port=8881 query.max-memory=50GB discovery.uri=http://hadoop112:8881 EOF # 9. 复制lzo 压缩支持包,重要!!! ## 注意!放到hive-hadoop2 目录下,这是数据源类型,否则HDFS 中用lzo 压缩的文件无法读取 cp /opt/modules/hadoop-2.7.2/share/hadoop/common/hadoop-lzo-0.4.20.jar /opt/modules/presto-0.196/plugin/hive-hadoop2/ ## 另外,Presto 不能直接读取纯lzo 文件,但可以读取parquet 存储的lzo 文件,当然orc 存储的也可以 ## 据说Presto 对orc 这种列式存储进行了优化,推荐使用orc+lzo 的方式存储数据 # 10. 分发Presto 程序到集群其他节点 xsync.sh /opt/modules/presto-0.196 # 11. 修改集群中各Presto 节点ID 为该节点的主机名 ccmd.sh 'sed -i "/node.id/d; 1 i node.id=$(hostname)" /opt/modules/presto-0.196/etc/node.properties' # 12. 指定Presto 的coordinator ssh hadoop112 'cd /opt/modules/presto-0.196/etc && cp config.properties.co config.properties' # 13. 指定Presto 的worker for host in hadoop113 hadoop114; do ssh $host 'cd /opt/modules/presto-0.196/etc && cp config.properties.wo config.properties' done
2. Presto 集群启停
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13# 0. 启动Hive MetaStore 服务 ## 这里以Hive 装在hadoop113 为例 ssh hadoop113 'nohup /opt/modules/hive-2.3.6/bin/hive --service metastore &> /opt/modules/hive-2.3.6/log/metasotre.log &' # 1. 启动Presto 集群 ## /opt/modules/presto-0.196/bin/launcher run # 为前台运行,可查看日志 ccmd.sh '/opt/modules/presto-0.196/bin/launcher start' ## 日志目录,/opt/modules/presto-0.196/data/var/log # 2. 停止Presto 集群 ccmd.sh '/opt/modules/presto-0.196/bin/launcher stop'
3. Presto 集群脚本
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25# 指定Presto 版本 _VERSION=0.196 # 创建Presto 脚本 cd && cat > presto.sh << EOF #!/bin/bash _usage="Usage: $0 <start|stop|status|restart>" if [ $# -lt 1 ]; then echo "$_usage"; exit 1; fi for host in hadoop112 hadoop113 hadoop114; do echo "================ $host ====================" ssh $host "cd /opt/modules/presto-$_VERSION && bin/launcher $1" done EOF # 赋予脚本执行权限x cd && chmod +x presto.sh # 使用样例 ./presto.sh start # 启动Presto ./presto.sh stop # 停止Presto ./presto.sh status # 查看Presto
4. Presto 简单使用
Presto CLI
安装Presto CLI
复制代码
1
2
3
4
5
6
7
8
9
10
11# 1. 下载Presto 客户端 cd && wget https://repo1.maven.org/maven2/com/facebook/presto/presto-cli/0.196/presto-cli-0.196-executable.jar # 2. 给客户端程序赋权 mv presto-cli-0.196-executable.jar prestocli.jar && chmod +x $_ # 3. 启动Presto 客户端 ## 连上Presto 的coordinator ./prestocli --server hadoop112:8881 --catalog hive --schema default
使用Presto CLI
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21-- 0. 显示当前有多少schema show schemas; -- 1. 切换schema 即数据库 use gmall; -- 2. 显示当前数据库的表 show tables; -- 3. 查询表数据 select * from dwd_fact_cart_info; -- 或者用schema.tablename select * from gmall.dwd_fact_cart_info; -- 注意!查询结果按q 键退出,按/ 键还可以查询 -- 4. 退出客户端 quit -- 或者 exit
Presto Web
编译yanagishima
最好专门准备一台编译用的机器
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24# 0. 安装编译相关工具 ## 注意各个软件的具体版本 ## 0.1 JDK 8 java version "1.8.0_241" ## 0.2 编译工具,Ubuntu 14.04.6 sudo apt install git gcc g++ make unzip build-essential -y ## 0.3 NodeJS 8.16.2 wget https://nodejs.org/dist/v8.16.2/node-v8.16.2-linux-x64.tar.gz -P /tmp cd /tmp && tar -xf node-v8.16.2-linux-x64.tar.gz && rm node-v8.16.2-linux-x64.tar.gz export PATH=$PATH:/tmp/node-v8.16.2-linux-x64/bin node -v # 查看nodejs 版本,v8.16.2 # 1. 下载yanagishima 源码 wget https://github.com/yanagishima/yanagishima/archive/18.0.zip -P /tmp # 2. 解压yanagishima 源码 unzip /tmp/18.0.zip -d /tmp # 3. 编译yanagishima 源码 cd /tmp/yanagishima-18.0 && ./gradlew clean && ./gradlew distZip # 4. 上传yanagishima 编译好的程序 cd build/distributions && sftp hadoop112 <<< 'put yanagishima-18.0.zip'
安装yanagishima
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28# 0. 安装unzip sudo apt install unzip -y # 1. 解压yanagishima cd && unzip yanagishima-18.0.zip -d /opt/modules ## 添加lzo 压缩支持 cp /opt/modules/hadoop-2.7.2/share/hadoop/common/hadoop-lzo-0.4.20.jar /opt/modules/yanagishima-18.0/lib/ # 2. 配置yanagishima ## 2.1 备份配置文件 cd /opt/modules/yanagishima-18.0/conf && [ -f yanagishima.properties.bak ] || cp yanagishima.properties yanagishima.properties.bak ## 2.2 还原配置文件 cd /opt/modules/yanagishima-18.0/conf && cp yanagishima.properties.bak yanagishima.properties ## 2.3 追加配置内容 cat >> /opt/modules/yanagishima-18.0/conf/yanagishima.properties << 'EOF' # === 追加内容如下 === jetty.port=7080 presto.datasources=atguigu-presto presto.coordinator.server.atguigu-presto=http://hadoop112:8881 catalog.atguigu-presto=hive schema.atguigu-presto=default sql.query.engines=presto EOF
使用yanagishima
复制代码
1
2
3
4
5
6
7
8
9
10
11
12# 3. 启动yanagishima ## 将所有日志信息都放到y.log 中,&> 表stdout 和stderr 两种输出 cd /opt/modules/yanagishima-18.0 && bin/yanagishima-start.sh &> y.log # 4. 访问yanagishima ## 浏览器,http://hadoop112:7080/ ## 注意!查询语句不能以分号; 结束 # 5. 停止yanagishima cd /opt/modules/yanagishima-18.0 && bin/yanagishima-shutdown.sh
参考资料
尚硅谷大数据项目之电商数仓V1.2/笔记/
尚硅谷大数据项目之电商数仓(4即席查询数据仓库)V6.3.0.pdf
尚硅谷大数据项目之电商数仓V1.2/视频/
228.227_尚硅谷_即席查询_Presto_概念(Av285304341,P228).mp4
229.228_尚硅谷_即席查询_Presto_部署_server(Av285304341,P229).mp4
230.229_尚硅谷_即席查询_Presto_启动_Server(Av285304341,P230).mp4
231.230_尚硅谷_即席查询_Presto_部署_命令行客户端(Av285304341,P231).mp4
232.231_尚硅谷_即席查询_Presto_部署_可视化客户端(Av285304341,P232).mp4
233.232_尚硅谷_即席查询_Presto_使用注意事项(Av285304341,P233).mp4
to build yanagishima
最后
以上就是柔弱爆米花最近收集整理的关于Presto 安装和简单使用Presto 安装和简单使用的全部内容,更多相关Presto内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复