beeline和hiveserver2
beeline和HS2(hiveserver2)的架构是C-S架构,如果想要用beeline作为与hive的交换工具,必须在hive中启动hiveserver2服务
后台启动hiveserver2服务
./beeline -u jdbc:hive2://hadoop001:10000/default -n hadoop 这是beeline连接hive固定写法,default代表的是hive的默认库,10000是默认端口,hadoop是当前运行的用户。
[hadoop@hadoop001 ~]$ beeline -u jdbc:hive2://hadoop001:10000/default -n hadoop
which: no hbase in (/home/hadoop/app/hive-1.1.0-cdh5.7.0/bin:/home/hadoop/app/hadoop/bin:/home/hadoop/app/scala-2.13.0/bin:/home/hadoop/app/apache-maven-3.6.1/bin:/usr/java/jdk1.8.0_45/bin/:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/hadoop/.local/bin:/home/hadoop/bin)
scan complete in 1ms
Connecting to jdbc:hive2://hadoop001:10000/default
Connected to: Apache Hive (version 1.1.0-cdh5.7.0)
Driver: Hive JDBC (version 1.1.0-cdh5.7.0)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 1.1.0-cdh5.7.0 by Apache Hive
0: jdbc:hive2://hadoop001:10000/default> show tables;
INFO : Compiling command(queryId=hadoop_20190721163939_d41aba86-f1b4-48f2-92e3-8b21554ccb24): show tables
INFO : Semantic Analysis Completed
INFO : Returning Hive schema: Schema(fieldSchemas:[FieldSchema(name:tab_name, type:string, comment:from deserializer)], properties:null)
INFO : Completed compiling command(queryId=hadoop_20190721163939_d41aba86-f1b4-48f2-92e3-8b21554ccb24); Time taken: 0.481 seconds
INFO : Concurrency mode is disabled, not creating a lock manager
INFO : Executing command(queryId=hadoop_20190721163939_d41aba86-f1b4-48f2-92e3-8b21554ccb24): show tables
INFO : Starting task [Stage-0:DDL] in serial mode
INFO : Completed executing command(queryId=hadoop_20190721163939_d41aba86-f1b4-48f2-92e3-8b21554ccb24); Time taken: 0.403 seconds
INFO : OK
+------------------+--+
| tab_name |
+------------------+--+
| dual |
| emp |
| emp2 |
| emp3 |
| hello |
| hello_bak |
| hive_row_number |
| rating_json |
| rating_width |
| wc |
+------------------+--+
10 rows selected (1.073 seconds)
0: jdbc:hive2://hadoop001:10000/default>
当beeline命令执行成功,此时也可以查看/tmp/hivesever2.log日志,应该以会有一个ok
[hadoop@hadoop001 conf]$ tail -10 /tmp/hiveserver2.log
nohup: ignoring input
which: no hbase in (/home/hadoop/app/hive-1.1.0-cdh5.7.0/bin:/home/hadoop/app/hadoop/bin:/home/hadoop/app/scala-2.13.0/bin:/home/hadoop/app/apache-maven-3.6.1/bin:/usr/java/jdk1.8.0_45/bin/:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/hadoop/.local/bin:/home/hadoop/bin)
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
nohup: ignoring input
which: no hbase in (/home/hadoop/app/hive-1.1.0-cdh5.7.0/bin:/home/hadoop/app/hadoop/bin:/home/hadoop/app/scala-2.13.0/bin:/home/hadoop/app/apache-maven-3.6.1/bin:/usr/java/jdk1.8.0_45/bin/:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/hadoop/.local/bin:/home/hadoop/bin)
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
OK
[hadoop@hadoop001 conf]$
注意:HS2的默认参数:
hive.server2.thrift.port– TCP 的监听端口,默认为10000
hive.server2.thrift.http.port– HTTP的监听端口,默认值为10001
hive.server2.transport.mode – 默认值为binary(TCP),可选值HTTP
如果需要修改参数可以是:set hive.server2.thrift.port=10010临时修改,也可以将这个参数放到$HIVE_HOME/conf/hive_site.xml
中永久生效。