hive
下载
本地安装
解压后导入环境变量
https://cwiki.apache.org/confluence/display/Hive/GettingStarted
配置 metadata
添加这几段
system:java.io.tmpdir/tmp/hive/javasystem:user.name${user.name}
修改 metadata 数据库到 mysql
javax.jdo.option.ConnectionURLjdbc:mysql://localhost:3306/hive_metastore JDBC connect string for a JDBC metastore. To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL. For example, jdbc:postgresql://myhost/db?ssl=true for postgres database.javax.jdo.option.ConnectionPasswordhivepasswordpassword to use against metastore databasejavax.jdo.option.ConnectionUserNamehiveUsername to use against metastore databasejavax.jdo.option.ConnectionDriverNamecom.mysql.jdbc.DriverDriver class name for a JDBC metastore
mysql 创建表
将正确版本的mysql-mysql-connector-java.jar 放到 $HIVE_HOME/lib中
初始化metadata表
观察是否安装正常
使用外部表
当一个目录下有一堆相同类型的csv时, 似乎需要制定文件夹而不是某个csv,LOCATION默认是hdfs,与hdfs:///testhive 类似
这样可以直接select *
拷贝一个表的内容
例如需要拷贝的表为 hive_test
观察表结构
show create table hive_test;
将第一步的result表名字改成要拷贝的表名创建hive表, 例如 export_hive_test
插入数据
insert into export_hive_test select * from hive_test;
bash执行hive短句
bash通过文件执行sql
Last updated