Hive配置部署与应用

📅 2026/7/22 12:00:09 👁️ 阅读次数 📝 编程学习
Hive配置部署与应用

1.MariaDB(MySQL)

1.1检查yum 源

yum list

1.2安装服务

yum-yinstallmariadb mariadb-server mysql-connector-java

或者yum -y install mariadb-server

1.3启动服务

systemctl start mariadb#启动DBsystemctlenablemariadb#7.X设置开机自启

chkconfig mariadb on 6.X设置开机自启

1.4查看服务状态

systemctl status mariadb

1.5配置 MariaDB(重要)

mysql_secure_installation


1.6登录数据库(123456是密码)

mysql-uroot-p123456

或者 (密码隐藏)

mysql-uroot-pEnter password:

1.7在MariaDB 中创建hive 数据库

create database hive;

1.8使用所创建的数据库hive

1.9给予hive 数据库本地权限

grant all privileges on hive.* to'root'@'localhost'identified by'123456';

1.10给予hive 数据库远程权限

grant all privileges on hive.* to'root'@'%'identified by'123456';

1.11保存退出MariaDB

exit;

1.12通过端口号监听查看 MariaDB 数据库是否处于服务状态

netstat -ano|grep 3306

插件安装:yum -y install net-tools

至此,MariaDB 数据库部署完毕!

2.Hive 配置

2.1上传hive 包到/opt/bigdata/目录下

2.2解压、重命名、去掉小版本号

2.3配置Hive 的系统环境变量

2.4修改Hive 的配置文件,实现hive 与MariaDB 的连接和访问配置如下:

注意 :需 要 将 hive/conf 目 录 下 的 hive-default.xml.template文 件 重 命 名 为 hive-site.xml

2.5将mysql-connector-java-5.0.8-bin.jar 文件拷贝到Hive 目录下的lib 库中

2.6启动hive

直接在命令行中输入hive 即可。如:
–>hive

3.操作hive:查看数据库、创建数据库等操作

操作任务:字段依次为:user_id brand_id type visit_date ,根据实验数据和提供的字段,创建天猫品牌推荐项目数据表,并把数据文件上传导入到hive 中。
create table t_alibaba_data(user_id string,brand_id string,type string,visit_date string) row format serde ‘org.apache.hadoop.hive.serde2.OpenCSVSerde’ with serdeproperties(“separatorchar” = “,”,“quotechar” = “'”,“escapechar” = “\”) stored as textfile;