nigel

2023-07-16   阅读量: 263

大数据 linux hive mysql

Linux安装hive

扫码加入数据分析学习群

1.准备

安装Linux https://www.cda.cn/discuss/post/details/649fba2a34a19c3cbf04a7c5

安装hadoop https://www.cda.cn/discuss/post/details/64b36e35f6b83a33b072c5fb

下载hive 和 mysql 安装包

Hive:apache-hive-3.1.2-bin.tar.gz(地址: https://mirrors.tuna.tsinghua.edu.cn/apache/hive/hive-3.1.2/)

Mysql:mysql-8.0.30-1.el9.aarch64.rpm-bundle.tar(地址:https://downloads.mysql.com/archives/community/)

mysql-connector-java:MySQL Connector Java » 8.0.30:(地址:https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.30/mysql-connector-java-8.0.30.jar)

2.安装hive

2.1将安装包上传到 linux cd /opt/module/software


2.2解压安装包

[nigel@nigel1 software]$ cd /opt/module/software

[nigel@nigel1 software]$ tar -zxvf apache-hive-3.1.2-bin.tar.gz -C /opt/module/

2.3修改目录名字

[nigel@nigel1 software]$ mv /opt/module/apache-hive-3.1.2-bin/ /opt/module/hive-3.1.2

2.4配置环境变量

[nigel@nigel1 software]$ sudo vim /etc/profile.d/my_env.sh

添加以下内容

#HIVE_HOME

export HIVE_HOME=/opt/module/hive-3.1.2

export PATH=$PATH:$HIVE_HOME/bin

[nigel@nigel1 software]$ source /etc/profile

2.5删除冲突的jar包

[nigel@nigel1 software]$ rm /opt/module/hive-3.1.2/lib/log4j-slf4j-impl-2.10.0.jar

2.6启动hadoop

[nigel@nigel1 software]$ start-dfs.sh

Starting namenodes on [nigel1]

Starting datanodes

Starting secondary namenodes [nigel1]

[nigel@nigel1 software]$ start-yarn.sh

Starting resourcemanager

Starting nodemanagers

[nigel@nigel1 software]$ mapred --daemon start historyserver

2.7初始化元数据

[nigel@nigel1 software]$ cd /opt/module/hive-3.1.2/bin/

[nigel@nigel1 bin]$ schematool -dbType derby -initSchema

2.8启动与退出hive

[nigel@nigel1 bin]$ hive

hive> exit;


3.安装mysql

3.1先查看是否自带mariadb-libs,南大镜像源下载的almalinux9.1是没有自带mariadb-libs。

[nigel@nigel1 bin]$ rpm -qa|grep mariadb

[nigel@nigel1 bin]$ sudo rpm -e --nodeps mariadb-libs

[sudo] nigel 的密码:

错误:未安装软件包 mariadb-libs

3.2解压mysql安装包

[nigel@nigel1 software]$ tar -xf mysql-8.0.30-1.el9.aarch64.rpm-bundle.tar

[nigel@nigel1 software]$ sudo yum install -y libaio

3.3安装mysql

[nigel@nigel1 software]$ sudo rpm -ivh mysql-community-common-8.0.30-1.el9.aarch64.rpm

[nigel@nigel1 software]$ sudo rpm -ivh mysql-community-client-plugins-8.0.30-1.el9.aarch64.rpm

[nigel@nigel1 software]$ sudo rpm -ivh mysql-community-libs-8.0.30-1.el9.aarch64.rpm

[nigel@nigel1 software]$ sudo rpm -ivh mysql-community-debuginfo-8.0.30-1.el9.aarch64.rpm

[nigel@nigel1 software]$ sudo rpm -ivh mysql-community-libs-debuginfo-8.0.30-1.el9.aarch64.rpm

[nigel@nigel1 software]$ sudo rpm -ivh mysql-community-client-8.0.30-1.el9.aarch64.rpm

[nigel@nigel1 software]$ sudo rpm -ivh mysql-community-icu-data-files-8.0.30-1.el9.aarch64.rpm

[nigel@nigel1 software]$ sudo rpm -ivh mysql-community-server-8.0.30-1.el9.aarch64.rpm


3.4初始化数据库

[nigel@nigel1 software]$ sudo mysqld --initialize —user=mysql

3.5查看临时密码

[nigel@nigel1 software]$ sudo cat /var/log/mysqld.log

2023-07-15T09:54:57.682375Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.30) initializing of server in progress as process 38705

2023-07-15T09:54:57.689621Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.

2023-07-15T09:54:57.895260Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.

2023-07-15T09:54:58.548774Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Q2acj_y9di3h

可以看到临时密码为 Q2acj_y9di3h

3.6修改mysql密码

3.6.1启动mysql

[nigel@nigel1 software]$ sudo systemctl start mysqld

[nigel@nigel1 software]$ mysql -uroot -p

Enter password:

输入临时密码


3.6.2设置密码,并允许任意ip连接

mysql> SET PASSWORD FOR root@localhost = ‘nigel’;

mysql> update mysql.user set host='%' where user='root';

mysql> flush privileges;

mysql> exit;


3.7拷贝MySQLJDBC驱动至hive-3.1.2下的lib/

[nigel@nigel1 software]$ cp mysql-connector-java-8.0.30.redhat-00001.jar /opt/module/hive-3.1.2/lib/

3.8mysql服务自动启动

[nigel@nigel1 ~]$ systemctl enable mysqld


4hive配置

4.1修改hive-site.xml

[nigel@nigel1 software]$ cd /opt/module/hive-3.1.2/conf/

[nigel@nigel1 conf]$ vim hive-site.xml

输入以下内容,注意修改主机名称

<?xml version="1.0"?>

<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>

<!-- jdbc接的URL -->

<property>

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

<value>jdbc:mysql://nigel1:3306/metastore?useSSL=false</value>

</property>

<!-- jdbc接的Driver -->

<property>

<name>javax.jdo.option.ConnectionDriverName</name>

<value>com.mysql.jdbc.Driver</value>

</property>

<!-- jdbc接的username -->

<property>

<name>javax.jdo.option.ConnectionUserName</name>

<value>root</value>

</property>

<!-- jdbc接的password -->

<property>

<name>javax.jdo.option.ConnectionPassword</name>

<value>nigel</value>

</property>

<!-- Hive元据存版本的验证 -->

<property>

<name>hive.metastore.schema.verification</name>

<value>false</value>

</property>

<!-- 元据存 -->

<property>

<name>hive.metastore.event.db.notification.api.auth</name>

<value>false</value>

</property>

<!-- Hive默在HDFS的工作目 -->

<property>

<name>hive.metastore.warehouse.dir</name>

<value>/user/hive/warehouse</value>

</property>

<!-- 指定存据要接的地址 -->

<property>

<name>hive.metastore.uris</name>

<value>thrift://nigel1:9083</value>

</property>

<!-- 指定hiveserver2接的主机名 -->

<property>

<name>hive.server2.thrift.bind.host</name>

<value>nigel1</value>

</property>

<!-- 指定hiveserver2接的端口 -->

<property>

<name>hive.server2.thrift.port</name>

<value>10000</value>

</property>

</configuration>

4.2新建hive元数据库

[nigel@nigel1 conf]$ mysql -uroot -p

mysql> use mysql

mysql> select user, host from user;

mysql> update user set host="%" where user=“root";

mysql> flush privileges;

mysql> exit;

[nigel@nigel1 conf]$ mysql -uroot -p

mysql> create database metastore;

mysql> exit;

4.3初始化元数据库

[nigel@nigel1 conf]$ schematool -initSchema -dbType mysql -verbose

4.4启动hive 退出hive

[nigel@nigel1 conf]$ hive

hive> exit;




添加CDA认证专家【维克多阿涛】,微信号:【cdashijiazhuang】,提供数据分析指导及CDA考试秘籍。已助千人通过CDA数字化人才认证。欢迎交流,共同成长!
0.0000 0 0 关注作者 收藏

评论(0)


暂无数据

推荐课程

推荐帖子