hive1.2.1安装步骤(在hadoop2.6.4集群上)
hive1.2.1在hadoop2.6.4集群上的安装
hive只需在一个节点上安装即可,这里再hadoop1上安装
1、上传hive安装包到/usr/local/目录下
2、解压 tar -zxvf /usr/local/hive-1.2.1.tar.gz
重命名 mv hive-1.2.1 hive
3、安装MySQL。具体步骤见《Linux下jdk、Tomcat、MySQL的安装》
4、配置hive
(1)配置环境变量vi /etc/profile
添加:export HIVE_HOME=/usr/local/hive
export PATH=.:$HIVE_HOME/bin:$...
配置完source /etc/profile
(2)将$HIVE_HOME/conf/下的两个文件重命名:
mv hive-default.xml.template hive-site.xml
mv hive-env.sh.template hive-env.sh
(3)vi hive-env.sh
配置其中的HADOOP_HOME,将HADOOP_HOME前面的#号去掉,添加路径/usr/local/hadoop
(4)配置元数据库信息 vi hive-site.xml (由于里面配置太多,很难找,提供一个简便修改方式,在WinSCP中编辑,可以快速查找)
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://hadoop1: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>
</configuration>
5、安装完hive和MySQL完成后,将MySQL的连接jar包(不必与MySQL安装版本一致,且没有32位和64位区别!)拷贝到$HIVE_HOME/lib目录下
如果出现没有权限的问题,在mysql授权(在安装mysql的机器上执行)
mysql -uroot -padmin
#(执行下面的语句 *.*:所有库下的所有表 %:任何IP地址或主机都可以连接)
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'admin' WITH GRANT OPTION;
FLUSH PRIVILEGES;
6、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
启动hive的时候,出现的错误:原因:system:java.io.tmpdir 和system:user.name提示需要使用绝对路径
解决办法:将conf/hive-site.xml中所有的system:java.io.tmpdir 和system:user.name都换成绝对路径。
hive-1.2.1版本中有四处需要修改:
1 <property> 2 <name>hive.exec.local.scratchdir</name> 3 <value>${system:java.io.tmpdir}/${system:user.name}</value> 4 <description>Local scratch space for Hive jobs</description> 5 </property> 6 <property> 7 <name>hive.downloaded.resources.dir</name> 8 <value>${system:java.io.tmpdir}/${hive.session.id}_resources</value> 9 <description>Temporary local directory for added resources in the remote file system.</description> 10 </property> 11 <property> 12 <name>hive.querylog.location</name> 13 <value>${system:java.io.tmpdir}/${system:user.name}</value> 14 <description>Location of Hive run time structured log file</description> 15 </property> 16 <property> 17 <name>hive.server2.logging.operation.log.location</name> 18 <value>${system:java.io.tmpdir}/${system:user.name}/operation_logs</value> 19 <description>Top level directory where operation logs are stored if logging functionality is enabled</description> 20 </property>
将上述配置修改为:
1 <property> 2 <name>hive.exec.local.scratchdir</name> 3 <value>/usr/local/hive/iotmp/hive</value> 4 <description>Local scratch space for Hive jobs</description> 5 </property> 6 <property> 7 <name>hive.downloaded.resources.dir</name> 8 <value>/usr/local/hive/iotmp/${hive.session.id}_resources</value> 9 <description>Temporary local directory for added resources in the remote file system.</description> 10 </property> 11 <property> 12 <name>hive.querylog.location</name> 13 <value>/usr/local/hive/iotmp/hive</value> 14 <description>Location of Hive run time structured log file</description> 15 </property> 16 <property> 17 <name>hive.server2.logging.operation.log.location</name> 18 <value>/usr/local/hive/iotmp/hive/operation_logs</value> 19 <description>Top level directory where operation logs are stored if logging functionality is enabled</description> 20 </property>
修改的后的新路径在hive中是没有的,所以要手动在hive中新建相关目录:在/usr/local/hive/新建iotmp文件夹,然后在/usr/local/hive/iotmp/目录下新建hive文件夹。
7、[ERROR] Terminal initialization failed; falling back to unsupported
java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected
Jline包版本不一致的问题,需要拷贝hive的lib目录中jline.2.12.jar的jar包替换掉hadoop中的
cp /usr/local/hive/libjline.2.12.jar /usr/local/hadoop/share/hadoop/yarn/lib/jline-0.9.94.jar
rm -rf /usr/local/hadoop/share/hadoop/yarn/lib/jline-0.9.94.jar
8、启动hive(之前要启动hadoop集群)
bin/hive