# Weather_Bigdata_Analysis **Repository Path**: LLF-grow/weather_bigdata_analysis ## Basic Information - **Project Name**: Weather_Bigdata_Analysis - **Description**: (1)Python爬虫进行数据爬取; (2)搭建Hadoop分布式集群; (3)Hive数仓存储原始数据; (4)Spark整合Hive完成数据分析,结果存入MySQL; (5)Spring Boot+ECharts进行数据可视化。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 13 - **Forks**: 2 - **Created**: 2023-04-06 - **Last Updated**: 2025-06-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 项目名:天气大数据分析及可视化展示 #### 介绍 (1)Python爬虫进行数据爬取; (2)搭建Hadoop分布式集群; (3)Hive数仓存储原始数据; (4)Spark整合Hive完成数据分析,结果存入MySQL; (5)Spring Boot+ECharts进行数据可视化。 #### 软件架构 ![p9KhtWF.png](https://s1.ax1x.com/2023/04/26/p9KhtWF.png) #### 安装教程 1. ``` 启动大数据环境 启停脚本存放路径:cd /export/onekey 启动执行:start-all.sh 停止执行:stop-all.sh 执行jps,查看进程是否全部启动成功。 ``` 2. 定时执行爬虫代码 3. 启动后端接口服务 4. 执行前端 #### 使用说明 ##### 连接hive: 启动交互方式-Beeline Client执行如下命令: /export/server/hive-2.1.0/bin/beeline 查看hiveserver是否成功启动: netstat -anp|grep 10000 ------如果没有启动就要手动启动------ 先启动 metastore 服务 nohup hive --service metastore & 再启动 hiveserver2 服务 nohup hive --service hiveserver2 & 连接命令: !connect jdbc:hive2://node1:10000 用户名/密码:root/直接回车 create database if not exists weather; ------创建future_weather数据表------ create table if not exists weather.future_weather( weather_date string comment '日期', weather string comment '天气', low_temperature string comment '最低气温', high_temperature string comment '最高气温', trend1 string comment '风向1', trend2 string comment '风向2', wind_scale string comment '风级', city string comment '城市' ) partitioned by (dt string comment '时间分区') ROW FORMAT DELIMITED FIELDS TERMINATED BY ','; ------创建tody_weather数据表------ create table if not exists weather.tody_weather( weather_date string comment '日期', weather_time string comment '时刻', temperature string comment '温度', trend string comment '风力风向', wind_scale string comment '风级', precipitation string comment '降水量', humidity string comment '相对湿度', air_quality string comment '空气质量', city string comment '城市' ) partitioned by (dt string comment '时间分区') ROW FORMAT DELIMITED FIELDS TERMINATED BY ','; ----------注意加载数据时忽略表头设置---------- alter table weather.tody_weather set tblproperties("skip.header.line.count"="1"); ##### 加载数据: load data local inpath '/export/weather/future_weather.csv' into table weather.future_weather partition (dt='2023-04-12'); load data local inpath '/export/weather/tody_weather.csv' into table weather.tody_weather partition (dt='2023-04-12'); ##### 中文乱码问题处理: ------第一种情况------ ##修改已存在的hive元数据库,字符编码格式为utf-8 mysql> alter database hive character set utf8; ##进入hive元数据库 mysql> use metastore; ##查看元数据库字符编码格式 mysql> show variables like 'character_set_database'; #修改字段注释字符集 alter table COLUMNS_V2 modify column COMMENT varchar(256) character set utf8; #修改表注释字符集 alter table TABLE_PARAMS modify column PARAM_VALUE varchar(20000) character set utf8; #修改分区参数,支持分区建用中文表示 alter table PARTITION_PARAMS modify column PARAM_VALUE varchar(20000) character set utf8; alter table PARTITION_KEYS modify column PKEY_COMMENT varchar(20000) character set utf8; #修改索引名注释,支持中文表示 alter table INDEX_PARAMS modify column PARAM_VALUE varchar(4000) character set utf8; #修改视图,支持视图中文 ALTER TABLE TBLS modify COLUMN VIEW_EXPANDED_TEXT mediumtext CHARACTER SET utf8; ALTER TABLE TBLS modify COLUMN VIEW_ORIGINAL_TEXT mediumtext CHARACTER SET utf8; ------第二种情况------ 通过爬虫获取到的数据写入文件时没有指定字符集,指定为UTF8即可; ##### Spark整合Hive进行数据分析问题记录 -----pom文件依赖冲突问题:添加如下依赖------ org.codehaus.janino commons-compiler 2.7.8 org.codehaus.janino janino 2.7.8 ##### 创建spark时需添加如下配置 .config("spark.sql.warehouse.dir", "hdfs://192.168.88.100:8020/user/hive/warehouse") //指定Hive数据库在HDFS上的位置 .config("hive.metastore.uris", "thrift://192.168.88.100:9083") 或者将如下配置文件拷贝到resource目录下: ``` core-site.xml hdfs-site.xml hive-site.xml ``` 备注:这里可能需要根据自己电脑上的环境,确认是否需要本地配置Hadoop的环境变量 ##### 前端项目启动 npm install npm run serve #### 鸣谢 1. https://gitee.com/y_project/RuoYi 2. https://gitee.com/MTrun/big-screen-vue-datav #### 其余 ​ 该项目为个人实践项目,难免会有问题和 BUG,如果有问题欢迎进行评论,共同学习交流,也可添加本人微信(备注来意):w15085924084。