天天看点

Ubuntu系统下配置HUE

1.环境准备

  • Ubuntu-16.04
  • JDK-1.8.0_71
  • Maven-3.3.9
  • Hue-3.11.0
  • Hadoop-2.7.1
  • Hive-2.1.0
  • Python-2.7

2.Hue安装

2.1 安装环境依赖

根据官方网站的说明 How to build Hue on Ubuntu 14.04 Trusty 进行前期环境配置,安装git等工具,使用命令apt-get install安装各种依赖工具,详细列表参照GitHub上的 Development Prerequisites

2.2 安装Maven

从 Downloading Apache Maven 3.3.9 下载Maven源代码,解压后在/etc/profile中配置Maven的环境变量,添加如下部分:

#set maven environment
MAVEN_HOME=/home/cuihaolong/maven
PATH=$PATH:$MAVEN_HOME/bin
export MAVEN_HOME PATH
           

使用命令mvn -version测试是否安装成功

2.3 安装Hue

从GitHub下载hue-3.11.0,解压后进入目录中,使用命令make apps安装hue,安装过程中可能遇到的问题参照 Ubuntu下配置Hue的各种问题解决

注:经过测试,ubuntu系统下对hue-3.10.0、hue3.9.0、hue-3.8.0、hue-3.7.1、hue-3.7.0均无法成功安装,只有hue-3.11.0能够成功安装

1274 static files copied to '/home/cuihaolong/hue-release-3.11.0/build/static', 1274 post-processed.
make[1]: Leaving directory '/home/cuihaolong/hue-release-3.11.0/apps'
           

说明成功安装,使用命令

.

/build/env/bin/hue

 runserver

运行hue服务,在浏览器中输入127.0.0.1:8000即可访问Hue主页

Ubuntu系统下配置HUE

第一次访问Hue主页需要创建账户,并设置密码,以后就用该账户访问Hue

3.环境配置

可根据下表查看配置文件的各字段

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配置文件目录

3.1 Hadoop配置

Hue 可以通过下面两种方式访问 Hdfs 中的数据:

  • WebHDFS

    :提供高速的数据传输,客户端直接和 DataNode 交互
  • HttpFS

    :一个代理服务,方便与集群外部的系统集成

对于

WebHDFS

模式,进入~/hadoop/etc/hadoop中修改配置文件,在 hdfs-site.xml添加:

<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>
           

core-site.html

添加:

<!-- For Hue  -->

<property>  
<name>hadoop.proxyuser.hue.hosts</name>  
<value>*</value>  
</property> 
 
<property>  
<name>hadoop.proxyuser.hue.groups</name>  
<value>*</value>  
</property> 

<property>  
<name>hadoop.proxyuser.hive.hosts</name>  
<value>*</value>  
</property> 
 
<property>  
<name>hadoop.proxyuser.hive.groups</name>  
<value>*</value>  
</property> 

<property>  
<name>hadoop.proxyuser.root.hosts</name>  
<value>*</value>  
</property> 
 
<property>  
<name>hadoop.proxyuser.root.groups</name>  
<value>*</value>  
</property> 

<property>  
<name>hadoop.proxyuser.cuihaolong.hosts</name>  
<value>*</value>  
</property> 
 
<property>  
<name>hadoop.proxyuser.cuihaolong.groups</name>  
<value>*</value>  
</property> 

<!-- For Hue  -->
           

进入~/hue/desktop/conf修改pseudo-distributed.ini中字段:

webhdfs_url=http://cdh1:50070/webhdfs/v1/
           

对于HttpFS模式,在hadoop中配置

httpfs-site.xml

<property>
<name>httpfs.proxyuser.hue.hosts</name>
<value>*</value>
</property>
<property>
<name>httpfs.proxyuser.hue.groups</name>
<value>*</value>
</property>
           

core-site.html

添加:

<!-- For Hue  -->

<property>  
<name>hadoop.proxyuser.hue.hosts</name>  
<value>*</value>  
</property> 
 
<property>  
<name>hadoop.proxyuser.hue.groups</name>  
<value>*</value>  
</property> 

<property>  
<name>hadoop.proxyuser.hive.hosts</name>  
<value>*</value>  
</property> 
 
<property>  
<name>hadoop.proxyuser.hive.groups</name>  
<value>*</value>  
</property> 

<property>  
<name>hadoop.proxyuser.root.hosts</name>  
<value>*</value>  
</property> 
 
<property>  
<name>hadoop.proxyuser.root.groups</name>  
<value>*</value>  
</property> 

