Apache Hive学习
hive安装
hive版本:hive-1.1.0-cdh5.14.2,环境:jdk1.8 、VirtualBox、hadoop2.6.0
解压文件:关闭hadoop
[root@km1 opt]#tar -zxvf hive-1.1.0-cdh5.14.2.tar.gz
移动文件到soft文件夹下
[root@km1 opt]#mv hive-1.1.0-cdh5.14.2 soft/hive110
进入hive中,开始修改配置
[root@km1 hive110]#vi /conf/hive-site.xml
这里有些安装包里没有这个文件,如果没有就自己创建一个
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/opt/soft/hive110/warehouse</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://127.0.0.1:3306/hive?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>ok</value>
</property>
</configuration>
修改好hive-site.xml里的代码后去下载mysql的jar包,因为hive的最终目的还是要将数据塞到mysql数据库中,如果没有在虚拟机中安装mysql,就先去把mysql装好。
在ftp中将从本地电脑maven中的jarstore寻找到的mysql5.1.38版本的jar添加到
/opt/soft/hive110/lib/目录下
新建一个文件夹warehouse
[root@km1 hive110]#mkdir warehouse
修改环境配置文件
[root@km1 hive110]#vi /etc/profile
添加两段话
export HIVE_HOME=/opt/soft/hive110
export PATH=$PATH:$HIVE_HOME/bin
环境变量不解释
激活一下
[root@km1 hive110]#source /etc/profile
重启hadoop:
运行hive
[root@km1 hive110]#hive
启动...
启动时可能遇到safemode
这时候需要退出safemode,命令是:
[root@km1 hive110]#hdfs dfsadmin -safemode leave
再次启动hive
[root@km1 hive110]#hive
运行出的结果类似于mysql界面:
which: no hbase in (/opt/soft/jdk180/bin:/opt/soft/jdk180/bin:/opt/soft/jdk180/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/soft/hadoop260/sbin:/opt/soft/hadoop260/bin:/root/bin:/opt/soft/hadoop260/sbin:/opt/soft/hadoop260/bin:HIVE_HOME/bin:/opt/soft/hadoop260/sbin:/opt/soft/hadoop260/bin:/opt/soft/hive110/bin)
19/12/06 19:01:36 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
19/12/06 19:01:36 WARN conf.HiveConf: HiveConf of name hive.metastore.local does not exist
Logging initialized using configuration in jar:file:/opt/soft/hive110/lib/hive-common-1.1.0-cdh5.14.2.jar!/hive-log4j.properties
WARNING: Hive CLI is deprecated and migration to Beeline is recommended.
hive>