Hive安装,
一、概述
- hadoop-3.1.1.tar.gz
- apache-hive-3.1.1-bin.tar.gz
二、安装
1、安装mysql,并登录mysql,并修改权限:
yum install -y mysql-server
mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
2、配置环境变量
vim /etc/profile
#增加HIVE环境变量内容
export HIVE_HOME=/data/local/hadoop/apache-hive-3.1.1-bin
export PATH=$PATH:$HADOOP_HOME/bin:$HIVE_HOME/bin
export CLASSPATH=$CLASSPATH:$HIVE_HOME/bin
source /etc/profile
3、创建hive-env.sh文件:
cp hive-default.xml.template hive-site.sh
vi hive-site.sh
#增加内容
export HADOOP_HOME=/usr/local/hadoop-3.1.1
export HIVE_CONF_DIR=/usr/local/apache-hive-3.1.1/conf
4、创建hive-site.sh
vi hive-site.sh
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
# hdfs的数据存放路径
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/data/hive/warehouse</value>
</property>
# 数据库连接
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://node1:3306/hivedb?allowMultiQueries=true&useSSL=false&verifyServerCertificate=false</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.cj.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>
# 其它
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
<property>
<name>datanucleus.readOnlyDatastore</name>
<value>false</value>
</property>
<property>
<name>datanucleus.fixedDatastore</name>
<value>false</value>
</property>
<property>
<name>datanucleus.autoCreateSchema</name>
<value>true</value>
</property>
<property>
<name>datanucleus.autoCreateTables</name>
<value>true</value>
</property>
<property>
<name>datanucleus.autoCreateColumns</name>
<value>true</value>
</property>
</configuration>
5、将下载好的驱动拷贝到hive的lib目录下。
cp /data/local/hadoop/mysql-connector-java-8.0.12.jar /data/local/hadoop/apache-hive-3.1.1-bin/lib
6、在 mysql 服务器中新建空数据库 hivedb,跟 hive-site.xml 中配置的数据库名称一致
7、首次启动初始化schema
./bin/schematool -dbType mysql -initSchema
8、验证
[root@node1 conf]# hive
which: no hbase in (/data/local/hadoop/hadoop-3.1.1/bin:/data/local/hadoop/hadoop-3.1.1/sbin:/data/local/hadoop/hadoop-3.1.1/bin:/data/local/hadoop/hadoop-3.1.1/sbin:/data/local/hadoop/hadoop-3.1.1/bin:/data/local/hadoop/hadoop-3.1.1/sbin:/data/local/hadoop/hadoop-3.1.1/bin:/data/local/hadoop/hadoop-3.1.1/sbin:/data/local/hadoop/hadoop-3.1.1/bin:/data/local/hadoop/hadoop-3.1.1/sbin:/data/local/hadoop/hadoop-3.1.1/bin:/data/local/hadoop/hadoop-3.1.1/sbin:/data/local/hadoop/hadoop-3.1.1/bin:/data/local/hadoop/hadoop-3.1.1/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/data/local/jdk1.8.0_191/bin:/root/bin:/data/local/jdk1.8.0_191/bin:/data/local/hadoop/hive-1.1.0-cdh5.7.0/bin:/data/local/jdk1.8.0_191/bin:/data/local/jdk1.8.0_191/bin:/data/local/hadoop/hadoop-3.1.1/bin:/data/local/hadoop/hadoop-3.1.1/sbin:/data/local/hadoop/hive-1.1.0-cdh5.7.0/bin:/data/local/jdk1.8.0_191/bin:/data/local/hadoop/hive-1.1.0-cdh5.7.0/bin:/data/local/jdk1.8.0_191/bin:/data/local/hadoop/hadoop-3.1.1/bin:/data/local/hadoop/hive-1.1.0-cdh5.7.0/bin:/data/local/jdk1.8.0_191/bin:/data/local/hadoop/hadoop-3.1.1/bin:/data/local/hadoop/apache-hive-3.1.1-bin/bin:/data/local/jdk1.8.0_191/bin:/data/local/hadoop/hadoop-3.1.1/bin:/data/local/hadoop/apache-hive-3.1.1-bin/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/data/local/hadoop/apache-hive-3.1.1-bin/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/data/local/hadoop/hadoop-3.1.1/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]
Hive Session ID = 6bf5ebbb-1dd2-4bea-b09e-84752ce891cd
Logging initialized using configuration in jar:file:/data/local/hadoop/apache-hive-3.1.1-bin/lib/hive-common-3.1.1.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 Session ID = 8ff8cce5-eaa4-4ee1-b19a-0d1f6d3dae5b
hive>
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。