<!-- For Hue  -->
           

注意:此处的hue为首次进入hue时创建的管理用用户名称

进入~/hue/desktop/conf修改pseudo-distributed.ini中字段:

webhdfs_url=http://cdh1:14000/webhdfs/v1/
           

配置MapReduce

将~/hue/desktop/libs/hadoop/java-lib/下的hue-plugins-3.11.0-SNAPSHOT.jar复制到hadoop的mapreduce lib中,路径为:~/hadoop/share/hadoop/mapreduce/lib

其余配置方法参照 Hue安装、 简单之美|Hue安装配置实践以及、 安装和配置Hue

配置成功后可以在Hue中的HDFS Browser以及Job Browser查看Hadoop的内容

Ubuntu系统下配置HUE
Ubuntu系统下配置HUE

3.2 Hive配置

pseudo-distributed.ini

中修改字段

hive_conf_dir

为包含

hive-site.xml

的目录

[beeswax]

  # Host where HiveServer2 is running.
  # If Kerberos security is enabled, use fully-qualified domain name (FQDN).
  hive_server_host=localhost

  # Port where HiveServer2 Thrift server runs on.
  hive_server_port=10000

  # Hive configuration directory, where hive-site.xml is located
  hive_conf_dir=~/hive/conf
           

查看HDFS上的/tmp/hive和/user/hive/warehouse目录权限,将其修改为777

修改

hive-site.xml

<property> 
<name>hive.security.authorization.enabled</name> 
<value>true</value> 
<description>enable or disable the hive client authorization</description> 
</property> 

<property> 
<name>hive.security.authorization.createtable.owner.grants</name> 
<value>ALL</value> 
<description>the privileges automatically granted to the owner whenever a table gets created. An example like "select,drop" will grant select and drop privilege to the owner of the table</description>
</property>
           

启动hiveserver2:

hiveserver2 start
           

3.3 Hue访问MySQL数据库

在MySQL中创建数据库并授权

mysql> create database hue;
Query OK, 1 row affected (0.01 sec)
mysql> grant all on hue.* to 'hue'@'localhost' identified by 'secretpassword';
Query OK, 0 rows affected (0.00 sec)
           

修改Hue配置文件中的database部分

## [[[mysql]]]
      # Name to show in the UI.
      nice_name="My SQL DB"

      # For MySQL and PostgreSQL, name is the name of the database.
      # For Oracle, Name is instance of the Oracle server. For express edition
      # this is 'xe' by default.
      name=hue

      # Database backend to use. This can be:
      # 1. mysql
      # 2. postgresql
      # 3. oracle
      engine=mysql

      # IP or hostname of the database to connect to.
      host=localhost

      # Port the database server is listening to. Defaults are:
      # 1. MySQL: 3306
      # 2. PostgreSQL: 5432
      # 3. Oracle Express Edition: 1521
      port=3306

      # Username to authenticate with when connecting to the database.
      user=hue

      # Password matching the username to authenticate with when
      # connecting to the database.
      password=hue

      # Database options to send to the server when connecting.
      # https://docs.djangoproject.com/en/1.4/ref/databases/
      ## options={}
           

3.4 错误处理

1.Failed to open new session: java.lang.RuntimeException: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.authorize.AuthorizationException): User: hue is not allowed to impersonate hue_user

出现该错误原因是没有为hue的管理员账户在hadoop中配置代理用户名,其中的hue就是hue管理员用户,hue_user是正在使用hue的一个普通用户,因此需要在core-site.xml添加如下内容:

<property>
<name>hadoop.proxyuser.hue.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.hue.groups</name>
<value>*</value>
</property>
           

配置完成后重启hadoop,即可通过hue访问hive数据库

2.Error while compiling statement: FAILED: HiveAccessControlException Permission denied: Principal [name=hue, type=USER] does not have following privileges for operation QUERY [[SELECT] on Object [type=TABLE_OR_VIEW, name=default.200907_med]]

将hive-site.xml中的hive.security.authorization.enabled字段配置为false,不开启权限验证

3.Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask. Permission denied: user=hue, access=EXECUTE, inode="/tmp/hadoop-yarn/staging/hue/.staging":

更改hdfs上相应目录的权限为777,更改完后发现仍旧无法访问,点击file browser发现无法访问/user/hue,应该是hadoop只创建了本机管理员用户的访问许可,而不允许其他用户访问,因此对hue使用与hadoop同名的管理员用户使用。

继续阅读