大資料學習操作筆記
linux解壓到指定目錄命令:tar -zxvf [檔名] -C /home
centos7檢視所有服務:sudo systemctl list-unit-files
Hadoop叢集啟動和關閉命令(node01):
hadoop.sh start
hadoop.sh stop
WebUI:node01:9870
啟動zookeeper服務
三臺機器啟動zookeeper服務;這個命令三臺機器都要執行
zkServer.sh start
檢視狀態
zkServer.sh status
關閉
zkServer.sh stop
HBase
啟動:start-hbase.sh
結束:stop-hbase.sh
WebUI:192.168.51.100:16010
MySQL
使用 service 啟動:service mysqld start
使用 service 停止:service mysqld stop
使用 service 重啟:service mysqld restart
利用sqoop匯出資料到MySQL
sqoop export --connect jdbc:mysql://192.168.51.100:3306/test01 --username root --password 123456 --table xslsqysjj --export-dir /user/hive/warehouse/hive01.db/csv_test01 --input-fields-terminated-by '\001' --input-null-string '\\N' --input-null-non-string '\\N' --m 1
HSQL建表語句
create table csv_test
(
id int,
sale_nbr String,
buy_cnt String,
buy_round String,
sale_cnt String,
sale_round String,
profit String
)
ROW format delimited fields terminated by ',' STORED AS TEXTFILE;
清空表資料(不刪除結構)
truncate table 表名
將查詢結果匯出到新表(hive表)
insert into table [表名]
select (查詢語句);
例如:
insert into table sales_sample_3_1
select day_id,sale_nbr,cnt,sum('round') from sales_sample_ok_day where sale_nbr='C%'
HSQL不支援insert into到指定列,需要嚴格根據select的順序以及本表列順序來設定插入
利用join補全資料:
例如根據兩張表,其中一張表格table2含有省份和城市的資訊, 其中一張表table1只有城市資訊,需要補全table1 中的省份資訊,可以像如下做法: select a.name, b.province, a.city from table1 a left join table2 b on a.city = b.city;