【hadoop3.0】hive 安装

安装

1、下载

http://archive.apache.org/dist/hive/hive-3.1.2/apache-hive-3.1.2-bin.tar.gz

tar -xf apache-hive-3.1.2-bin.tar.gz -C /export/servers/

vim /etc/profile

export HIVE_HOME=/export/servers/apache-hive-3.1.2-bin
export PATH=:$HIVE_HOME/bin:$PATH

source /etc/profile

2、mysql8.0配置

CREATE DATABASE hive;

CREATE USER 'hive' IDENTIFIED BY 'hive'; grant all privileges on *.* to 'hive' identified by 'hive';

flush privileges;

3、建立文件

hadoop fs -mkdir -p /tmp/hive

hadoop fs -mkdir -p /user/hive/warehouse

groupadd hadoop
usermod -G hadoop hive
hadoop fs -chown -R hive:hadoop /user/hive/warehouse
hadoop fs -chown -R hive:hadoop /tmp/hive/
hadoop fs -chmod 755 /user/hive/warehouse
hadoop fs -chmod 777 /tmp/hive/

hadoop fs -mkdir -p /user/hive/log
hadoop fs -chmod 777 /user/hive/log

配置

2.0 配置文件拷贝

cd /export/servers/apache-hive-2.3.3-bin/conf/

cp hive-env.sh.template hive-env.sh

export HADOOP_HOME=/export/servers/hadoop-3.3.0
export HIVE_CONF_DIR=/export/servers/apache-hive-2.3.3-bin/conf

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

2.1 搜索hive.exec.scratchdir, 将该name对应的value修改为/user/hive/tmp

<property>
<name>hive.exec.scratchdir</name>
<value>/user/hive/tmp</value>
</property>

2.2 搜索hive.querylog.location,将该name对应的value修改为/user/hive/log/hadoop

<property>
<name>hive.querylog.location</name>
<value>/user/hive/log/hadoop</value>
<description>Location of Hive run time structured log file</description>
</property>

2.3 搜索javax.jdo.option.connectionURL,将该name对应的value修改为MySQL的地址

<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.252.124: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>

2.4 搜索javax.jdo.option.ConnectionDriverName,将该name对应的value修改为MySQL驱动类路径

<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>

2.5 搜索javax.jdo.option.ConnectionUserName,将对应的value修改为MySQL数据库登录名

<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>Username to use against metastore database</description>
</property>

2.6 搜索javax.jdo.option.ConnectionPassword,将对应的value修改为MySQL数据库的登录密码

<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hadoop</value>
<description>password to use against metastore database</description>
</property>

3 创建tmp文件

mkdir $HIVE_HOME/tmp
并在 hive-site.xml 中修改:

把{system:java.io.tmpdir} 改成 /export/servers/apache-hive-2.3.3-bin/tmp
把 {system:user.name} 改成 {user.name}

 

4、lib包

cd /export/servers/hadoop-3.3.0/share/hadoop/common/lib

cp guava-27.0-jre.jar /export/servers/apache-hive-2.3.3-bin/lib/

wget  https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.20/mysql-connector-java-8.0.20.jar

启动

初始化硬盘

schematool -initSchema -dbType mysql

验证

hive

hive --service metastore &

posted @ 2021-06-02 14:35  shuyang  阅读(183)  评论(0编辑  收藏  举报