配置项 | 配置项说明 | 示例 |
集群名称 | 集群的名称,可自定义 | EMR-7sx2aqmu |
地域 | 集群所部署的物理数据中心 注意:集群创建后,无法更改地域,请谨慎选择。 | 北京、上海、广州、南京、新加坡等 |
容器类型 | 服务角色由底层容器提供资源进行部署,支持 TKE 标准集群和 TKE Serverless 集群 | TKE |
集群网络及子网 | 用于购买 db 使用,需保持网络与容器集群网络一致 | 广州七区 |
安全组 | 集群维度配置安全组 | 创建新安全组 |
计费模式 | 集群部署计费模式 | 按量计费 |
产品版本 | 不同产品版本上捆绑的组件和组件的版本不同 | EMR-TKE1.0.0 版本中内置的是 Hadoop 2.8.5、Spark 3.2.1 等。 |
部署服务 | 非必选组件,根据自身需求组合搭配自定义部署,最少选择一个组件 | Hive-2.3.9、Impala-3.4.1等 |
COS 存储桶 | 用于存储日志,jar 包等信息 | - |
设置密码 | 设置 webUI 密码,当前密码仅用于初始设置服务 webUI 访问密码。 | 8-16个字符,包含大写字母、小写字母、数字和特殊字符四种,特殊符号仅支持!@%^*,密码第一位不能为特殊字符 |
<dependency><groupId>org.apache.hive</groupId><artifactId>hive-jdbc</artifactId><version>2.3.7</version></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-common</artifactId><version>2.8.5</version></dependency>
<build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>1.8</source><target>1.8</target><encoding>utf-8</encoding></configuration></plugin><plugin><artifactId>maven-assembly-plugin</artifactId><configuration><descriptorRefs><descriptorRef>jar-with-dependencies</descriptorRef></descriptorRefs></configuration><executions><execution><id>make-assembly</id><phase>package</phase><goals><goal>single</goal></goals></execution></executions></plugin></plugins></build>
package org.apache.hive;import java.sql.*;/*** Created by tencent on 2023/6/20.*/public class HiveJdbcTest {private static String driverName ="org.apache.hive.jdbc.HiveDriver";public static void main(String[] args)throws SQLException {try {Class.forName(driverName);} catch (ClassNotFoundException e) {e.printStackTrace();System.exit(1);}Connection con = DriverManager.getConnection("jdbc:hive2://$hs2host:7001/test_db", "hadoop", "");Statement stmt = con.createStatement();String tableName = "test_jdbc";stmt.execute("drop table if exists " + tableName);stmt.execute("create table " + tableName +" (key int, value string)");System.out.println("Create table success!");// show tablesString sql = "show tables '" + tableName + "'";System.out.println("Running: " + sql);ResultSet res = stmt.executeQuery(sql);if (res.next()) {System.out.println(res.getString(1));}// describe tablesql = "describe " + tableName;System.out.println("Running: " + sql);res = stmt.executeQuery(sql);while (res.next()) {System.out.println(res.getString(1) + "\\t" + res.getString(2));}sql = "insert into " + tableName + " values (42,\\"hello\\"),(48,\\"world\\")";stmt.execute(sql);sql = "select * from " + tableName;System.out.println("Running: " + sql);res = stmt.executeQuery(sql);while (res.next()) {System.out.println(String.valueOf(res.getInt(1)) + "\\t"+ res.getString(2));}sql = "select count(1) from " + tableName;System.out.println("Running: " + sql);res = stmt.executeQuery(sql);while (res.next()) {System.out.println(res.getString(1));}}}
mvn package
java -classpath ${package}-jar-with-dependencies.jar org.apache.hive.HiveJdbcTest
Create table success!Running: show tables 'test_jdbc'test_jdbcRunning: describe test_jdbckey intvalue stringRunning: select * from test_jdbc42 hello48 worldRunning: select count(1) from test_jdbc2
package org.apache.hive;import java.sql.*;/*** Created by tencent on 2023/6/20.*/public class KyuubiJdbcTest {private static String driverName ="org.apache.hive.jdbc.HiveDriver";public static void main(String[] args)throws SQLException {try {Class.forName(driverName);} catch (ClassNotFoundException e) {e.printStackTrace();System.exit(1);}Connection con = DriverManager.getConnection("jdbc:hive2://$kyuubihost:10009/test_db", "hadoop", "");Statement stmt = con.createStatement();String tableName = "test_kyuubi";stmt.execute("drop table if exists " + tableName);stmt.execute("create table " + tableName +" (key int, value string)");System.out.println("Create table success!");// show tablesString sql = "show tables '" + tableName + "'";System.out.println("Running: " + sql);ResultSet res = stmt.executeQuery(sql);if (res.next()) {System.out.println(res.getString(1));}// describe tablesql = "describe " + tableName;System.out.println("Running: " + sql);res = stmt.executeQuery(sql);while (res.next()) {System.out.println(res.getString(1) + "\\t" + res.getString(2));}sql = "insert into " + tableName + " values (42,\\"hello\\"),(48,\\"world\\")";stmt.execute(sql);sql = "select * from " + tableName;System.out.println("Running: " + sql);res = stmt.executeQuery(sql);while (res.next()) {System.out.println(String.valueOf(res.getInt(1)) + "\\t"+ res.getString(2));}sql = "select count(1) from " + tableName;System.out.println("Running: " + sql);res = stmt.executeQuery(sql);while (res.next()) {System.out.println(res.getString(1));}}}
mvn package
java -classpath ${package}-jar-with-dependencies.jar org.apache.hive.KyuubiJdbcTest其中package为您自定义的artifactId-version。运行结果如下:Create table success!Running: show tables 'test_kyuubi'test_dbRunning: describe test_kyuubikey intvalue stringRunning: select * from test_kyuubi42 hello48 worldRunning: select count(1) from test_kyuubi2
本页内容是否解决了您的问题?