HIVE安装遇到的问题
环境信息
ubuntu 16.04具体问题
hive设置mysql为metastore数据库,执行数据库初始化命令
schematool -initSchema -dbType mysql
出现以下问题:
> root@ubuntu:/home/ac# schematool -initSchema -dbType mysql SLF4J:
> Class path contains multiple SLF4J bindings. SLF4J: Found binding in
> [jar:file:/usr/hive/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: Found binding in
> [jar:file:/usr/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
> explanation. SLF4J: Actual binding is of type
> [org.apache.logging.slf4j.Log4jLoggerFactory] Metastore connection
> URL:
> jdbc:mysql://192.168.0.109:3306/hive?createDatabaseIfNotExist=true
> Metastore Connection Driver : com.mysql.jdbc.Driver Metastore
> connection User: hive
> org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get
> schema version. Underlying cause:
> com.mysql.jdbc.exceptions.jdbc4.CommunicationsException :
> Communications link failure The last packet sent successfully to the
> server was 0 milliseconds ago. The driver has not received any packets
> from the server. SQL Error code: 0
如图:
解决办法
检查mysql数据库运行状态
systemctl status mysql.service
如果运行状态为active 则mysql运行状态正常
使用数据库可视化工具,无法链接数据库,但在ubuntu环境使用命令行登陆mysql,登陆正常
mysql -u hive -p
问题根因:
mysql的默认配置为了增强安全性,禁止了非本机的访问,在ubuntu中是这样,debian中也是,需要修改
# vi /etc/mysql/my.cnf
修改
bind-address = 127.0.0.1 为 bind-address = 0.0.0.0
修改完成后重启mysql服务
sudo /etc/init.d/mysql restart
再次执行数据库初始化命令
schematool -initSchema -dbType mysql
初始化成功
备注:hive 安装以及设置mysql作为metastore 操作方法参见
http://www.linuxidc.com/Linux/2017-05/143864.htm