CLI hive -vs- Beelinenode
# Beeline操做結果 0: jdbc:hive2://node225:10000/movie> select * from t_user limit 5; OK +----------------+----------------+-------------+--------------------+-----------------+--+ | t_user.userid | t_user.gender | t_user.age | t_user.occupation | t_user.zipcode | +----------------+----------------+-------------+--------------------+-----------------+--+ | 1 | F | 1 | 10 | 48067 | | 2 | M | 56 | 16 | 70072 | | 3 | M | 25 | 15 | 55117 | | 4 | M | 45 | 7 | 02460 | | 5 | M | 25 | 20 | 55455 | +----------------+----------------+-------------+--------------------+-----------------+--+ # hive 操做結果 hive> select * from t_user limit 5; OK 1 F 1 10 48067 2 M 56 16 70072 3 M 25 15 55117 4 M 45 7 02460 5 M 25 20 55455 Time taken: 2.662 seconds, Fetched: 5 row(s) hive>
要使用Beeline前須要先啓動HiveServer2,啓動過程當中能夠經過hiveconf設置相應的自定義參數和值,直接啓動會佔據當前鏈接會話,第一次能夠直接啓動,正常啓動後能夠切換至後臺運行方式啓動。mongodb
# 直接啓動 [root@node225 ~]# /usr/local/hive-2.1.1/bin/hiveserver2 --hiveconf hive.server2.thrift.prot=10000 # 後臺運行方式啓動 [root@node225 ~]# /usr/local/hive-2.1.1/bin/hiveserver2 --hiveconf hive.server2.thrift.prot=10000 2>&1 >> /dev/null & #或者 #分別記錄標準日誌輸出和錯誤日誌 nohup /usr/local/hive-2.1.1/bin/hiveserver2 --hiveconf hive.server2.thrift.prot=10000 1>/usr/local/hive-2.1.1/hivelog/hiveserver.log 2>/usr/local/hive-2.1.1/hivelog/hiveserver.err & #不記錄日誌 nohup /usr/local/hive-2.1.1/bin/hiveserver2 --hiveconf hive.server2.thrift.prot=10000 1>/dev/null 2>/dev/null & nohup /usr/local/hive-2.1.1/bin/hiveserver2 --hiveconf hive.server2.thrift.prot=10000 >/dev/null 2>&1 &
beeline的使用編程
每成功運行一個命令,hiveserver2啓動的那個窗口,只要在啓動beeline的窗口中執行成功一條命令,另外個窗口隨即打印一個OK若是命令錯誤,hiveserver2那個窗口就會拋出異常安全
# beeline鏈接hive [root@node225 ~]# /usr/local/hive-2.1.1/bin/beeline -u jdbc:hive2://node225:10000/movie -n root which: no hbase in (.:/usr/local/jdk1.8.0_66//bin:/usr/local/zookeeper-3.4.10/bin:ZK_HOME/sbin:ZK_HOME/lib:/usr/local/hadoop-2.6.5//bin:/usr/local/hadoop-2.6.5//sbin:/usr/local/hadoop-2.6.5//lib:/usr/local/hive-2.1.1/bin:/usr/local/mongodb/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin) Connecting to jdbc:hive2://node225:10000/movie Connected to: Apache Hive (version 2.1.1) Driver: Hive JDBC (version 2.1.1) 18/10/09 14:03:00 [main]: WARN jdbc.HiveConnection: Request to set autoCommit to false; Hive does not support autoCommit=false. Transaction isolation: TRANSACTION_REPEATABLE_READ Beeline version 2.1.1 by Apache Hive 0: jdbc:hive2://node225:10000/movie> select current_database(); +----------------+--+ | database_name | +----------------+--+ | db_hive_edu | | default | | movie | +----------------+--+ 3 rows selected (1.293 seconds)
能夠在相同局域網內的其餘部署hive的節點上經過Beelin鏈接指定的HiveServer2服務,進行多用戶操做。性能優化
退出beeline鏈接用!quitbash