SparkSQL使用之Thrift JDBC Server(2)

Usage: java org.apache.hive.cli.beeline.BeeLine
  -u <database url>              the JDBC URL to connect to
  -n <username>                  the username to connect as
  -p <password>                  the password to connect as
  -d <driver class>              the driver class to use
  -e <query>                      query that should be executed
  -f <file>                      script file that should be executed
  --color=[true/false]            control whether color is used for display
  --showHeader=[true/false]      show column names in query results
  --headerInterval=ROWS;          the interval between which heades are displayed
  --fastConnect=[true/false]      skip building table/column list for tab-completion
  --autoCommit=[true/false]      enable/disable automatic transaction commit
  --verbose=[true/false]          show verbose error messages and debug info
  --showWarnings=[true/false]    display connection warnings
  --showNestedErrs=[true/false]  display nested errors
  --numberFormat=[pattern]        format numbers using DecimalFormat pattern
  --force=[true/false]            continue running script even after errors
  --maxWidth=MAXWIDTH            the maximum width of the terminal
  --maxColumnWidth=MAXCOLWIDTH    the maximum width to use when displaying columns
  --silent=[true/false]          be more silent
  --autosave=[true/false]        automatically save preferences
  --outputformat=[table/vertical/csv/tsv]  format mode for result display
  --isolation=LEVEL              set the transaction isolation level
  --help                          display this message

Thrift JDBC Server/beeline启动

启动Thrift JDBC Server:默认端口是10000

cd $SPARK_HOME/sbin
start-thriftserver.sh

如何修改Thrift JDBC Server的默认监听端口号?借助于--hiveconf

start-thriftserver.sh  --hiveconf hive.server2.thrift.port=14000

HiveServer2 Clients 详情参见:https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients

启动beeline

cd $SPARK_HOME/bin
beeline -u jdbc:hive2://hadoop000:10000/default -n hadoop

sql脚本测试

SELECT track_time, url, session_id, referer, ip, end_user_id, city_id FROM page_views WHERE city_id = -1000 limit 10;
SELECT session_id, count(*) c FROM page_views group by session_id order by c desc limit 10;

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/961b06a98bac8ffd68206cedd8d79f87.html