1. 安装Hive
1.1准备工作
- Hive官网:https://hive.apache.org/
- 下载hive,如( apache-hive-2.3.3-bin.tar.gz )
1.2 开始安装步骤
- 1.安装到hadoop的namenode上,即主节点上,拷贝文件到linux 中的/usr/local/Hive 目录下。
- 2.解压【tar -zxvf apache-hive-2.3.3-bin.tar.gz】
- 3.添加环境变量
【vim /etc/profile】
编辑
# Hive
export HIVE_HOME=/usr/local/Hive/apache-hive-2.3.3-bin
export PATH=$PATH:$HIVE_HOME/bin
保存后使其生效:【source /etc/profile】
2. 安装mysql作为hive的Metastore
在linux安装mysql的文章日后单独补充
3. 配置Hive
3.1 准备工作
linux开启hdfs,yarn
start-dfs.sh
start-yarn.sh
jps指令确保相关服务全都开启
3.2 开始配置
- 1.在hdfs中新建目录 /user/hive/warehouse
hdfs dfs -mkdir -p /user/hive/warehouse
hadoop fs -chmod g+w /tmp
hadoop fs -chmod g+w /user/hive/warehouse
- 2.将mysql的驱动jar包mysql-connector-java-*-bin.jar拷入hive的安装目录lib下。
- 3.修改配置文件
进入hive的conf目录下复制hive-default.xml.template,名字命名为 hive-site.xml
cp hive-default.xml.template hive-site.xml
具体配置如下
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://127.0.0.1:3306/hive?createDatabaseIfNotExist=true&useSSL=false</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>123456</value>
<description>password to use against metastore database</description>
</property>
<property>
<name>hive.exec.local.scratchdir</name>
<value>/usr/local/Hive/apache-hive-2.3.3-bin/tmp</value>
<description>Local scratch space for Hive jobs</description>
</property>
<property>
<name>hive.downloaded.resources.dir</name>
<value>/usr/local/Hive/apache-hive-2.3.3-bin/tmp/resources</value>
<description>Temporary local directory for added resources in the remote file system.</description>
</property>
<property>
<name>hive.querylog.location</name>
<value>/usr/local/Hive/apache-hive-2.3.3-bin/tmp</value>
<description>Location of Hive run time structured log file</description>
</property>
<property>
<name>hive.server2.logging.operation.log.location</name>
<value>/usr/local/Hive/apache-hive-2.3.3-bin/tmp/operation_logs</value>
<description>Top level directory where operation logs are stored if logging functionality is enabled</description>
</property>
- 4.使用schematool初始化metastore 的schema
schematool -initSchema -dbType mysql
若格式化失败,删掉默认的hive数据库,重新执行初始化命令
5. 安装Beeline CLI
推荐:SQuirrel SQL Client
若网站无法打开,可以在在百度网盘下载:
链接:https://pan.baidu.com/s/1V2Kt9WmPFi8G13VTdXnCXQ 密码:jygl
连接比较简单就这几步:
完!