Zeppelin0.7.2結合hive直譯器進行報表展示
1.環境和變數配置
①拷貝hive的配置檔案hive-site.xml到zeppelin-0.7.2-bin-all/conf下
# cp /root/hadoop-2.6.0/conf/hive-site.xml /data/hadoop/zeppelin/zeppelin-0.7.2-bin-all/conf
②進入conf下進行環境變數的配置
# cd /data/hadoop/zeppelin/zeppelin-0.7.2-bin-all/conf
vim zeppelin-env.sh
export JAVA_HOME=/usr/java/jdk1.8.0_111
export HADOOP_CONF_DIR=/root/hadoop-2.6.0/conf
2.在web介面配置整合hive
訪問zeppelin的web介面(http://ip:8080)
右上角anonymous --> interpreter --> +Create新建一個叫做hive的整合環境(也可以在jdbc的基礎上修改,不用新建)
編輯hive的相關屬性,hive相關的配置可以到hive-site.xml中檢視
Properties value
common.max_count 1000
hive.driver org.apache.hive.jdbc.HiveDriver
hive.password hive
hive.url jdbc:hive2://uhadoop-bwgkeu-master2:10000 # 注意是hive2不是hive
hive.user hive
zeppelin.interpreter.localRepo /data/hadoop/zeppelin/zeppelin-0.7.2-bin-all/local-repo/2CNPYUV7Z
zeppelin.interpreter.output.limit 102400
zeppelin.jdbc.auth.type
zeppelin.jdbc.concurrent.max_connection 10
zeppelin.jdbc.concurrent.use true
zeppelin.jdbc.keytab.location
zeppelin.jdbc.principal
填寫Dependencies相關屬性
2個hive依賴包,一個mysql依賴包,不用mysql可以不用寫mysql jdbc包
填好後點儲存,這個時候zeppelin會出現卡頓,這是因為上面填的2個Dependencies,zeppelin去指定maven庫下載相關依賴包去了,等待時間可能需幾分鐘。
下載完成可在local-repo目錄下檢視,依賴包放在local-repo/2CNPYUV7Z/(可能不同)目錄下,等完全下載完成,就可查詢。
Dependencies
artifact exclude
org.apache.hive:hive-jdbc:0.14.0
org.apache.hadoop:hadoop-common:2.6.0
mysql:mysql-connector-java:5.1.38
# ls local-repo/2CNPYUV7Z/
activation-1.1.jar commons-lang-2.6.jar hive-shims-common-0.14.0.jar jta-1.1.jar
ant-1.9.1.jar commons-logging-1.1.3.jar hive-shims-common-secure-0.14.0.jar junit-4.11.jar
ant-launcher-1.9.1.jar commons-math3-3.1.1.jar htrace-core-3.0.4.jar libfb303-0.9.0.jar
antlr-2.7.7.jar commons-net-3.1.jar httpclient-4.2.5.jar libthrift-0.9.0.jar
antlr-runtime-3.4.jar commons-pool-1.5.4.jar httpcore-4.2.5.jar log4j-1.2.16.jar
apacheds-i18n-2.0.0-M15.jar curator-client-2.6.0.jar jackson-core-asl-1.9.13.jar log4j-1.2.17.jar
apacheds-kerberos-codec-2.0.0-M15.jar curator-framework-2.6.0.jar jackson-core-asl-1.9.2.jar mail-1.4.1.jar
api-asn1-api-1.0.0-M20.jar curator-recipes-2.6.0.jar jackson-jaxrs-1.9.13.jar mysql-connector-java-5.1.38.jar
api-util-1.0.0-M20.jar datanucleus-api-jdo-3.2.6.jar jackson-mapper-asl-1.9.13.jar netty-3.6.2.Final.jar
asm-3.1.jar datanucleus-core-3.2.10.jar jackson-mapper-asl-1.9.2.jar opencsv-2.3.jar
asm-3.2.jar datanucleus-rdbms-3.2.9.jar jackson-xc-1.9.13.jar paranamer-2.3.jar
asm-commons-3.1.jar derby-10.10.1.1.jar java-xmlbuilder-0.4.jar protobuf-java-2.5.0.jar
asm-tree-3.1.jar geronimo-annotation_1.0_spec-1.1.1.jar jaxb-api-2.2.2.jar servlet-api-2.5.jar
avro-1.7.4.jar geronimo-jaspic_1.0_spec-1.0.jar jaxb-impl-2.2.3-1.jar slf4j-api-1.7.5.jar
avro-1.7.5.jar geronimo-jta_1.1_spec-1.1.1.jar jdo-api-3.0.1.jar slf4j-log4j12-1.7.5.jar
bonecp-0.8.0.RELEASE.jar gson-2.2.4.jar jersey-core-1.9.jar snappy-java-1.0.4.1.jar
commons-beanutils-1.7.0.jar guava-11.0.2.jar jersey-json-1.9.jar snappy-java-1.0.5.jar
commons-beanutils-core-1.8.0.jar hadoop-annotations-2.6.0.jar jersey-server-1.9.jar stax-api-1.0-2.jar
commons-cli-1.2.jar hadoop-auth-2.6.0.jar jets3t-0.9.0.jar stringtemplate-3.2.1.jar
commons-codec-1.4.jar hadoop-common-2.6.0.jar jettison-1.1.jar tools.jar
commons-collections-3.2.1.jar hamcrest-core-1.3.jar jetty-6.1.26.jar xmlenc-0.52.jar
commons-compress-1.4.1.jar hive-common-0.14.0.jar jetty-all-7.6.0.v20120127.jar xz-1.0.jar
commons-configuration-1.6.jar hive-jdbc-0.14.0.jar jetty-util-6.1.26.jar zookeeper-3.4.5.jar
commons-dbcp-1.4.jar hive-metastore-0.14.0.jar jline-0.9.94.jar zookeeper-3.4.6.jar
commons-digester-1.8.jar hive-serde-0.14.0.jar jpam-1.1.jar
commons-httpclient-3.1.jar hive-service-0.14.0.jar jsch-0.1.42.jar
commons-io-2.4.jar hive-shims-0.14.0.jar jsr305-1.3.9.jar
如果有問題,可以檢視日誌查詢原因,日誌路徑:/data/hadoop/zeppelin/zeppelin-0.7.2-bin-all/logs/zeppelin-interpreter-jdbc-root-u04rdp01.yaya.corp.log
3.新建一個作業進行測試
notebook --> Create new node填寫名稱,選擇hive即可
輸入查詢語句,注意查詢語句前需要有字首(hive):
(hive)
select * from tbl_push_user_req limit 3;
柱狀圖展示
餅狀圖形展示