版本号:均为发文前(2018-04-04)最新版
Hive版本:2.3.2
Hadoop版本:3.0.1
一.环境变量
/etc/profile /root/.bash_profile
1 | #hive |
二.安装配置
1.复制配置文
1 | cp hive-env.sh.template hive-env.sh |
2.hdfs创建hive存放目录
1 | hadoop fs -mkdir -p /user/hive/warehouse |
3.配置
1>先安装mysql,创建hive元数据库。
1 | create database hive character set latin1; |
2>拷贝mysql-connector-java-5.1.32.jar(其他版本也可)至hive/lib目录
3>修改配置文件
1 | #hive-site.xml |
4>初始化元数据库
1 | schematool -dbType mysql -initSchema |
5>键入hive进入hive控制台
三、错误详解
错误信息
1 | org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version. |
解决方法(mysql中添加权限)
1 | grant all on *.* to root@'%' identified by 'root'; |
错误信息
1 | FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:For direct MetaStore DB connections, we don't support retries at the client level.) |
解决方法
删除mysql中hive数据库,指定latin1编码重建,并重新初始化元数据库。
四.脚本执行
hive处理表后通过sqoop导出mysql,并按日期打印日志,并加入定时任务。
本demo中hive表名:前一天日期_word_src,前一天日期_word_count, eg:2018-04-04_word_count
mysql数据库名:wordcount ,表名:wordcount
1 | start-hive.sh |
1 | #!/bin/bash |
2.定时任务添加
1>设置文件权限
1 | chmod 777 hive-start.sh |
2>定时任务
1 | #添加,每天2点0分启动 |
3>/etc/profile自己配置的环境变量复制到/root/.bash_profile
shell脚本中添加
1 | . /etc/profile |