Impala的安裝
1.安裝Hive
安裝Impala之前必須先安裝Hive
在CDH集群中,先安裝上Hive角色
測試連接后如果顯示successful即視為成功!
然后繼續
查看HDFS中新創建的目錄
接下來進入hive客戶端
在CDH集群上的任意一個節點都可以進入同一個hive客戶端。
Linux上輸入命令:hive
之后可查看數據庫:show databases;
創建表格:
create table if not exists student2(
id int, name string
)
row format delimited fields terminated by '\t';
然后顯示表格:
hive> show tables;
OK
student2
之后先退出即可:quit;
2.安裝Impala
1)Impala的地址
Impala的官網
Impala文檔查看
http://impala.apache.org/impala-docs.html
下載地址
http://impala.apache.org/downloads.html
2)Impala的安裝方式
Cloudera Manager(CDH首推)或者手動安裝
3)開始安裝Impala
下面我們使用Cloudera Manager安裝Impala
1.在主頁中點擊添加服務
2.選擇Impala服務
3.進行角色分配
因為我的目前主節點僅剩下1G內存了,所以就先將ISS和ICS存放在cdh3上。
注意:最好將StateStore和CataLog Sever單獨部署在同一節點上。
4.配置Impala
5.安裝成功
3.Impala 的監護管理
可以通過下面的鏈接來訪問Impala的監護管理頁面:
• 查看StateStore
• 查看Catalog
4.Impala的初體驗
1.啟動Impala
[root@bigdata11 ~]# impala-shell
2.查看數據庫
[bigdata11:21000] > show databases;
3.打開默認數據庫
[bigdata11:21000] > use default;
4.顯示數據庫中的表
[bigdata11:21000] > show tables;
5.創建一張student表
[bigdata11:21000] > create table student(id int, name string) row format delimited fields terminated by '\t';
向表中導入數據
先創建一個文件:vi student.txt
內容為:
1 xiaoming
2 wangwu
3 zhangsan
4 lisi
5 haha
6 lala
加載該數據到student2表中
1)先嘗試本地加載:
2)HDFS加載數據
先將文件上傳到HDFS上
[root@cdh2 ~]# hdfs dfs -put student.txt /
然后加載數據
[cdh2:21000] > load data inpath "/student.txt" into table student2;
注意:
1)關閉(修改hdfs的配置dfs.permissions為false)或修改hdfs的權限,否則impala沒有寫的權限
[root@cdh2 ~]# hadoop fs -chmod 777 /
chmod: changing permissions of '/': Permission denied. user=root is not the owner of inode=
[root@cdh2 ~]# su hdfs
[hdfs@cdh2 root]$ hadoop fs -chmod 777 /
2)Impala不支持將本地文件導入到表中
會發生錯誤:load local data inpath '/opt/student.txt' into table student;
再次嘗試加載數據:
[cdh2:21000] > load data inpath "/student.txt" into table student;
6.查詢
[cdh2:21000] > select * from student;
+----+----------+
| id | name |
+----+----------+
| 1 | xiaoming |
| 2 | wangwu |
| 3 | zhangsan |
| 4 | lisi |
| 5 | haha |
| 6 | lala |
+----+----------+
簡單的查詢速度Hive和Impala是差不多的。
8.退出impala
[cdh2:21000]:21000] > quit;