search
HomeDatabaseMysql TutorialHue安装配置实践

Hue安装配置实践

Jun 07, 2016 pm 04:41 PM
apacheInstallpracticeOpen sourceConfiguration

Hue是一个开源的Apache Hadoop UI系统,最早是由Cloudera Desktop演化而来,由Cloudera贡献给开源社区,它是基于Python Web框架Django实现的。通过使用Hue我们可以在浏览器端的Web控制台上与Hadoop集群进行交互来分析处理数据,例如操作HDFS上的数据,运行Ma

Hue是一个开源的Apache Hadoop UI系统,最早是由Cloudera Desktop演化而来,由Cloudera贡献给开源社区,它是基于Python Web框架Django实现的。通过使用Hue我们可以在浏览器端的Web控制台上与Hadoop集群进行交互来分析处理数据,例如操作HDFS上的数据,运行MapReduce Job等等。很早以前就听说过Hue的便利与强大,一直没能亲自尝试使用,下面先通过官网给出的特性,通过翻译原文简单了解一下Hue所支持的功能特性集合:

  • 默认基于轻量级sqlite数据库管理会话数据,用户认证和授权,可以自定义为MySQL、Postgresql,以及Oracle
  • 基于文件浏览器(File Browser)访问HDFS
  • 基于Hive编辑器来开发和运行Hive查询
  • 支持基于Solr进行搜索的应用,并提供可视化的数据视图,以及仪表板(Dashboard)
  • 支持基于Impala的应用进行交互式查询
  • 支持Spark编辑器和仪表板(Dashboard)
  • 支持Pig编辑器,并能够提交脚本任务
  • 支持Oozie编辑器,可以通过仪表板提交和监控Workflow、Coordinator和Bundle
  • 支持HBase浏览器,能够可视化数据、查询数据、修改HBase表
  • 支持Metastore浏览器,可以访问Hive的元数据,以及HCatalog
  • 支持Job浏览器,能够访问MapReduce Job(MR1/MR2-YARN)
  • 支持Job设计器,能够创建MapReduce/Streaming/Java Job
  • 支持Sqoop 2编辑器和仪表板(Dashboard)
  • 支持ZooKeeper浏览器和编辑器
  • 支持MySql、PostGresql、Sqlite和Oracle数据库查询编辑器

下面,我们通过实际安装来验证Hue的一些功能。

环境准备

这里,我所基于的基本环境及其配置情况,如下所示:

  • CentOS-6.6 (Final)
  • JDK-1.7.0_25
  • Maven-3.2.1
  • Git-1.7.1
  • Hue-3.7.0(branch-3.7.1)
  • Hadoop-2.2.0
  • Hive-0.14
  • Python-2.6.6

基于上面的软件工具,要保证正确安装和配置。需要说明的是,我们通过Hue来执行Hive查询,需要启动HiveServer2服务:

cd /usr/local/hive
bin/hiveserver2 &

否则通过Hue Web控制无法执行Hive查询。

安装配置

我新建了一个hadoop用户,以hadoop用户,首先使用yum工具来安装Hue相关的依赖软件:

sudo yum install krb5-devel cyrus-sasl-gssapi cyrus-sasl-deve libxml2-devel libxslt-devel mysql mysql-devel openldap-devel python-devel python-simplejson sqlite-devel

然后,执行如下命令进行Hue软件包的下载构建:

cd /usr/local/
sudo git clone https://github.com/cloudera/hue.git branch-3.7.1
sudo chown -R hadoop:hadoop branch-3.7.1/
cd branch-3.7.1/
make apps

上述过程如果没有任何问题,我们就已经安装好Hue。Hue的配置文件为/usr/local/branch-3.7.1/desktop/conf/pseudo-distributed.ini,默认的配置文件不能正常运行Hue,所以需要修改其中的内容,与我们对应的Hadoop集群配置相对应。该配置文件根据整合不同的软件,将配置分成多个段,每个段下面还有子段,便于管理配置,如下所示(省略子段名称):

  • desktop
  • libsaml
  • libopenid
  • liboauth
  • librdbms
  • hadoop
  • filebrowser
  • liboozie
  • oozie
  • beeswax
  • impala
  • pig
  • sqoop
  • proxy
  • hbase
  • search
  • indexer
  • jobsub
  • jobbrowser
  • zookeeper
  • spark
  • useradmin
  • libsentry

