Hadoop-2.7集群安装Hive-2.2

驱动包–mysql-connector-java.jar

安装mysql

yum install wget

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

yum -y install mysql57-community-release-el7-10.noarch.rpm

yum -y install mysql-community-server

systemctl start  mysqld.service

systemctl status mysqld.service

grep 'temporary password' /var/log/mysqld.log
:后面是密码

进入mysql,执行下面的代码

show variables like 'validate_password%'; \
set global validate_password_policy=LOW; \
set global validate_password_length=4; \
show variables like 'validate_password%'; \
grant all on *.* to 'hive'@'hserver-1' identified by 'hive' with grant option; \
grant all on *.* to 'hive'@'localhost' identified by 'hive' with grant option; \
grant all on *.* to 'root'@'%' identified by 'root' with grant option; \
grant all on *.* to ''@'%' identified by 'root' with grant option; \

ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

创建hive用户和hive_metadata元数据库,在root用户下创建,并开放权限

create database if not exists hive_metadata;
grant all privileges on hive_metadata.* to 'hive'@'%' identified by 'hive';
grant all privileges on hive_metadata.* to 'hive'@'localhost' identified by 'hive';
grant all privileges on *.* to ''@'hserver-1' identified by 'root';
flush privileges;
use hive_metadata;

创建文件夹

mkdir /opt/hive-2.2/tmp
chmod 777 -R /opt/hive-2.2/tmp

hadoop fs -mkdir -p /user/hive/warehouse
hadoop fs -mkdir -p /tmp/hive
hadoop fs -chmod -R 777 /user/hive
hadoop fs -chmod -R 777 /tmp/hive

hive-env.sh中添加:

export HADOOP_HOME=/opt/hadoop-2.7
export HIVE_CONF_DIR=/opt/hive-2.2/conf
export HIVE_AUX_JARS_PATH=/opt/hive-2.2/lib
export JAVA_HOME=/opt/jdk-1.8

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

修改hive-site.xml:

修改hive-site.xml把所有的${system:java.io.tmpdir} 修改为/opt/hive-2.2/tmp

把所有的${system:user.name} 修改为root

修改 javax.jdo.option.ConnectionURL

<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://hserver-1:3306/hive_metadata?createDatabaseIfNotExist=true</value>

修改javax.jdo.option.ConnectionDriverName

<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>

注:把mysql-connector-java .jar包放到hive的lib目录里面

修改javax.jdo.option.ConnectionUserName

 <name>javax.jdo.option.ConnectionUserName</name>
 <value>hive</value>

修改javax.jdo.option.ConnectionPassword

 <name>javax.jdo.option.ConnectionPassword</name>
 <value>hive</value>

进入hive的bin目录

schematool -initSchema -dbType mysql

与Spark集成

修改hive.metastore.uris

<name>hive.metastore.uris</name>
<value>thrift://hserver-1:9083</value>

把hive-site.xml复制到sparkconf目录下

把驱动包复制到spark的jars目录下

启动hive metastore和hive2服务

hive --service metastore  1>/dev/null  2>&1  &
hive --service hiveserver2 1>/dev/null  2>&1  &
    原文作者:hipeer
    原文地址: https://www.jianshu.com/p/fbe03a087d42
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