飞道的博客

Hive元数据配置到MySQL

441人阅读  评论(0)

准备驱动:

Hive要连接到mysql肯定需要连接驱动,所以要先准备连接驱动。
链接:https://pan.baidu.com/s/1aru6ghaOQgfPxKtkavDEhg
提取码:yj1t

步骤如下:

1.上传mysql-libs.zip到Linux /opt/software目录下


2.解压mysql-libs.zip

unzip mysql-libs.zip


3. 进入mysql-libs目录下,并解压mysql-connector-java-5.1.27.tar.gz文件

sudo tar -zxvf mysql-connector-java-5.1.27.tar.gz


4.拷贝mysql-connector-java-5.1.27-bin.jar 到/opt/module/hive/lib/

cp mysql-connector-java-5.1.27/mysql-connector-java-5.1.27-bin.jar /opt/module/hive/lib/

5.在/opt/module/hive/conf目录下创建一个hive-site.xml文件

touch hive-site.xml


6.编辑hive-site.xml文件,将下面内容写到文件中

注意:一些配置要按照你的实际信息修改

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
	<name>javax.jdo.option.ConnectionURL</name>
	<value>jdbc:mysql://hadoop01:3306/metastore?createDatabaseIfNotExist=true</value>
 	<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
 	<name>javax.jdo.option.ConnectionDriverName</name>
 	<value>com.mysql.jdbc.Driver</value>
 	<description>Driver class name for a JDBC metastore</description>
</property>
<property>
 	<name>javax.jdo.option.ConnectionUserName</name>
 	<value>root</value>
 	<description>username to use against metastore database</description>
</property>
<property>
 	<name>javax.jdo.option.ConnectionPassword</name>
 	<value>123456</value>
 	<description>password to use against metastore database</description>
</property>
</configuration>

7.多窗口启动Hive(如果启动失败了重启下机器


8.创建stu表并在MySQL中查看元数据

create table stu(id int,name string);

  • 1)查看表信息

  • 2)查看表的字段信息


转载:https://blog.csdn.net/qq_43437122/article/details/108036267
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场