一、 Apache Hue介绍
1、Hue是什么
- HUE英文全称为Hadoop User Experience,是一个开源的Apache Hadoop UI系统,由Cloudera Desktop演化而来,最后Cloudera公司将其贡献给Apache基金会的Hadoop社区,它是基于Python Web框架Django实现的
- 通过使用Hue,可以在浏览器端的Web控制台上与Hadoop集群进行交互,来分析处理数据,例如操作HDFS上的数据,运行MapReduce Job,执行Hive的SQL语句,浏览HBase数据库等等
2、Hue能做什么
- 访问HDFS和文件浏览
- 通过web调试和开发hive以及数据结果展示
- 查询solr和结果展示,报表生成
- 通过web调试和开发impala交互式SQL Query
- spark调试和开发
- Pig开发和调试
- oozie任务的开发,监控,和工作流协调调度
- Hbase数据查询和修改,数据展示
- Hive的元数据(metastore)查询
- MapReduce任务进度查看,日志追踪
- 创建和提交MapReduce,Streaming,Java job任务
- Sqoop2的开发和调试
- Zookeeper的浏览和编辑
- 数据库(MySQL,PostGres,SQlite,Oracle)的查询和展示
3、Hue的架构
- Hue是一个友好的界面集成框架,可以集成各种大量的大数据体系软件框架,通过一个界面就可以做到查看以及执行所有的框架
- Hue提供的这些功能相比Hadoop生态各组件提供的界面更加友好,但是一些需要debug的场景可能还是要使用原生系统才能更加深入的找到错误的原因
二、 Hue的安装
1.上传解压安装包
- Hue的安装支持多种方式,包括rpm包的方式进行安装、tar.gz包的方式进行安装以及cloudera manager的方式来进行安装等,我们这里使用tar.gz包的方式来进行安装
- Hue的压缩包的下载地址:
http://archive.cloudera.com/cdh5/cdh/5/ - 我们这里使用的是CDH5.14.0这个对应的版本,具体下载地址为
http://archive.cloudera.com/cdh5/cdh/5/hue-3.9.0-cdh5.14.0.tar.gz
tar -zxf hue-3.9.0-cdh5.14.0.tar.gz
2.联网安装各种必须的依赖包
yum install -y asciidoc cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-plain gcc gcc-c++ krb5-devel libffi-devel libxml2-devel libxslt-devel make openldap-devel python-devel sqlite-devel gmp-devel
3.Hue初始化配置
cd /export/servers/hue-3.9.0-cdh5.14.0/desktop/conf
vim hue.ini
根据自己配置修改以下内容
#通用配置
[desktop]
secret_key=jFE93j;2[290-eiw.KEiwN2s3['d;/.q[eIW^y#e=+Iei*@Mn<qW5o
#通过http访问hue界面的主机名
http_host=node01
#是否启用新版hue界面
is_hue_4=true
#时区
time_zone=Asia/Shanghai
server_user=root
server_group=root
default_user=root
default_hdfs_superuser=root
#配置使用mysql作为hue的存储数据库,大概在hue.ini的587行左右
[[database]]
#设置database为mysql
engine=mysql
#mysql所在节点
host=node01
port=3306
#mysql用户名及密码
user=root
password=Hadoop
#mysql数据库名
name=hue
4.创建mysql中Hue使用的DB
create database hue default character set utf8 default collate utf8_general_ci;
5.编译Hue
cd /export/servers/hue-3.9.0-cdh5.14.0
make apps
编译成功之后,会在hue数据库中创建许多初始化表
5.启动Hue、Web UI访问
cd /export/servers/hue-3.9.0-cdh5.14.0
前台启动:
./build/env/bin/supervisor
后台启动:
./build/env/bin/supervisor &
WEB页面访问路径
http://node01:8888
第一次访问的时候,需要设置超级管理员用户和密码。记住它
三、 Hue与软件的集成
3.1、 Hue集成HDFS
3.1.1、修改core-site.xml配置
<!—允许通过httpfs方式访问hdfs的主机名 -->
<property>
<name>hadoop.proxyuser.root.hosts</name>
<value>*</value>
</property>
<!—允许通过httpfs方式访问hdfs的用户组 -->
<property>
<name>hadoop.proxyuser.root.groups</name>
<value>*</value>
</property>
3.1.2、修改hdfs-site.xml配置
<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>
3.1.3、修改hue.ini
[[hdfs_clusters]]
[[[default]]]
fs_defaultfs=hdfs://node01:8020
webhdfs_url=http://node01:50070/webhdfs/v1
hadoop_hdfs_home=/export/servers/hadoop-2.6.0-cdh5.14.0
hadoop_bin=/export/servers/hadoop-2.6.0-cdh5.14.0/bin
hadoop_conf_dir=/export/servers/hadoop-2.6.0-cdh5.14.0/etc/hadoop
3.1.4、重启HDFS、Hue
启动HDFS
start-dfs.sh
启动hue进程
cd /export/servers/hue-3.9.0-cdh5.14.0
./build/env/bin/supervisor
3.1.5、WEB界面查看
3.2、 Hue集成YARN
3.2.1、修改hue.ini
[[yarn_clusters]]
[[[default]]]
resourcemanager_host=node01
resourcemanager_port=8032
submit_to=True
resourcemanager_api_url=http://node01:8088
history_server_api_url=http://node01:19888
3.2.2、开启yarn日志聚集服务
MapReduce 是在各个机器上运行的, 在运行过程中产生的日志存在于各个机器上,为了能够统一查看各个机器的运行日志,将日志集中存放在 HDFS 上, 这个过程就是日志聚集
<property> ##是否启用日志聚集功能。
<name>yarn.log-aggregation-enable</name>
<value>true</value>
</property>
<property> ##设置日志保留时间,单位是秒。
<name>yarn.log-aggregation.retain-seconds</name>
<value>106800</value>
</property>
3.2.3、重启Yarn、Hue
启动yarn
start-yarn.sh
启动hue进程
cd /export/servers/hue-3.9.0-cdh5.14.0
./build/env/bin/supervisor
3.2.4、WEB界面查看
3.3、 Hue集成Hive
如果需要配置hue与hive的集成,我们需要启动hive的metastore服务以及hiveserver2服务(impala需要hive的metastore服务,hue需要hvie的hiveserver2服务)
3.3.1、修改Hue.ini
[beeswax]
hive_server_host=node01
hive_server_port=10000
hive_conf_dir=/export/servers/hive-1.1.0-cdh5.14.0/conf
server_conn_timeout=120
auth_username=root
auth_password=hadoop
[metastore]
#允许使用hive创建数据库表等操作
enable_new_create_table=true
3.3.2、启动Hive服务、重启hue
在node01机器上启动hive的 metastore 以及 hiveserver2 服务
后台启动 metastore 以及 hiveserver2 服务
cd /export/servers/hive-1.1.0-cdh5.14.0
nohup bin/hive --service metastore &
nohup bin/hive --service hiveserver2 &
启动hue进程
cd /export/servers/hue-3.9.0-cdh5.14.0
./build/env/bin/supervisor
3.3.3、WEB界面查看
3.4、Hue集成Mysql
3.4.1、修改hue.ini
需要把mysql的注释给去掉;大概位于1546行
[[[mysql]]]
nice_name="My SQL DB"
engine=mysql
host=node01
port=3306
user=root
password=hadoop
3.4.2、重启hue
启动hue进程
cd /export/servers/hue-3.9.0-cdh5.14.0/
./build/env/bin/supervisor
3.4.3、WEB界面查看
3.5、Hue集成Oozie
3.5.1、修改hue配置文件hue.ini
[liboozie]
# The URL where the Oozie service runs on. This is required in order for
# users to submit jobs. Empty value disables the config check.
oozie_url=http://node01:11000/oozie
# Requires FQDN in oozie_url if enabled
## security_enabled=false
# Location on HDFS where the workflows/coordinator are deployed when submitted.
remote_deployement_dir=/export/service/oozie/oozie_works
[oozie]
# Location on local FS where the examples are stored.
# local_data_dir=/export/servers/oozie-4.1.0-cdh5.14.0/examples/apps
# Location on local FS where the data for the examples is stored.
# sample_data_dir=/export/servers/oozie-4.1.0-cdh5.14.0/examples/input-data
# Location on HDFS where the oozie examples and workflows are stored.
# Parameters are $TIME and $USER, e.g. /user/$USER/hue/workspaces/workflow-$TIME
# remote_data_dir=/user/root/oozie_works/examples/apps
# Maximum of Oozie workflows or coodinators to retrieve in one API call.
oozie_jobs_count=100
# Use Cron format for defining the frequency of a Coordinator instead of the old frequency number/unit.
enable_cron_scheduling=true
# Flag to enable the saved Editor queries to be dragged and dropped into a workflow.
enable_document_action=true
# Flag to enable Oozie backend filtering instead of doing it at the page level in Javascript. Requires Oozie 4.3+.
enable_oozie_backend_filtering=true
# Flag to enable the Impala action.
enable_impala_action=true
[filebrowser]
# Location on local filesystem where the uploaded archives are temporary stored.
archive_upload_tempdir=/tmp
# Show Download Button for HDFS file browser.
show_download_button=true
# Show Upload Button for HDFS file browser.
show_upload_button=true
# Flag to enable the extraction of a uploaded archive in HDFS.
enable_extract_uploaded_archive=true
3.5.2、启动hue、oozie
启动hue进程
cd /export/servers/hue-3.9.0-cdh5.14.0
./build/env/bin/supervisor
启动oozie进程
cd /export/servers/oozie-4.1.0-cdh5.14.0
./bin/oozied.sh start
3.5.3、WEB界面查看
3.6、Hue集成Hbase
3.6.1、修改hbase配置
在hbase-site.xml配置文件中的添加如下内容,开启hbase thrift服务
修改完成之后scp给其他机器上hbase安装包
<property>
<name>hbase.thrift.support.proxyuser</name>
<value>true</value>
</property>
<property>
<name>hbase.regionserver.thrift.http</name>
<value>true</value>
</property>
3.6.2、修改hadoop配置
在core-site.xml中确保 HBase被授权代理,添加下面内容
把修改之后的配置文件scp给其他机器和hbase安装包conf目录下
<property>
<name>hadoop.proxyuser.hbase.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.hbase.groups</name>
<value>*</value>
</property>
3.6.3、修改Hue配置
[hbase]
# Comma-separated list of HBase Thrift servers for clusters in the format of '(name|host:port)'.
# Use full hostname with security.
# If using Kerberos we assume GSSAPI SASL, not PLAIN.
hbase_clusters=(Cluster|node01:9090)
# HBase configuration directory, where hbase-site.xml is located.
hbase_conf_dir=/export/servers/hbase-1.2.1/conf
# Hard limit of rows or columns per row fetched before truncating.
## truncate_limit = 500
# 'buffered' is the default of the HBase Thrift Server and supports security.
# 'framed' can be used to chunk up responses,
# which is useful when used in conjunction with the nonblocking server in Thrift.
thrift_transport=buffered
3.6.4、启动hbase(包括thrift服务)、hue
需要启动hdfs和hbase,然后再启动thrift
start-dfs.sh
start-hbase.sh
./hbase-daemon.sh start thrift
重新启动hue
cd /export/servers/hue-3.9.0-cdh5.14.0/
./build/env/bin/supervisor
3.6.5、WEB界面查看
3.7、Hue集成Impala
3.7.1、修改hue配置文件hue.ini
[impala]
server_host=node01
server_port=21050
impala_conf_dir=/etc/impala/conf
3.7.2、重启Hue
cd /export/servers/hue-3.9.0-cdh5.14.0/
./build/env/bin/supervisor