HUE安裝與使用


HUE安裝與使用

1、介紹

HUE是一個開源的Apache Hadoop UI系統,早期由Cloudera開發,后來貢獻給開源社區。它是基於Python Web框架Django實現的。通過使用Hue我們可以通過瀏覽器方式操縱Hadoop集群。例如put、get、執行MapReduce Job等等。

2、安裝

2.1 安裝hue依賴的第三方包

#安裝xml軟件包
$>sudo yum install -y libxml2-devel.x86_64

#安裝其他軟件包
$>sudo yum install -y libxslt-devel.x86_64 python-devel openldap-devel asciidoc cyrus-sasl-gssapi

1527152006500

3、 配置hue

hue與hadoop連接,即訪問hadoop文件,可以使用兩種方式。

  • WebHDFS

    提供高速數據傳輸,client可以直接和DataNode通信。

  • HttpFS

    一個代理服務,方便於集群外部的系統進行集成。注意:HA模式下只能使用該中方式。

3.1 配置hadoop的hue代理用戶

  1. [/soft/hadoop/etc/hadoop/core-site.xml]

    注意:hadoop的代理用戶配置方式是:hadoop.proxyuser.${superuser}.hosts,這里我的superuser是centos。

    <property>
    	<name>hadoop.proxyuser.centos.hosts</name>
        <value>*</value>
    </property>
    <property>
    	<name>hadoop.proxyuser.centos.groups</name>
    	<value>*</value>
    </property>
    
  2. [/soft/hadoop/etc/hadoop/hdfs-site.xml]

    <property>
    	<name>dfs.webhdfs.enabled</name>
    	<value>true</value>
    </property>
    
  3. [/soft/hadoop/etc/hadoop/httpfs-site.xml]

    <property>
    	<name>httpfs.proxyuser.centos.hosts</name>
    	<value>*</value>
    </property>
    <property>
     	<name>httpfs.proxyuser.centos.groups</name>
    	<value>*</value>
    </property>
    
  4. 分發配置文件

    $>cd /soft/hadoop/etc/hadoop
    $>xsync.sh core-site.xml
    $>xsync.sh hdfs-site.xml
    $>xsync.sh httpfs-site.xml
    

3.2 重啟hadoop和yarn進程

$>stop-dfs.sh
$>stop-dfs.sh

$>start-dfs.sh
$>start-yarn.sh

3.3 啟動httpfs進程

3.3.1 啟動進程
$>/soft/hadoop/sbin/httpfs.sh start
3.3.2 檢查14000端口
$>netstat -anop |grep 14000

1527152006500

3.4 配置hue文件

這里我們使用的是hadoop的namenode HA模式,因此只能配置httpfs方式訪問hdfs文件。需要注意的是webhdfs_url指定的是14000的端口,具體如下所示。

[/home/centos/hue-3.12.0/desktop/conf/hue.ini]

...
	[[[default]]]
      # Enter the filesystem uri
      fs_defaultfs=hdfs://mycluster:8020

      # NameNode logical name.
      logical_name=mycluster

      # Use WebHdfs/HttpFs as the communication mechanism.
      # Domain should be the NameNode or HttpFs host.
      # Default port is 14000 for HttpFs.
      webhdfs_url=http://s101:14000/webhdfs/v1

      # Change this if your HDFS cluster is Kerberos-secured
      ## security_enabled=false

      # In secure mode (HTTPS), if SSL certificates from YARN Rest APIs
      # have to be verified against certificate authority
      ## ssl_cert_ca_verify=True

      # Directory of the Hadoop configuration
      hadoop_conf_dir=/soft/hadoop/etc/hadoop

3.5 配置hue的數據庫為mysql

