hue学习使用整理整理

Hue 学习使用整理整理

依赖安装:html

yum install -y ant gcc gcc-c++ krb5-devel mysql mysql-devel
openssl-devel cyrus-sasl-gssapi cyrus-sasl sqlite-devel
libacl-devel libtidy libxml2-devel libxslt-devel python-devel
python-simplejson python-setuptools rsync saslwrapper gmp
gmp-devel openldap-devel

编译 hue

make install

集成到 ambari

> 注: HDP 提供发行版的 HUE, 和开源的HUE有些不一样, 但未添加到 Ambari 的 Service Stack 中, 须要手动安装及配置, 安装配置信息参考: [Command Line Installation-​Chapter 15. Installing Hue](http://dev.hortonworks.com.s3.amazonaws.com/HDPDocuments/HDP2/HDP-2-trunk/bk_command-line-installation/content/installing_hue.html)

使用 github 上的 ambari-hue-service 完成, 实际操做过程参考 (Hue 3 on HDP installation tutorial)[http://gethue.com/hadoop-hue-3-on-hdp-installation-tutorial/]。java

git clone https://github.com/EsharEditor/ambari-hue-service.git /var/lib/ambari-server/resource/stack/HDP/<version>/services/HUE

增长 hue service 的前提: 在 HDP 的 repo 中添加编译好的 hue 且路径为{HDP.repo}/hue/hue-3.11.0.tgz。安装地址为: /usr/local/huepython

重启 ambari-server , 增长 hue 。mysql

可能遇到问题:c++

  1. 编码格式问题
UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 3354: ordinal not in range(128)

做者给出的解决方案是: 为 ambari-common 中的 sudo , py 增长编码格式:git

import sys
reload(sys)
sys.setdefaultencoding('utf-8')

个人解决方案: 修改 setup.py , 增长生成 hue 配置文件时, 指定编码格式为 utf-8github

File(format("{hue_conf_dir}/pseudo-distributed.ini"),
  content = InlineTemplate(params.hue_pseudodistributed_content),
  owner = params.hue_user,
  # 添加
  encoding = 'utf-8'
)
  1. 资源数据未导入 完成后能够正常集成, 可是启动后的界面为错误信息。
  • 错误信息:
[12/Jul/2017 21:55:26 -0700] file_reporter ERROR    failed to write metrics to file
Traceback (most recent call last):
  File "/usr/local/hue/desktop/core/src/desktop/lib/metrics/file_reporter.py", line 51, in report_now
    json.dump(self.registry.dump_metrics(), f)
  File "/usr/local/hue/desktop/core/src/desktop/lib/metrics/registry.py", line 107, in dump_metrics
    metrics = self._registry.dump_metrics()
  File "/usr/local/hue/build/env/lib/python2.6/site-packages/pyformance-0.3.2-py2.6.egg/pyformance/registry.py", line 215, in dump_metrics
    metrics[key] = self.get_metrics(key)
  File "/usr/local/hue/build/env/lib/python2.6/site-packages/pyformance-0.3.2-py2.6.egg/pyformance/registry.py", line 199, in get_metrics
    metrics.update(getter(key))
  File "/usr/local/hue/build/env/lib/python2.6/site-packages/pyformance-0.3.2-py2.6.egg/pyformance/registry.py", line 132, in _get_gauge_metrics
    return {"value": gauge.get_value()}
  File "/usr/local/hue/build/env/lib/python2.6/site-packages/pyformance-0.3.2-py2.6.egg/pyformance/meters/gauge.py", line 36, in get_value
    return self.callback()
  File "/usr/local/hue/desktop/core/src/desktop/metrics.py", line 110, in <lambda>
    callback=lambda: User.objects.count(),
  File "/usr/local/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/manager.py", line 136, in count
    return self.get_queryset().count()
  File "/usr/local/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/query.py", line 294, in count
    return self.query.get_count(using=self.db)
  File "/usr/local/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/sql/query.py", line 390, in get_count
    number = obj.get_aggregation(using=using)[None]
  File "/usr/local/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/sql/query.py", line 356, in get_aggregation
    result = query.get_compiler(using).execute_sql(SINGLE)
  File "/usr/local/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/sql/compiler.py", line 786, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
ProgrammingError: relation "auth_user" does not exist
LINE 1: SELECT COUNT(*) FROM "auth_user"
  • 解决方法:

参考 ambari-hue-service 的 README.md , 运行集成的 custom command 解决, 即执行 migrate。 > 其实是执行 Django 的同步数据的指令, 即 Django 的python manage.py syncdb;python manage.py migrateweb

使用遇到的问题

###. 使用 hive 问题:sql

relation "beeswax_session" does not exist LINE 1: ...application", "beeswax_session"."properties" FROM "beeswax_s... ^

There are currently no rules defined. To get started, right click on any table column in the SQL Assist panel.

Metastore Manager 问题:

relation "beeswax_session" does not exist LINE 1: ...application", "beeswax_session"."properties" FROM "beeswax_s... ^

hive
  |-Databases
  |-Error loading databases.

hue 集成 NameNode HA

参考:shell

Hadoop High Availability

在 hue.ini 中, ha 的 NameNode 和 普通状态的 NameNode 须要配置的 webhdfs_url 不一样:

[hadoop]

  [[hdfs_clusters]]

    [[[default]]]

      # Enter the filesystem uri
      fs_defaultfs=hdfs://localhost:8020

      # Use WebHdfs/HttpFs as the communication mechanism.
      # Domain should be the NameNode or HttpFs host.
      webhdfs_url=http://localhost:50070/webhdfs/v1

须要完成的准备工做以下:

  1. 在 hue server 的节点上安装 Hadoop HttpFS
yum install hadoop-httpfs
  1. 配置 httpfs-env.sh:
  • 添加 java 环境。
  1. /etc/hadoop-httpfs/conf/httpfs-site.xml 中添加如下配置:
<property>
 <name>httpfs.proxyuser.hue.hosts</name>
 <value>*</value>
</property>

<property>
 <name>httpfs.proxyuser.hue.groups</name>
 <value>*</value>
</property>
  1. 启动 HttpFS service

  2. 在 core.xml 中添加如下配置:

<property>
 <name>hadoop.proxyuser.httpfs.groups</name>
 <value>*</value>
</property>

<property>
 <name>hadoop.proxyuser.httpfs.hosts</name>
 <value>*</value>
</property>

配置 hue.ini :

[hadoop]

  [[hdfs_clusters]]

    [[[default]]]

      # Enter the filesystem uri
      # 使用 NameNode service ID
      fs_defaultfs=hdfs://mycluster

      # Use WebHdfs/HttpFs as the communication mechanism.
      # Domain should be the NameNode or HttpFs host.
      webhdfs_url=http://localhost:14000/webhdfs/v1

重启 hue。

hue 管理员用户丢失解决方法

问题描述:

经过 ambari 安装 hue 后, 管理员用户没法登陆。
问题排查: hue 的数据库中无管理员用户。

解决方法:

进入hue shell 进行添加用户。

# Django 提供的服务端的命令行, 可直接执行一些代码
$HUE_DIR/build/env/bin/hue shell

执行如下代码

# hue shell
from django.contrib.auth.models import User
user = User.objects.create(username='admin')
user.set_password('admin')
user.is_superuser = True
user.save
# 忘记密码时修改密码
from django.contrib.auth.models import User
user = User.objects.get(username='example')
user.set_password('some password')
user.save()

hive 没法获取 database, table 信息, 没法执行sql

环境描述: 管理工具使用 ambari, Hadoop 使用 HDP2.5 发行版, hue版本为 3.11.0。

问题描述: 经过合法的用户登录 hue, 进入 hive 的界面, 没法加载 database 信息和 table 信息。

定位问题思路:

  1. 怀疑是 hive 链接问题, 经过 hive 提供的两种方式 hive 命令和 beeline 可以正常链接到 hive 执行 sql, 排除 hive 引发问题;
  2. 查看日志, 无异常日志,未定位到问题缘由;
  3. Google 查找相似现象, 找到和 hue 的用户缓存相关, 新建用户后可以使用。 经尝试, 该方式可以暂时解决问题。

类似现象:
https://community.hortonworks.com/questions/48834/hivebeewax-on-hue-time-out-error-while-i-run-simpl.html
https://stackoverflow.com/questions/16247073/how-to-refresh-clear-the-distributedcache-when-using-hue-beeswax-to-run-hive-q

相关文章
相关标签/搜索