【hive-部署】hive搭建及mysql配置

hive安装部署有三种模式,本地模式,单用户模式,多用户模式。本文只做多用户模式配置。

1. 安装MySQL

# 安装mysql yum源
rpm -ivh https://repo.mysql.com//mysql-community-release-el7-7.noarch.rpm
yum -y install mysql-server
#设置开机启动
systemctl enable mysqld
# 启动mysql
systemctl start mysqld

1.1 设置mysql
设置root密码并禁止远程登录

mysql_secure_installation

使用root用户登录mysql,创建hive数据库和用户

#进入mysql shell
mysql -uroot -p

create database hive character set utf8;  
CREATE USER 'hive'@'%'IDENTIFIED BY 'hive123';
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%';
FLUSH PRIVILEGES;

2. hive安装

2.1. 下载地址 http://archive.apache.org/dist/hive/hive-2.3.3/
2.2. 解压安装

tar xvf apache-hive-2.3.3-bin.tar.gz -C /opt/
ln -s /opt/apache-hive-2.3.3-bin/ /opt/apps/hive

2.3 下载mysql驱动

http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.40/
将mysql-connector-Java.jar复制到/opt/apps/hive/lib目录下

2.4 修改配置文件
hive-site.xml服务端配置

vi /opt/apps/hive/conf/hive-site.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--><configuration>

<!-- hdfs存储目录 -->
<property> 
    <name>hive.metastore.warehouse.dir</name>
    <value>/user/hive/warehouse</value>       
</property> 

<!-- jdbc url配置 -->
<property> 
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://hdc-data4:3306/hive?createDatabaseIfNotExist=true</value>       
</property> 

<!-- 设置jdbc驱动 -->
<property> 
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>com.mysql.jdbc.Driver</value>
</property> 

<!-- jdbc连接用户名 -->
<property> 
    <name>javax.jdo.option.ConnectionUserName</name>
    <value>hive</value>
</property> 

<!-- jdbc连接密码 -->
<property> 
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>hive123</value>
</property> 
</configuration>

2.5 客户端搭建及配置
从服务端直接拷贝安装目录到客户端

修改hive-site.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--><configuration>
<property> 
    <name>hive.metastore.warehouse.dir</name> 
    <value>/user/hive/warehouse</value> 
</property> 
<property> 
    <name>hive.metastore.local</name> 
    <value>false</value> 
</property> 
<!-- 设置服务端url -->
<property> 
    <name>hive.metastore.uris</name> 
    <value>thrift://hdc-data4:9083</value> 
</property> 
</configuration>

若服务端也配置客户端支持,只需在服务端hive-site.xml添加以下两个配置

<property> 
    <name>hive.metastore.local</name> 
    <value>false</value> 
</property> 
<!-- 设置服务端url -->
<property> 
    <name>hive.metastore.uris</name> 
    <value>thrift://hdc-data4:9083</value> 
</property> 

2.6 配置环境变量(每台服务器)

#vi /etc/profile
export HIVE_HOME=/opt/apps/hive
export PATH=$PATH:$HIVE_HOME/bin

source /etc/profile

2.7 手动创建hive 数据库及元数据表

cd /opt/apps/hive/scripts/metastore/upgrade/mysql/

#登录mysql
mysql> use hive;
Database changed
mysql> source hive-schema-2.3.0.mysql.sql;

2.8 启动服务端和客户端
服务端:hive --service metastore
客户端:hive

3. 解决hive COMMNET(备注)中文问题

https://www.jianshu.com/p/ea7e29285dd9

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容