欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Centos7安装Hive与MySQL

程序员文章站 2024-03-21 20:47:10
...

Centos7安装Hive

  1. Hive使用的数据库不在是mariadb 而是mysql,因此先装mysql
  2. 官网下载MySQL

https://dev.mysql.com/downloads/mysql/

Centos7安装Hive与MySQL

3.下载完成后上传到虚拟机

Centos7安装Hive与MySQL

上传目录可随意指定

4.通过 rpm -qa | grep mariadb 命令查看 mariadb 的安装包

Centos7安装Hive与MySQL

5.如果有mariadb 通过 rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps 命令装卸 mariadb

6.在当前目录解压安装包

7.通过 tar -xvf mysql-8.0.17-1.el7.x86_64.rpm-bundle.tar  命令解压 tar 包

Centos7安装Hive与MySQL8.安装库

  • 通过 rpm-ivhmysql-community-common-8.0.17-1.el7.x86_64.rpm--force 命令安装 common
  • 通过 rpm -ivh mysql-community-libs-8.0.17-1.el7.x86_64.rpm --nodeps --force 命令安装 libs
  • 通过 rpm -ivh mysql-community-client-8.0.17-1.el7.x86_64.rpm--nodeps --force 命令安装 client
  • 通过 rpm-ivhmysql-community-server-8.0.17-1.el7.x86_64.rpm--nodeps --force 命令安装 server

9.通过 rpm -qa | grep mysql 命令查看 mysql 的安装包

Centos7安装Hive与MySQL

10.通过以下命令,完成对 mysql 数据库的初始化和相关配置

mysqld --initialize;

chown mysql:mysql /var/lib/mysql -R;

systemctl start mysqld.service;

systemctl enable mysqld;

11.通过 cat /var/log/mysqld.log | grep password 命令查看数据库的密码

Centos7安装Hive与MySQL

12.通过 mysql -uroot -p 敲回车键进入数据库登陆界面

 Centos7安装Hive与MySQL

13.输入刚刚查到的密码,进行数据库的登陆,复制粘贴就行,MySQL 的登陆密码也是不显示的

Centos7安装Hive与MySQL

14.通过 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'; 命令来修改密码

Centos7安装Hive与MySQL

15.通过 exit; 命令退出 MySQL,然后通过新密码再次登陆

Centos7安装Hive与MySQL

16.通过以下命令,进行远程访问的授权

create user 'root'@'%' identified with mysql_native_password by 'root';

grant all privileges on *.* to 'root'@'%' with grant option;

flush privileges;

17.通过 flush privileges; 命令刷新修该后的权限

 

安装Hive

1.官网下载Hive包

https://mirrors.tuna.tsinghua.edu.cn/apache/hive/hive-2.3.6/

Centos7安装Hive与MySQL

  • 上传到虚拟机并解压
  • 配置Hive的环境变量
  • 修改配置文件

2.将hive-env.sh.template改名为hive-env.sh

Centos7安装Hive与MySQL

3.修改hive-env.sh

(1)修改HADOOP_HOME的路径

(2)修改HIve配置文件的路径

(3)修改Hive需要jar包的路径

Centos7安装Hive与MySQL

4.vi hive-site.xml

<configuration>
        <property>
                <name>javax.jdo.option.ConnectionURL</name>

                <value>jdbc:mysql://hdp-2: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.cj.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>root</value>

                <description>password to use against metastore database</description>
        </property>
</configuration>

 

Centos7安装Hive与MySQL
5.将mysql驱动包导入hive的lib下

Centos7安装Hive与MySQL

 

6.启动Hive

Centos7安装Hive与MySQL