你好,游客 登录 注册 搜索
背景:
阅读新闻

Hadoop2.6下安装Hive

[日期:2016-10-24] 来源:Chay Cao  作者: [字体: ]

安装Mysql:

sudo apt-get install mysql-server mysql-client

安装后检查是否启动

Hadoop

创建数据库Hive和用户hadoop

用root身份进入mysql:

mysql -u root -p

解压及配置Hive

我的hadoop安装目录在 /usr/local/hadoop-2.6.4 中,解压apache-hive-1.1.1-bin.tar.gz到 /usr/local/hadoop-2.6.4/hive 中。

tar –zxvf /usr/local/hadoop/hive apache-hive-1.1.1-bin.tar.gz

修改 /etc/profile 文件,添加HIVE_HOME和PATH

export HIVE_HOME=/usr/local/hadoop-2.6.4/hive/apache-hive-1.1.1-bin

export PATH= \${PATH}:\${HIVE_HOME}/bin

source /etc/profile 使配置生效

在 /usr/local/hadoop-2.6.4/apache-hive-1.1.1-bin/conf 复制一份 hive-default.xml.template 为 hive-size.xml 文件

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

修改内容如下,模板里面没有 hive.metastore.local ,手动添加,账户和密码是使用Mysql的账户密码:

<property>
<name>hive.metastore.local</name>
<value>true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost: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>root</value>
<description>Username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>admin</value>
<description>password to use against metastore database</description>
</property>

在 /usr/local/hadoop-2.6.4/apache-hive-1.1.1-bin/bin/ 修改hive-config.sh添加下面的3个export语句

export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_101

export HADOOP_HOME=/usr/local/hadoop-2.6.4

export HIVE_HOME=/usr/local/hadoop-2.6.4/hive/apache-hive-1.1.1-bin

将下载的 mysql-connector-java-5.1.40 中的 mysql-connector-java-5.1.40-bin.jar 复制到apache-hive-1.1.1-bin/lib 中

启动hive

在Mysql和Hadoop运行的情况下,使用 hive 命令运行hive:

hive

可能发生的问题

(1)Exception in thread “main” java.lang.RuntimeException: java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: \${system:java.io.tmpdir%7D/\$%7Bsystem:user.name%7D

at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:444)

at

处理办法:在配置文件hive-site.xml里找” system:java.io.tmpdir “把他们都换成绝对路径如: /usr/local/hadoop-2.6.4/hive/apache-hive-1.1.1-bin/iotmp

(2)[ERROR] Terminal initialization failed; falling back to unsupported

java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected

原因:hadoop目录下存在老版本jline:

/usr/local/hadoop-2.6.4/share/hadoop/yarn/lib/:

-rw-r–r– 1 root root 87325 Mar 10 18:10 jline-0.9.94.jar

解决办法:

cp /usr/local/hadoop-2.6.4/hive/apache-hive-1.1.1-bin/lib/jline-2.12.jar /usr/local/hadoop-2.6.4/share/hadoop/yarn/lib/





收藏 推荐 打印 | 录入:elainebo | 阅读: