赞
踩
目录
1.修改/usr/local/hive/conf下的hive-site.xml
操作系统:Ubuntu 18.04
Hadoop版本:3.1.3
Hive版本:3.1.2
JDK版本:1.8
Mysql版本:5.7.4
tar -zxvf ./apache-hive-3.1.2-bin.tar.gz -C /usr/local
vim /etc/profile
添加:
- export HIVE_HOME=/usr/local/hive
- export PATH=$PATH: $HIVE_HOME/bin
刷新环境变量
source /etc/profie
cd /usr/local/hive/conf
将hive-default.xml.template重命名为hive-default.xml;
mv hive-default.xml.tenplate hive-default.xml
使用vim编辑器新建一个配置文件hive-site.xml,
vim hive-site.xml
在hive-site.xml中添加如下配置信息(注意下方有个密码,用于连接元数据库,与连接mysql密码相同):
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
- <configuration>
- <!-- 如果 mysql 和 hive 在同一个服务器节点,那么请更改 master 为 localhost -->
- <property>
- <name>javax.jdo.option.ConnectionURL</name>
- <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>
- <description>JDBC connect string for a JDBC metastore</description>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionDriverName</name>
- <value>com.mysql.jdbc.Driver</value>
- <description>Driver class name for a JDBC metastore</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>这里输入你的密码</value>
- <description>password to use against metastore database</description>
- </property>
- <property>
- <name>datanucleus.schema.autoCreateAll</name>
- <value>true</value>
- <description>Auto creates necessary schema on a startup if one doesn't exist. Set this to false, after creating it once.To enable auto create also set hive.metastore.schema.verification=false. Auto creation is not recommended for production use cases, run schematool command instead.</description>
- </property>
- <property>
- <name>hive.metastore.schema.verification</name>
- <value>false</value>
- <description>
- Enforce metastore schema version consistency.
- True: Verify that version information stored in is compatible with one from Hive jars. Also disable automatic
- schema migration attempt. Users are required to manually migrate schema after Hive upgrade which ensures
- proper metastore schema migration. (Default)
- False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.
- </description>
- </property>
- </configuration>
cp hive-env.sh.template hive-env.sh
vim hive-env.sh
插入java和hadoop环境变量
- export JAVA_HOME=/usr/local/jdk
- export HADOOP_HOME=/usr/local/Hadoop
cd /usr/local/hive/bin
添加:
- export JAVA HOME=/usr/local/jdk
- export HADOOP_HOME=/usr/local/hadoop
- export HIVE_HOME=/usr/local/hive
hive --version
#更新软件源
apt-get update
#安装mysql
apt-get install mysql-server
为mysql设置密码,与hive-site.xml配置文件的一样:
update user set authentication_string=PASSWORD('输入你的密码') where user='root';
启动mysql服务器:
service mysql start
确认是否启动成功,mysql节点处于LISTEN状态表示启动成功:
netstat -tap | grep mysql
进入mysql shell界面:
mysql -u root -p
关闭服务:
service mysql stop
tar -zxvf mysql-connector-java-5.1.40.tar.gz
将mysql驱动文件复制到hive目录下的lib目录中
#启动mysql服务
service mysql start
#登陆shell界面
mysql -u root -p
#这个hive数据库与hive-site.xml中localhost:3306/hive的hive对应,用来保存hive元数据
create database hive;
#将所有数据库的所有表的所有权限赋给hive用户,后面的hive是配置hive-site.xml中配置的连接密码
grant all on *.* to root@localhost identified by '跟你上方一样的密码';
#刷新mysql系统权限关系表
flush privileges;
cd /usr/local/hive
./bin/schematool -dbType mysql -initSchema
启动hive之前,先启动hadoop集群。
#启动Hadoop的HDFS
start-dfs.sh
#启动hive
hive
注意,我们这里已经配置了PATH,所以,不需要把start-all.sh和hive命令的路径加上。如果没有配置PATH,请加上路径才能运行命令,比如,本教程Hadoop安装目录是“/usr/local/hadoop”,Hive的安装目录是“/usr/local/hive”,因此,启动hadoop和hive,也可以使用下面带路径的方式:
cd /usr/local/hadoop
./sbin/start-dfs.sh
cd /usr/local/hive
./bin/hive
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。