【原创】大数据基础之Ambari(5)通过Ambari部署Hue

时间:2023-03-09 19:39:53
【原创】大数据基础之Ambari(5)通过Ambari部署Hue

ambari2.7.3(hdp3.1) 安装 hue4.2

ambari的hdp中原生不支持hue安装,下面介绍如何通过添加service的方式使ambari支持hue安装:

【原创】大数据基础之Ambari(5)通过Ambari部署Hue

官方:http://gethue.com/

Hue is an open source Workbench for developing and accessing Data Apps.

一 安装SERVICE

第三方service:https://github.com/EsharEditor/ambari-hue-service

1 下载

VERSION=`hdp-select status hadoop-client | sed 's/hadoop-client - \([0-9]\.[0-9]\).*/\1/'`
rm -rf /var/lib/ambari-server/resources/stacks/HDP/$VERSION/services/HUE
sudo git clone https://github.com/EsharEditor/ambari-hue-service.git /var/lib/ambari-server/resources/stacks/HDP/$VERSION/services/HUE

2 修改

第三方service中安装的是hue3.11,改为4.2,需要如下改动:

# cd /var/lib/ambari-server/resources/stacks/HDP/3.1/services/HUE
# sed -i 's/3.11.0/4.2.0/g' metainfo.xml
# sed -i 's/3.11.0/4.2.0/g' README.md
# sed -i 's/3.11.0/4.2.0/g' package/scripts/params.py
# sed -i 's/3.11.0/4.2.0/g' package/scripts/setup_hue.py

# vi package/scripts/params.py

--modify line

32 #download_url = 'cat /etc/yum.repos.d/HDP.repo | grep "baseurl" | awk -F \'=\' \'{print $2"hue/hue-4.2.0.tgz"}\''
33 download_url = 'echo "http://gethue.com/downloads/releases/4.2.0/hue-4.2.0.tgz"'

187 webhdfs_url = format('http://' + hdfs_httpfs_host + ':50070/webhdfs/v1')

--without yarn

:234,256s/^/#/g

# vi package/scripts/common.py

--add line 59,63,64

58 Execute('tar -zxvf hue.tgz -C {0} && rm -f hue.tgz'.format(params.hue_install_ dir))
59 Execute('mkdir -p {0}'.format(params.hue_dir))
60 # Ensure all Hue files owned by hue 61 Execute('chown -R {0}:{1} {2}'.format(params.hue_user,params.hue_group,params. hue_dir))
62 Execute('ln -s {0} /usr/hdp/current/hue-server'.format(params.hue_dir))
63 Execute('rm -rf {0}/*'.format(params.hue_dir))
64 Execute('cd /usr/local/hue-4.2.0 && make install')

--comment line

90 #services_configurations['httpfs-site'] = {}
91 #services_configurations['httpfs-site']['httpfs.proxyuser.hue.groups'] = '*'
92 #services_configurations['httpfs-site']['httpfs.proxyuser.hue.hosts'] = '*'

# vi package/scripts/setup_hue.py

--comment line

26 #Logger.info("Creating symlinks /usr/hdp/current/hadoop-client/lib/hue-plugins -4.2.0-SNAPSHOT.jar")
27 #Link("{0}/desktop/libs/hadoop/java-lib/*".format(params.hue_dir),to = "/usr/h dp/current/hadoop-client/lib")

# vi package/files/configs.sh

39 PASSWD="admin"

注意这一步

download_url = 'echo "http://gethue.com/downloads/releases/4.2.0/hue-4.2.0.tgz"'

hue-4.2.0.tgz需要手工下载并放到一个服务器可访问的url上(比如本地的nginx),同时修改这里的download_url

二 在ambari中部署

1 添加用户

useradd hue

2 页面部署安装hue

安装后的hue目录位于/usr/local/hue/

3 修改配置

1)修改数据库配置

# vi desktop/conf/hue.ini

[[database]]

# Database engine is typically one of:

# postgresql_psycopg2, mysql, sqlite3 or oracle.

#

# Note that for sqlite3, 'name', below is a path to the filename. For other backends, it is the database name

# Note for Oracle, options={"threaded":true} must be set in order to avoid crashes.

# Note for Oracle, you can use the Oracle Service Name by setting "host=" and "port=" and then "name=<host>:<port>/<service_name>".

# Note for MariaDB use the 'mysql' engine.

## engine=sqlite3

## host=

## port=

## user=

## password=

# conn_max_age option to make database connection persistent value in seconds

# https://docs.djangoproject.com/en/1.9/ref/databases/#persistent-connections

## conn_max_age=0

# Execute this script to produce the database password. This will be used when 'password' is not set.

## password_script=/path/script

## name=desktop/desktop.db

修改engine、host、port、user、password、name

2)初始化数据库

# build/env/bin/hue syncdb

其中会创建初试用户名和密码

# build/env/bin/hue migrate

3)如果要支持数据库查询比如mysql,找到

[[databases]]

# mysql, oracle, or postgresql configuration.

## [[[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=mysqldb

# 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=example

# Password matching the username to authenticate with when

# connecting to the database.

## password=example

按照注释添加即可,可添加多个

4)如果需要增加impala查询,找到

[impala]

# Host of the Impala Server (one of the Impalad)

# server_host=localhost

# Port of the Impala Server

## server_port=21050

注意这里是21050端口,不是impala-shell连接的21000端口

5)可以通过配置blacklist来隐藏一些组件的菜单

[desktop]

app_blacklist=beeswax,impala,security,filebrowser,jobbrowser,rdbms,jobsub,pig,hbase,sqoop,zookeeper,metastore,spark,oozie,indexer

4 启动

直接启动

# build/env/bin/hue runcherrypyserver

后台启动supervisor(supervisor会监控并启动hue server)

# nohup build/env/bin/supervisor start >> logs/hue.out 2>&1 &

日志位于 /usr/local/hue/logs/ 下

三 使用

【原创】大数据基础之Ambari(5)通过Ambari部署Hue

如果hue使用nginx代理,一定要设置Host,否则会报400错误:

location / {

proxy_pass http://hue_backend;

proxy_set_header Host hue.anything;

}

另外还可以使用nginx来管理hue的静态文件,加速访问;

参考:https://blog.****.net/zhouyuanlinli/article/details/83374416