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