我们很容易根据需要来配置自己需要的内容。我们修改配置文件的情况,如下表所示:

Hue配置段 Hue配置项 Hue配置值 说明
desktop default_hdfs_superuser hadoop HDFS管理用户
desktop http_host 10.10.4.125 Hue Web Server所在主机/IP
desktop http_port 8000 Hue Web Server服务端口
desktop server_user hadoop 运行Hue Web Server的进程用户
desktop server_group hadoop 运行Hue Web Server的进程用户组
desktop default_user yanjun Hue管理员
hadoop/hdfs_clusters fs_defaultfs hdfs://hadoop6:8020 对应core-site.xml配置项fs.defaultFS
hadoop/hdfs_clusters hadoop_conf_dir /usr/local/hadoop/etc/hadoop Hadoop配置文件目录
hadoop/yarn_clusters resourcemanager_host hadoop6 对应yarn-site.xml配置项yarn.resourcemanager.hostname
hadoop/yarn_clusters resourcemanager_port 8032 ResourceManager服务端口号
hadoop/yarn_clusters resourcemanager_api_url http://hadoop6:8088 对应于yarn-site.xml配置项yarn.resourcemanager.webapp.address
hadoop/yarn_clusters proxy_api_url http://hadoop6:8888 对应yarn-site.xml配置项yarn.web-proxy.address
hadoop/yarn_clusters history_server_api_url http://hadoo6:19888 对应mapred-site.xml配置项mapreduce.jobhistory.webapp.address
beeswax hive_server_host 10.10.4.125 Hive所在节点主机名/IP
beeswax hive_server_port 10000 HiveServer2服务端口号
beeswax hive_conf_dir /usr/local/hive/conf Hive配置文件目录

上面主要配置了Hadoop集群相关的内容,以及Hive(beeswax段配置的是Hive,通过HIveServer2与Hive交互)。
最后,启动Hue服务,执行如下命令:

cd /usr/local/branch-3.7.1/
build/env/bin/supervisor &

Hue功能验证

我们主要通过在Hue Web控制台上执行Hive查询,所以需要准备Hive相关的表和数据。

  • Hive准备

我们首先在Hive中创建一个数据库(如果没有权限则授权):

GRANT ALL TO USER hadoop;
CREATE DATABASE user_db;

这里,hadoop用户是Hive的管理用户,可以将全部权限赋给该用户。
创建示例表,建表DDL如下所示:

CREATE TABLE user_db.daily_user_info (
  device_type int,
  version string,
  channel string,
  udid string)
PARTITIONED BY (
  stat_date string)
ROW FORMAT DELIMITED
  FIELDS TERMINATED BY '\t'
STORED AS INPUTFORMAT
  'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
  'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat';

准备的数据文件格式,示例如下所示:

0     3.2.1     C-gbnpk     b01b8178b86cebb9fddc035bb238876d
0     3.0.7     A-wanglouko     e2b7a3d8713d51c0215c3a4affacbc95
0     1.2.7     H-follower     766e7b2d2eedba2996498605fa03ed33
0     1.2.7     A-shiry     d2924e24d9dbc887c3bea5a1682204d9
0     1.5.1     Z-wammer     f880af48ba2567de0f3f9a6bb70fa962
0     1.2.7     H-clouda     aa051d9e2accbae74004d761ec747110
0     2.2.13     H-clouda     02a32fd61c60dd2c5d9ed8a826c53be4
0     2.5.9     B-ywsy     04cc447ad65dcea5a131d5a993268edf

各个字段之间使用TAB分隔,每个字段含义与上面表user_db.daily_user_info的字段对应,然后我们将测试数据加载到示例表的各个分区之中:

LOAD DATA LOCAL INPATH '/home/hadoop/u2014-12-05.log' OVERWRITE INTO TABLE user_db.daily_user_info PARTITION (stat_date='2014-12-05');
LOAD DATA LOCAL INPATH '/home/hadoop/u2014-12-06.log' OVERWRITE INTO TABLE user_db.daily_user_info PARTITION (stat_date='2014-12-06');
LOAD DATA LOCAL INPATH '/home/hadoop/u2014-12-07.log' OVERWRITE INTO TABLE user_db.daily_user_info PARTITION (stat_date='2014-12-07');
LOAD DATA LOCAL INPATH '/home/hadoop/u2014-12-08.log' OVERWRITE INTO TABLE user_db.daily_user_info PARTITION (stat_date='2014-12-08');
LOAD DATA LOCAL INPATH '/home/hadoop/u2014-12-09.log' OVERWRITE INTO TABLE user_db.daily_user_info PARTITION (stat_date='2014-12-09');
LOAD DATA LOCAL INPATH '/home/hadoop/u2014-12-10.log' OVERWRITE INTO TABLE user_db.daily_user_info PARTITION (stat_date='2014-12-10');
LOAD DATA LOCAL INPATH '/home/hadoop/u2014-12-11.log' OVERWRITE INTO TABLE user_db.daily_user_info PARTITION (stat_date='2014-12-11');

可以通过Hive CLI接口登录,查看表中数据:

SELECT COUNT(1) FROM daily_user_info;

我这里有241709545条记录作为测试数据。

  • Hue登录页面

Hue服务启动成功后,可以直接通过浏览器打开连接http://10.10.4.125:8000/,就可以登录。第一次打开,需要输入默认用户和口令,然后就可以登录进去,如下图所示:
hue-login
首次登录,选择使用的用户即为Hue管理员用户,权限很大,可以添加用户并管理用户及其用户组的操作权限。

  • Hue用户首页

登录成功以后,进入Hue Web控制台首页,如下图所示:
hue-index
登录成功后,首先会执行一些基本环境的配置检查工作,它与我们实际修改配置时都指定了哪些应用有关系。

  • Hive查询编辑器页面

用户登录成功后,选择Query Editors下面的Hive菜单项,如图所示:
hue-hive-query
在提交查询的时候,由于该查询执行时间较长,可以等待查询执行,最后结果显示在的现房的Results标签页上,也可以在执行过程中查看Hive后台执行情况。

  • Job浏览器页面

通过Job浏览器(Job Browser)页面http://10.10.4.125:8000/jobbrowser/,可以查看运行在Hadoop集群上各种状态的Job,包括Succeeded、Running、Failed、Killed这4种状态,如图所示:
hue-job-browser
如果想要看到Job具体执行状态信息,需要正确配置并启动Hadoop集群的JobHistoryServer和WebAppProxyServer服务,可以通过Web页面看到相关数据,我们的示例,如图所示:
hue-job-browser-detail
如果想看某个Job对应的MapTask或者ReduceTask执行情况,可以点击对应链接进去,和通过Hadoop YARN的Job Web管理界面类似,监控起来非常方便。

  • 用户管理和授权认证

以授权管理员用户登录成功后,可以通过点击右上角用户(我这里是yanjun),下拉列表中有“Manage Users”菜单项,在这里面可以创建新用户,并指定访问权限,如下图所示:
hue-manage-users
上面,我创建了几个用户,并指定用户所属的组(Groups,支持组管理)。实际上,我们可以将不同的Hue应用设置为不同的组,然后将新建的用户分配到该相关组,通过这种方式可以控制用户访问Hue应用的权限。上面创建并分配权限的用户可以通过设置的用户名和口令登录Hue Web管理系统,与各种Hadoop相关的应用(不仅仅限于此,如MySQL、Spark等)进行交互。

总结

