由于mysql服务被设置了开机自启,可以直接用datadrip连接mysql,用户名为root,密码为:hadoop。
mysql建库建表语句:
点击查看代码
-- 创建数据库和表
CREATE DATABASE IF NOT EXISTS gov_report;
USE gov_report;-- 机构处理量排名表
CREATE TABLE reply_org_ranking (id INT AUTO_INCREMENT PRIMARY KEY,reply_org VARCHAR(255) NOT NULL,cnt INT NOT NULL
);-- 处理时效分布表
CREATE TABLE processing_time_distribution (id INT AUTO_INCREMENT PRIMARY KEY,processing_period VARCHAR(20) NOT NULL,cnt INT NOT NULL,percentage DECIMAL(5,2) NOT NULL
);ALTER TABLE gov_report.reply_org_ranking
MODIFY reply_org VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;-- 月度趋势分析表
CREATE TABLE gov_report.months_trend (id INT AUTO_INCREMENT PRIMARY KEY,year_months VARCHAR(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,total_letters INT NOT NULL,UNIQUE KEY unique_year_month (year_months) -- 确保年月唯一
);
在node1上安装sqoop,我参考的文章是https://blog.csdn.net/2301_78038072/article/details/143066963
注意打开sqoop官网时,要开魔法(懂的都懂)。
执行命令,将数据导入mysql
点击查看代码
# 1. 机构处理量排名表
sqoop export \
--connect "jdbc:mysql://node1:3306/gov_report?useUnicode=true&characterEncoding=UTF-8" \
--username root \
--password hadoop \
--table reply_org_ranking \
--export-dir /user/hive/warehouse/gov_letter_db.db/reply_org_ranking \
--input-fields-terminated-by '\001' \
--columns "reply_org,cnt" \
-- \
--direct# 2. 导出处理时效分布表
sqoop export \
--connect jdbc:mysql://node1:3306/gov_report \
--username root \
--password hadoop \
--table processing_time_distribution \
--export-dir /user/hive/warehouse/gov_letter_db.db/processing_time_distribution \
--input-fields-terminated-by '\001' \
--columns "processing_period,cnt,percentage"# 3. 月度趋势分析表
sqoop export \
--connect jdbc:mysql://node1:3306/gov_report \
--username root \
--password hadoop \
--table months_trend \
--columns year_months,total_letters \
--input-null-string '\\\\N' \
--input-null-non-string '\\\\N' \
--export-dir /user/hive/warehouse/gov_letter_db.db/monthly_trend \
--input-fields-terminated-by '\001' \
--input-lines-terminated-by '\n' \
--update-key year_months \
--update-mode allowinsert
实现数据可视化,这就很简单了,也是回到老本行了,就不提供源代码了,只展示结果。
技术栈:springboot,JPA,vue,ECharts,axios。