概述
hive本地模式配置
前置条件:优先安装mysql
安装包导入
如果没有mysql安装包,可以前往mysql官网下载
1)将安装包和JDBC驱动上传到/opt/software,共计6个
01_mysql-community-common-5.7.16-1.el7.x86_64.rpm
02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm
03_mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
04_mysql-community-client-5.7.16-1.el7.x86_64.rpm
05_mysql-community-server-5.7.16-1.el7.x86_64.rpm
mysql-connector-java-5.1.27-bin.jar
2)如果是虚拟机按照如下步骤执行
(1)卸载自带的Mysql-libs(如果之前安装过MySQL,要全都卸载掉)
[atguigu@hadoop102 software]$ rpm -qa | grep -i -E mysql|mariadb | xargs -n1 sudo rpm -e --nodeps
3)如果是阿里云服务器按照如下步骤执行**
说明:由于阿里云服务器安装的是Linux最小系统版,没有如下工具,所以需要安装。
(1)卸载MySQL依赖,虽然机器上没有装MySQL,但是这一步不可少
[atguigu@hadoop102 software]# sudo yum remove mysql-libs
(2)下载依赖并安装
[atguigu@hadoop102 software]# sudo yum install libaio
[atguigu@hadoop102 software]# sudo yum -y install autoconf
正式安装mysql
1)安装MySQL依赖
[atguigu@hadoop102 software]$ sudo rpm -ivh 01_mysql-community-common-5.7.16-1.el7.x86_64.rpm
[atguigu@hadoop102 software]$ sudo rpm -ivh 02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm
[atguigu@hadoop102 software]$ sudo rpm -ivh 03_mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
2)安装mysql-client
[atguigu@hadoop102 software]$ sudo rpm -ivh 04_mysql-community-client-5.7.16-1.el7.x86_64.rpm
3)安装mysql-server
[atguigu@hadoop102 software]$ sudo rpm -ivh 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm
**注意:如果报如下错误,这是由于yum****安装了旧版本的GPG keys所造86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libaio.so.1()(64bit) is needed by mysql-community-server-5.7.16-1.el7.x86_64
解决办法
[atguigu@hadoop102 software]$ sudo rpm -ivh 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm --force --nodeps
4)启动MySQL
[atguigu@hadoop102 software]$ sudo systemctl start mysqld
5)查看MySQL密码
[atguigu@hadoop102 software]$ sudo cat /var/log/mysqld.log | grep password
MySQL配置
配置只要是root用户 + 密码,在任何主机上都能登录MySQL数据库。
1)用刚刚查到的密码进入MySQL(如果报错,给密码加单引号)
[atguigu@hadoop102 software]$ mysql -uroot -p'password'
2)设置复杂密码(由于MySQL密码策略,此密码必须足够复杂)
mysql> set password=password("Qs23=zs32");
3)更改MySQL密码策略
mysql> set global validate_password_length=4;
mysql> set global validate_password_policy=0;
4)设置简单好记的密码
mysql> set password=password("000000");
5)进入MySQL库
mysql> use mysql
6)查询user表
mysql> select user, host from user;
7)修改user表,把Host表内容修改为%
mysql> update user set host="%" where user="root";
8)刷新
mysql> flush privileges;
9)退出
mysql> quit;
HIVE安装
安装mysql驱动
将MySQL的JDBC驱动拷贝到Hive的lib目录下
[atguigu@hadoop102 lib]$ cp /opt/software/mysql-connector-java-5.1.27-bin.jar /opt/module/hive/lib/
配置Metastore到MySQL
在$HIVE_HOME/conf目录下新建hive-site.xml文件
[atguigu@hadoop102 conf]$ vim hive-site.xml
添加如下内容
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://hadoop102:3306/metastore?useSSL=false&useUnicode=true&characterEncoding=UTF-8</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>000000</value>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>hadoop102</value>
</property>
<property>
<name>hive.metastore.event.db.notification.api.auth</name>
<value>false</value>
</property>
<property>
<name>hive.cli.print.header</name>
<value>true</value>
</property>
<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
</property>
</configuration>
初始化Hive
1)登陆MySQL
[atguigu@hadoop102 conf]$ mysql -uroot -p000000
2)新建Hive元数据库
mysql> create database metastore;
3)初始化Hive元数据库
[atguigu@hadoop102 conf]$ schematool -initSchema -dbType mysql -verbose
4)修改元数据库字符集
Hive元数据库的字符集默认为Latin1,由于其不支持中文字符,故若建表语句中包含中文注释,会出现乱码现象。如需解决乱码问题,须做以下修改。
修改Hive元数据库中存储注释的字段的字符集为utf-8
(1)字段注释
mysql> alter t able COLUMNS_V2 modify column COMMENT varchar(256) character set utf8;
(2)表注释
mysql> alter table TABLE_PARAMS modify column PARAM_VALUE mediumtext character set utf8;
4)退出mysql
mysql> quit;
启动Hive客户端
1)启动Hive**客户端(需要提前打开hdfs,并提前创建好对应的目录/user/hive/warehouse)
[atguigu@hadoop102 hive]$ bin/hive
2)查看一下数据库
hive (default)> show databases;
OK
database_name
default
最后
以上就是紧张钢铁侠为你收集整理的hive本地模式配置hive本地模式配置的全部内容,希望文章能够帮你解决hive本地模式配置hive本地模式配置所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复