通过上面的了解,以及安装配置过程所遇到的问题,做一个总结:

  • 如果基于CentOS环境安装配置Hue,可能相对复杂一点,不一定能够很容易的配置成功。我开始基于CentOS-5.11(Final)进行配置,没有配置成功,可能是使用的Hue的版本太高(branch-3.0和branch-3.7.1我都试过),或者可能是CentOS依赖的一些软件包无法安装等问题导致的。建议最好使用较新版本的CentOS,我这里使用的是CentOS-6.6 (Final),Hue使用的branch-3.7.1源码编译,并且Python版本需要2.6+。
  • 使用Hue,我们可能会对用户管理及其权限分配也很感兴趣,所以数据存储,可以根据需要使用我们熟悉的其他关系数据库,如MySQL等,并做好备份,以防使用Hue应用的相关用户数据丢失,造成无法访问Hadoop集群等问题。需要修改Hue的配置文件,将默认存储方式sqlite3改成我们熟悉的关系数据库,目前支持MySQL、Postgresql,以及Oracle。
  • 如果有必要,可能结合Hadoop集群底层的访问控制机制,如Kerberos,或者Hadoop SLA,配合Hue的用户管理和授权认证功能,更好地进行访问权限的约束和控制。
  • 根据前面我们提到的Hue特性,我们可以根据自己实际的应用场景,来选择不同的Hue应用,通过这种插件式的配置来启动应用,通过Hue与其交互,如Oozie、Pig、Spark、HBase等等。
  • 使用更低版本的Hive,如0.12,可能在验证过程中会遇到问题,可以根据Hive的版本来选择兼容版本的Hue来安装配置。
  • 由于本次安装配置实践,并没有使用Cloudera发行的CDH软件包,如果使用CDH可能会更加顺利一些。

参考链接

  • https://github.com/cloudera/hue
  • https://github.com/cloudera/hue/wiki
  • http://cloudera.github.io/hue/docs-3.5.0/manual.html
  • http://cloudera.github.io/hue/docs-3.5.0/sdk/sdk.html
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
MySQL's Place: Databases and ProgrammingMySQL's Place: Databases and ProgrammingApr 13, 2025 am 12:18 AM

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL: From Small Businesses to Large EnterprisesMySQL: From Small Businesses to Large EnterprisesApr 13, 2025 am 12:17 AM

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

What are phantom reads and how does InnoDB prevent them (Next-Key Locking)?What are phantom reads and how does InnoDB prevent them (Next-Key Locking)?Apr 13, 2025 am 12:16 AM

InnoDB effectively prevents phantom reading through Next-KeyLocking mechanism. 1) Next-KeyLocking combines row lock and gap lock to lock records and their gaps to prevent new records from being inserted. 2) In practical applications, by optimizing query and adjusting isolation levels, lock competition can be reduced and concurrency performance can be improved.

MySQL: Not a Programming Language, But...MySQL: Not a Programming Language, But...Apr 13, 2025 am 12:03 AM

MySQL is not a programming language, but its query language SQL has the characteristics of a programming language: 1. SQL supports conditional judgment, loops and variable operations; 2. Through stored procedures, triggers and functions, users can perform complex logical operations in the database.

MySQL: An Introduction to the World's Most Popular DatabaseMySQL: An Introduction to the World's Most Popular DatabaseApr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

The Importance of MySQL: Data Storage and ManagementThe Importance of MySQL: Data Storage and ManagementApr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system suitable for data storage, management, query and security. 1. It supports a variety of operating systems and is widely used in Web applications and other fields. 2. Through the client-server architecture and different storage engines, MySQL processes data efficiently. 3. Basic usage includes creating databases and tables, inserting, querying and updating data. 4. Advanced usage involves complex queries and stored procedures. 5. Common errors can be debugged through the EXPLAIN statement. 6. Performance optimization includes the rational use of indexes and optimized query statements.

Why Use MySQL? Benefits and AdvantagesWhy Use MySQL? Benefits and AdvantagesApr 12, 2025 am 12:17 AM

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

Describe InnoDB locking mechanisms (shared locks, exclusive locks, intention locks, record locks, gap locks, next-key locks).Describe InnoDB locking mechanisms (shared locks, exclusive locks, intention locks, record locks, gap locks, next-key locks).Apr 12, 2025 am 12:16 AM

InnoDB's lock mechanisms include shared locks, exclusive locks, intention locks, record locks, gap locks and next key locks. 1. Shared lock allows transactions to read data without preventing other transactions from reading. 2. Exclusive lock prevents other transactions from reading and modifying data. 3. Intention lock optimizes lock efficiency. 4. Record lock lock index record. 5. Gap lock locks index recording gap. 6. The next key lock is a combination of record lock and gap lock to ensure data consistency.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.