Presto整合MySQL和Hive,实现跨引擎查询

Presto配置MySQL Connector

(1)在Presto的/etc/catalog目录下创建mysql.properties,加入以下内容:

connector.name=mysql
connection-url=jdbc:mysql://hadoop000:3306
connection-user=root
connection-password=root

(2)将presto-cli-0.196-executable.jar拷贝到/home/hadoop/app/presto-server-0.196/bin目录下,并将其重命名为presto,加上执行权限 chmod +x presto

Presto配置Hive Connector

(1)在Presto的/etc/catalog目录下创建hive.properties,加入以下内容:

connector.name=hive-hadoop2
hive.metastore.uri=thrift://hadoop000:9083
hive.config.resources=/home/hadoop/app/hadoop-2.6.0-cdh5.15.1/etc/hadoop/core-site.xml,/home/hadoop/app/hadoop-2.6.0-cdh5.15.1/etc/hadoop/hdfs-site.xml

(2)在Presto的/etc/jvm.config中加入Hadoop用户名
-DHADOOP_USER_NAME=hadoop。如果不加的话,它会默认以Presto进程所在的系统用户名作为Hadoop用户名

启动Presto客户端

/home/hadoop/app/presto-server-0.196/bin/presto --server hadoop000:8080 --catalog hive

查询MySQL中的dept表和Hive中的emp表进行join操作

select * from mysql.test.dept as d join hive.default.emp as e on d.id = e.deptid;

你可能感兴趣的:(Presto)