赞
踩
1、安装HIve前得安装好Hadoop集群,不会安装的去我前面文章找
2、安装包准备
3、在Hadoop的namenode节点服务器安装即可
链接:链接:https://pan.baidu.com/s/1XuSDdssel1mzbfW3wAYmhQ
提取码:whrs
复制这段内容后打开百度网盘手机App,操作更方便哦–来自百度网盘超级会员V1的分享
1、将HIve安装包上传至 /usr/local 文件下
tar -zxvf apache-hive-2.3.3-bin.tar.gz
#更换名称
mv apache-hive-2.3.3-bin hive
vim /etc/profile
export HIVE_HOME=/usr/local/hive
在之前的配置上加上 :$HIVE_HOME/bin
2、配置Hive
cd /usr/local/hive/conf
cp hive-default.xml.template hive-site.xml
3、在Hdfs中创建Hive所需目录
[hadoop@master conf]$ hdfs dfs -mkdir -p /user/hive/warehouse
[hadoop@master conf]$ hdfs dfs -chmod -R 777 /user/hive/warehouse
[hadoop@master conf]$ hdfs dfs -mkdir -p /tmp/hive
[hadoop@master conf]$ hdfs dfs -chmod -R 777 /tmp/hive
[hadoop@master conf]$ hdfs dfs -ls /
Found 2 items
drwx------ - hadoop supergroup 0 2018-08-12 11:53 /tmp
drwxr-xr-x - hadoop supergroup 0 2018-08-12 14:31 /user
4、配置Hive本地临时目录
将 hive-site.xml 文件中的 ${system:java.io.tmpdir} 替换为hive的本地临时目录,例如我使用的是 /usr/local/hive/tmp ,如果该目录不存在,需要先进行创建,并且赋予读写权限
cd /usr/local/hive
mkdir tmp/
chmod -R 777 tmp/
cd /usr/local/hive/conf
vim hive-site.xml
在vim命令模式下执行如下命令完成替换:
:%s#${system:java.io.tmpdir}#/usr/local/hive/tmp#g
配置Hive用户名-----操作Hive的账户的用户名,博主此刻登录的root用户
:%s#${system:user.name}#root#g
5、修改Hive数据库配置
Hive默认的配置使用的是Derby数据库来存储Hive的元数据信息,其配置信息如下:
<property> <name>javax.jdo.option.ConnectionDriverName</name> <value>org.apache.derby.jdbc.EmbeddedDriver</value> <description>Driver class name for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:derby:;databaseName=metastore_db;create=true</value> <description> JDBC connect string for a JDBC metastore. To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL. For example, jdbc:postgresql://myhost/db?ssl=true for postgres database. </description> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>APP</value> <description>Username to use against metastore database</description> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>mine</value> <description>password to use against metastore database</description> </property>
如果你需要将Derby数据库切换为MySQL数据库的话,只需要修改以上4项配置,例如,我的是:
<property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.cj.jdbc.Driver</value> <description>Driver class name for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://192.168.220.137:3306/hive?createDatabaseIfNotExist=true</value> <description> JDBC connect string for a JDBC metastore. To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL. For example, jdbc:postgresql://myhost/db?ssl=true for postgres database. </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>199700</value> <description>password to use against metastore database</description> </property>
此外,还需要将MySQL的驱动包放到到Hive的lib目录下:
jar包在网盘中有,将jar包上传至hive的lib目录下
6、配置hive-env.sh
cd /usr/local/hive/conf
cp hive-env.sh.template hive-env.sh
vim hive-env.sh
# 编辑 hive-env.sh 增加下面3行内容
export HADOOP_HOME=/usr/local/hadoop
export HIVE_CONF_DIR=/usr/local/hive/conf
export HIVE_AUX_JARS_PATH=/usr/local/hive/lib
初始化:
cd /usr/local/hive/bin
schematool -initSchema -dbType mysql
查看mysql:
会在mysql自动生成hive库。
3.1、启动HIve
cd /usr/local/hive/bin
./hive
which: no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/java/bin:/usr/local/hadoop/bin:/usr/local/java/bin:/usr/local/hadoop/bin:/usr/local/hive/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.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]
Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-2.3.3.jar!/hive-log4j2.properties Async: true
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。