Hadoop之Hive本地与远程mysql数据库管理模式安装

 

$ $HADOOP_HOME/bin/hadoop fs -mkdir       /tmp
  $ $HADOOP_HOME/bin/hadoop fs-mkdir       /user/hive/warehouse
  $$HADOOP_HOME/bin/hadoop fs -chmod g+w  /tmp

image

 

create user 'hive'@'localhost' identified by 'hive'

image

 

  使用GRANT ALL PRIVILEGES ON *.* TO hive@'%' IDENTIFIED BY 'hive'; 赋权限

 

flush privileges;    (运行此句才生效,或者重启MySQL)

 

  使用create database hive;创建数据库

  使用SELECT database();  或者status;查看当前数据库

 

下载mysql java驱动程序与hive安装包

mysql-connector-java-5.1.22.tar.gz

hive-0.8.1.tar.gz

将上述两个tar.gz文件解压

进入到hive安装目录的lib目录下,将mysql java驱动拷贝到此目录中

 

进入到hive安装目录的bin子目录下编辑hive.config.sh文件

# vi hive-config.sh

在文件末尾加入

export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.24

export HIVE_HOME=/home/yangze/soft/hive-0.8.1

export HADOOP_HOME=/home/yangze/soft/hadoop-0.20.2

 

 

修改配置文件:

cp hive-default.xml.template  hive-site.xml

 

<property>
  <name>hive.metastore.local</name>
<value>true</value>
  <description>controls whether to connect to remove metastore server or open a new metastore server in Hive Client JVM</
description>
</property>
<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:mysql://master:3306/hive?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>hive</value>
  <description>username to use against metastore database</description>
</property>
<property>
  <name>javax.jdo.option.ConnectionPassword</name>
  <value>hive</value>
  <description>password to use against metastore database</description>
</property>

 

测试:

image

 

image

启动hwi命令:

bin/hive --service hwi

这个服务也是前台启动,在这里就卡死了,不用管

image

 

 

遇到的错误总结:   hive本身没错 mysql出了问题  ubuntu自带的mysql  问题多多呀~~

 

mysql不能远程

解决:

GRANT ALL PRIVILEGES ON *.* TO root@‘%’ IDENTIFIED BY "admin";

查看/etc/mysql/my.cnf找到bind-address才发现配置的是 127.0.0.1(bind-address=127.0.0.1),直接改为bind-address=192.168.0.xxx(本机ip),然 后再查看3306端口打开了,ok,可以正常连接了

 

 

  java.sql.SQLException: Can't create/write to file '/tmp/#sql_14ac_0.MYI' (Errcode: 13)
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask

解决:修改mysql的临时文件夹   

 

sudo mkdir /var/lib/mysql/tmp

sudo chown mysql:mysql /var/lib/mysql/tmp

 

sudo vi /etc/mysql/my.cnf 

 

image

 

 

FAILED: Error in metadata: javax.jdo.JDOFatalDataStoreException: 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. NestedThrowables: 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. FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask

 

解决: 配置文件 localhost 换成 iP or  host

image

您可以选择一种方式赞助本站