CentOS上安装Hue

1.安装依赖

yum -y install ant asciidoc cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-plain gcc gcc-c++ krb5-devel libffi-devel libxml2-devel libxslt-devel make mysql mysql-devel openldap-devel python-devel sqlite-devel gmp-devel openssl-devel libtidy

# 安装sasl相关依赖
yum install -y cyrus-sasl-plain  cyrus-sasl-devel  cyrus-sasl-gssapi

2.安装nodejs

略,参考《centos7.5 安装nodejs

3.安装python

python版本:2.7.5
配置pip源(很重要)

4.安装maven

wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz

配置maven:

tar -zxvf apache-maven-3.6.3-bin.tar.gz
mv apache-maven-3.6.3 maven-3.6.3

vim /etc/profile

export MAVEN_HOME=/app/hadoop/software/maven-3.6.3
export PATH=$MAVEN_HOME/bin:$PATH

source /etc/profile

设置maven为国内源,点击参考文章

5.下载hue

git clone https://github.com/cloudera/hue.git

6.设置hue为默认中文显示

vi desktop/core/src/desktop/settings.py

LANGUAGE_CODE = 'zh-CN'

LANGUAGES = [
  ('zh-CN', _('Simplified Chinese')),
  ('en-us', _('English')),
]

7.修改环境变量

vim /etc/profile

export HUE_HOME=/home/hadoop/soft/hue-4.8
export PATH=$PATH:$HUE_HOME/build/env/bin

source /etc/profile

8.创建用户和组

groupadd hue
useradd -d /app/hue -g hue -m hue

9.编译hue

cd hue
# 如果你机器的python版本是3.5+编译时先设置PYTHON_VER
# export PYTHON_VER=python3.8
# 编译
make apps
# 编译中文(很重要,如果不执行该语句不会显示中文)
make locales

10.配置hadoop

  • 配置hdfs-site.xml
vim ../hadoop-2.9.2/etc/hadoop/hdfs-site.xml

配置内容:

<property>
  <name>dfs.webhdfs.enabled</name>
  <value>true</value>
</property>
  • 配置core-site.xml
<property>
  <name>hadoop.proxyuser.hue.hosts</name>
  <value>*</value>
</property>
<property>
  <name>hadoop.proxyuser.hue.groups</name>
  <value>*</value>
</property>
  • 配置httpfs-site.xml
<property>
    <name>httpfs.proxyuser.hue.hosts</name>
    <value>*</value>
</property>
<property>
    <name>httpfs.proxyuser.hue.groups</name>
    <value>*</value>
</property>

11.修改hive中的hive-site.xml文件

vim ../hive-3.1.2/conf/hive-site.xml

修改内容:

 <property>
    <name>hive.server2.authentication</name>
    <value>NOSASL</value>
 </property>

重启hive

12.修改hue.ini配置文件

vim desktop/conf/pseudo-distributed.ini

修改内容:

#一个安全key,建议填写30-60个任意字符
secret_key=2s8GDObb4WcEeipL9tWf4a4SuG586m4ZrmFt0gpIR

# Webserver listens on this address and port
http_host=0.0.0.0
http_port=8888

# Time zone name
time_zone=Asia/Shanghai
# 关闭django debug模式
django_debug_mode=false

# 配置Hue使用MySQL作为默认元数据库,搜索"Database engine is typically one of"定位到修改处
engine=mysql
host=data-repo-06
port=3306
user=root
password=123456
# 数据库名称
name=hue

# hue中使用hive。搜索“Settings to configure Beeswax with Hive”定位到修改处
hive_server_host=data-repo-01
hive_server_port=10000
hive_conf_dir=/app/hadoop/software/hive-3.1.2/conf

13.登录MySQL,创建hue数据库

# 登录MySQL
mysql -uroot -p123456
# 创建hive数据库
CREATE DATABASE IF NOT EXISTS hue default charset utf8 COLLATE utf8_general_ci;
# 查看是否创建成功
show databases;

14.安装pyhive

./build/env/bin/pip install pyhive

15.启动hue

nohup build/env/bin/supervisor >/dev/null 2>&1 &

16.验证服务器是否启动成功

浏览器输入地址:http://data-repo-03:8888

17.创建hue账号

第一次访问hue web时会提示创建hue账号,输入账号和密码。账号名称最好是:hadoop

常见问题

1.安装提示Error: must have python development packages for python2.7. Could not find Python.h. Please install python2.7-devel

yum -y install python-devel.x86_64

2.安装提示_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory

yum -y install libffi-devel

3.安装提示make[1]: Entering directory `/home/hadoop/soft/hue-4.8'
npm --version
/bin/bash: npm: command not found
make[1]: * [npm-install] Error 127
make[1]: Leaving directory `/home/hadoop/soft/hue-4.8'
make: * [apps] Error 2

解决:安装nodejs环境

3.编译过程提示- /app/hadoop/software/node-v12.19.0/bin/npm

at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Module.require (internal/modules/cjs/loader.js:903:19)
at require (internal/modules/cjs/helpers.js:74:18)
at /app/hadoop/software/node-v12.19.0/bin/npm:19:21
at Object.<anonymous> (/app/hadoop/software/node-v12.19.0/bin/npm:155:3)
at Module._compile (internal/modules/cjs/loader.js:1015:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14) {

code: 'MODULE_NOT_FOUND',
requireStack: [ '/app/hadoop/software/node-v12.19.0/bin/npm' ]
}

执行npm --version还是提示报错。
解决办法:重新安装nodejs

4.如果需要将hue sqlite元数据同步到MySQL中

# 同步数据库
./build/env/bin/hue syncdb
# 导入数据,主要包括oozie、pig、desktop所需要的表
./build/env/bin/hue migrate

5.报错:hue 'ascii' codec can't encode characters in position 8-15: ordinal not in range(128)

解决办法:

vim ./build/env/lib/python2.7/site-packages/Django-1.11.29-py2.7.egg/django/core/management/base.py

添加代码:

import sys
reload(sys)
sys.setdefaultencoding('utf8')
如果觉得我的文章对你有用,请随意赞赏