准备工作:

将hive进程起来
nohup hive --service metastore &
nohup hive --service hiveserver2 &
beeline -u jdbc:hive2://localhost:10000
找到要读取的数据 即在数据库名为 lianxi 表名为 stu 的数据

开始操作:

首先 需要将 hive-site.xml 拷贝到 spark/conf 目录下

具体代码
[root@hadoop7 conf]# cp /opt/install/hive-1.1.0-cdh5.14.2/conf/hive-site.xml ./

其次 需要将mysql驱动 mysql-connector-java-5.1.31.jar 放在spark/jars目录下

具体代码
[root@hadoop7 jars]# cp /opt/software/mysql-connector-java-5.1.31.jar ./

然后进入 spark-shell ,读取数据
示意图如下
在这里插入图片描述

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