...
	[[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=mysql
    host=192.168.231.1
    port=3306
    user=root
    password=root
    # Execute this script to produce the database password. This will be used when 'password' is not set.
    ## password_script=/path/script
    name=hue
    ## options={}
    # Database schema, to be used only when public schema is revoked in postgres
    ## schema=

4、初始化mysql庫,生成表

4.1 創建hue庫

因為我們在hue.ini文件中指定的數據庫名為hue,因此需要先創建hue數據庫。

msyql>create database hue ;

4.2 初始化數據表

該步驟是創建表和插入部分數據。hue的初始化數據表命令由hue/bin/hue syncdb完成,創建期間,需要輸入用戶名和密碼。如下所示:

#同步數據庫
$>~/hue-3.12.0/build/env/bin/hue syncdb
#導入數據,主要包括oozie、pig、desktop所需要的表
$>~/hue-3.12.0/build/env/bin/hue migrate

1527152006500

4.3 查看mysql中是否生成表

查看是否在mysql中生成了所需要的表,截圖如下所示:

msyql>show tables ;

1527152006500

5、啟動hue進程

$>~/hue-3.12.0/build/env/bin/supervisor

啟動過程如下圖所示:

1527152006500

6、檢查webui

http://s101:8888/

打開登錄界面,輸入前文創建的賬戶即可。

1527152006500

7、訪問hdfs

點擊右上角的hdfs鏈接,進入hdfs系統畫面。

1527152006500

1527152006500

8、配置ResourceManager

8.1 修改hue.ini配置文件

  [[yarn_clusters]]
	...
	# [[[ha]]]
      # Resource Manager logical name (required for HA)
      logical_name=cluster1

      # Un-comment to enable
      ## submit_to=True

      # URL of the ResourceManager API
      resourcemanager_api_url=http://s101:8088

8.2 查看job執行情況

1527152006500

9、配置hive

9.1 編寫hue.ini文件

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

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

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

9.2 安裝依賴軟件包

如果不安裝以下的依賴包,會導致sasl方面的錯誤,說hiveserver2沒有啟動。

$>sudo yum install -y cyrus-sasl-plain  cyrus-sasl-devel  cyrus-sasl-gssapi

9.3 啟動hiveserver2服務器

$>/soft/hive/bin/hiveserver2

9.4 查看webui

1527152006500

10、配置hbase

10.1 修改hue.ini配置文件

hbase配置的是thriftserver2服務器地址,不是master地址,而且需要用小括號包起來。thriftserver需要單獨啟動。

[hbase]
  # Comma-separated list of HBase Thrift servers for clusters in the format of '(name|host:port)'.
  # Use full hostname with security.
  # If using Kerberos we assume GSSAPI SASL, not PLAIN.
  hbase_clusters=(s101:9090)

  # HBase configuration directory, where hbase-site.xml is located.
  hbase_conf_dir=/soft/hbase/conf

10.2 啟動thriftserver服務器

注意:thriftserver服務器啟動的名稱是thrift。切記:有些文檔上寫的是thrit2,這里是thrfit。

$>hbase-daemon.sh start thrift

10.3 查看端口9090

1527152006500

10.4 查看hue中hbase

1527152006500

11、配置spark

11.1 介紹

hue與spark的集成使用livy server進行中轉,livy server類似於hive server2。提供一套基於restful風格的服務,接受client提交http的請求,然后轉發給spark集群。livy server不在spark的發行包中,需要單獨下載。

注意:hue中通過netebook編寫scala或者python程序,要確保notebook可以使用,需要啟動hadoop的httpfs進程--切記!

注意下載使用較高的版本,否則有些類找不到。下載地址如下:

http://mirrors.tuna.tsinghua.edu.cn/apache/incubator/livy/0.5.0-incubating/livy-0.5.0-incubating-bin.zip

11.2 解壓

$>unzip livy-server-0.2.0.zip -d /soft/

11.3 啟動livy服務器

$>/soft/livy-server-0.2.0/bin/live-server

1527152006500

1527152006500

11.4 配置hue

推薦使用local或yarn模式啟動job,這里我們配置成spark://s101:7077。

[spark]
  # Host address of the Livy Server.
  livy_server_host=s101

  # Port of the Livy Server.
  livy_server_port=8998

  # Configure Livy to start in local 'process' mode, or 'yarn' workers.
  livy_server_session_kind=spark://s101:7077

11.5 使用notebook編寫scala程序

1527152006500

1527152006500


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM