centos7安装使用presto

  • 参考链接

    https://blog.csdn.net/wangpei1949/article/details/79952539
    
  • 参考链接是18年的文章,可以用用

  • 基于ambari平台安装

  • 恢复ambari平台服务

  • 做一下节点规划

    master --ambari server --Presto coordinator
    node01 --ambari node01 --Presto worker与Client
    node02 --ambari node02 --Presto worker与Client
    
  • [all]安装presto的结点需要禁用requiretty,编辑/etc/sudoers文件,注释掉Defaults requiretty

  • [master]下载ambari-presto-service

    wget https://github.com/prestodb/ambari-presto-service/releases/download/v1.2/ambari-presto-1.2.tar.gz
    mkdir /var/lib/ambari-server/resources/stacks/HDP/2.6/services/PRESTO
    tar xvf ambari-presto-1.2.tar.gz --strip-components 1 -C /var/lib/ambari-server/resources/stacks/HDP/2.6/services/PRESTO
    chmod -R +x /var/lib/ambari-server/resources/stacks/HDP/2.6/services/PRESTO/*
    
  • [master]下载presto离线安装包

    wget http://search.maven.org/remotecontent?filepath=com/facebook/presto/presto-server-rpm/0.198/presto-server-rpm-0.198.rpm
    wget http://search.maven.org/remotecontent?filepath=com/facebook/presto/presto-cli/0.198/presto-cli-0.198-executable.jar
    
  • [master]配置仓库(需要到rpm和jar的目录下执行)

    yum install createrepo -y
    createrepo ${PWD}
    python -m SimpleHTTPServer 8081
    
  • [master]增加repo文件

    vim /etc/yum.repos.d/presto.repo
    [presto_repo]
    name=presto_repo
    baseurl=http://172.28.128.11:8082
    enable=1
    gpgcheck=0
    
  • [master]修改presto版本和安装包下载路径

    vim /var/lib/ambari-server/resources/stacks/HDP/2.6/services/PRESTO/metainfo.xml
            <version>0.198</version>
    
    vim /var/lib/ambari-server/resources/stacks/HDP/2.6/services/PRESTO/package/scripts/download.ini       
            [download]
            presto_rpm_url = http://172.28.128.11:8082/presto-server-rpm-0.198.rpm
            presto_cli_url = http://172.28.128.11:8082/presto-cli-0.198-executable.jar
    
    
  • [master]Ambari安装Presto

    ambari-server restart
    按Ambari正常安装服务即可完成安装。discovery.uri:http://172.28.128.11:8285
    
  • 安装报错如下

    Error occured during stack advisor command invocation: Cannot create /var/run/ambari-server/stack-recommendations
    
  • 执行如下名解决

    chmod 777 /var/run/ambari-server/
    
  • 剩下的安装步骤参考链接里的即可

  • 安装完成

  • 如何使用呢?

  • Ambari=>Presto=>Configs=>Connectors添加如下Connectors

    {
      'hive':[
        'connector.name=hive-fake-table',
        'hive.metastore.uri=thrift://172.28.128.12:9083'
      ]
    }
    
  • 造假数据

    # 建hive表
    create database fake_db;
    use fake_db;
    CREATE TABLE fake_table(
       uuid string,
       name string,  
       phone_number string,
       address string,
       email string,
       cardno string,
       company string
    )
    comment 'the table which store test data.'
    ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
    WITH SERDEPROPERTIES (
        "separatorChar" = ",",
        "quoteChar" = "\"",
        "escapeChar" = "\\"
    )
    STORED AS TEXTFILE;
    load data local inpath '/opt/tmp-dir/2020-10-15/output_step_1.csv' into table fake_db.fake_table;
    
  • 【master】看看presto执行命令

    # 打开客户端
    /usr/lib/presto/bin/presto-cli --server 172.28.128.11:8285 --catalog hive --schema default
    
  • 注意,presto的worker和coordinator不能安装在同一个节点上

  • 配置可视化界面

    https://www.jianshu.com/p/28fa8f867380
    
  • 界面重启presto报错如下

    Error connecting to presto server at: localhost:8285
    
  • 解决办法

    cd /var/lib/ambari-agent/cache/stacks/HDP/2.6/services/PRESTO/package/scripts
    vim presto_coordinator.py 
    # 注释掉如下代码
            smoketest_presto(
                PrestoClient('localhost','root',
                             config_properties['http-server.http.port']),
                all_hosts)
    
    
  • 和mysql联查一下

    • 对应的properties怎么配置

      mysql.properties
      connector.name=mysql
      connection-url=jdbc:mysql://172.28.128.11:3306
      connection-user=root
      connection-password=123456
      
      
    • 即:

      {
        'hive':[
          'connector.name=hive-hadoop2',
          'hive.metastore.uri=thrift://172.28.128.12:9083'
        ],
        'mysql':[
          'connector.name=mysql',
          'connection-url=jdbc:mysql://172.28.128.11:3306',
          'connection-user=test_db',
          'connection-password=123456'
        ]
      }
      
    • 创建测试库表

      create database test_db character set utf8 ;  
      CREATE USER 'test_db'@'%'IDENTIFIED BY '123456';
      GRANT ALL PRIVILEGES ON *.* TO 'test_db'@'%';
      FLUSH PRIVILEGES;
      create table test_table(
       _id VARCHAR(100) NOT NULL,
       field_1 longtext NOT NULL,
       field_2 longtext NOT NULL,
       field_3 longtext NOT NULL,
       PRIMARY KEY ( _id )
      );
      
    • 导入测试数据

      INSERT INTO test_db.test_table (_id, field_1, field_2, field_3) VALUES (uuid(), "451323199505170811", "陈勇_mysql", "18896586067_mysql");
      
      
  • 客户端查询比较一下效率

    测试数据量  100W条
    执行sql:
    select count(1) from fake_db.fake_table;
    hive mapreduce查询时间: 19.455 seconds
    presto查询时间:         2 seconds
    执行sql:
    select count(distinct company) from fake_db.fake_table where cardno like '%19950517%';
    hive mapreduce查询时间: 19.571 seconds
    presto查询时间:         3 seconds
    
    测试数据量: 1000W条
    执行sql:
    select count(1) from fake_db.fake_table;
    hive mapreduce查询时间: 35.986 seconds
    presto查询时间:         19 seconds
    执行sql:
    select count(distinct company) from fake_db.fake_table where cardno like '%32319950517%';
    hive mapreduce查询时间: 45.522 seconds
    presto查询时间:         23 seconds
    
  • 代码连接查询数据测试

  • 测试结果

    测试数据量: 1000W条
    执行sql:select * from fake_db.fake_table where cardno like '%32319950517%';
    python presto查询时间:      15.718753576278687
    python sparksql查询时间:     32.25914740562439
    执行sql:select count(distinct company) from fake_db.fake_table where cardno like '%32319950517%';
    python presto查询时间:      15.594711780548096
    python sparksql查询时间:     30.081300973892212
    
  • 造一个大表,里面存储数据大于内存,看看处理能力

    测试数据量: 9000W条(占用14G空间,内存空余13G)
    客户端查询:
        执行sql:
        	select count(1) from fake_db.fake_table;
        hive mapreduce查询时间: 
        	253.912 seconds
        presto查询时间:         
        	180 seconds
        执行sql:
        	select count(distinct company) from fake_db.fake_table where cardno like '%32319950517%';
        hive mapreduce查询时间: 
        	207.097 seconds
        presto查询时间:         
        	200 seconds
    代码查询:
        执行sql:
        	select count(1) from fake_db.fake_table;
        hive mapreduce查询时间: 
        	199.2008821964264
        presto查询时间:         
        	176.18870639801025
        执行sql:
        	select count(distinct company) from fake_db.fake_table where cardno like '%32319950517%';
        hive mapreduce查询时间: 
        	216.40228271484375
        presto查询时间:         
        	196.51006293296814
    
  • 两表联查测试比较

    测试数据量: fake_db.fake_table:9000W条 fake_db.fake_table_little: 100W条
    客户端查询:
        执行sql:
        	select distinct A.name hive_name,B.field_2 mysql_name from fake_db.fake_table as A,fake_db.fake_table_little as B where A.cardno=B.field_1 and A.cardno like "%32319950517%";
        hive mapreduce查询时间: 
        	432.075 seconds
        presto查询时间:         
        	197 seconds
    代码查询:
        执行sql:
        	select distinct A.name hive_name,B.field_2 mysql_name from fake_db.fake_table as A,fake_db.fake_table_little as B where A.cardno=B.field_1 and A.cardno like "%32319950517%";
        hive mapreduce查询时间: 
        	203.07808113098145
        presto查询时间:         
        	197.08233761787415
    
  • 用大表和mysql联查试一下

    hive表数据量:  9000W
    mysql表数据量: 100W
    异构数据源两表查询语句:
    select distinct A.name hive_name,B.field_2 mysql_name from hive.fake_db.fake_table as A,mysql.test_db.test_table as B where A.cardno=B.field_1 and A.cardno like '%32319950517%';
    客户端: 195秒
    代码:    195.43368768692017
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
版本:presto-server-0.214.tar软件版本 presto-cli-0.214-executableCentOS71、presto的起因 hadoop ---hdfs----MR(java)-----hivehive底层原理用MR,速度比较慢,公司hadoop集群主要集中于晚上到凌晨,平日工作时间负载不是很高。但在工作时间内,公司业务人员有实时查询的需求,现在主要借助于hive提供业务人员的查询。hive是基于MR类的SQL查询工具,他会输入的查询SQL解析为MapReduce,能极大的降低使用大数据门槛,让一般的业务人员可以直接准对大数据进行查询,但是有一个利弊,它的查询基于MR,会让人等待比较着急,等待的时间可能是几个小时或者一天。 spark基于内存提高改良的hive,sql,现在factbook在hive上面开发一套利器,准对hive可以通过sql语句快速查询,presto。2、Facebook为何开发Presto  Facebook的2011的数据仓库存储在少量大型hadoopfs集群,Hive是FaceBook在几年前专门为Hadoop打造的一款数据仓库工具,在以前,facebook的科学家和分析师一直靠hive进行数据分析.但hive使用MR作为底层计算框架,是专为批处理设计的,但是随着数据的不断增多,使用hive进行一个简单的数据查询可能要花费分钟或者几个小时,显然不能满足查询需求,FaceBooke也调研了其他比hive更快的工具,但是他们需要在功能有限的条件下做简单操作,以至于无法操作Facebook庞大的数据要求。2012年开始研究自己的框架--presto,每日可以超过1pb查询,而且速度比较快,faceBook声称Presto的性能比hive要好上10倍或者100倍,presto和hive都是facebook开发的 Presto是一个开源的分布式SQL查询引擎,适用于交互式查询,数据量支持GB到PB字节。Presto的设计和编写完全是为了解决Facebook这样规模的商业数据仓库交互式分析和处理速度的问题Presto可以做什么 Presto支持在线数据查询,包括Hive kafka Cassandra关系数据库以及专门数据存储,一条Presto查询可以将多个数据源进行合并,可以跨越整个组织进行分析。Presto以分析师的需求作为目标,他们期望相应速度小于1秒到几分钟,Presto要么在使用速度的快的昂贵的商业方案,提高内存,要么是消耗大量的硬件进行快速查询。(128G 64G)本套课程教给如何在企业环境中使用Presto技术。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值