Hive 的 hiveserver2 和 beeline 使用


Hive 开启了 hiveserver2 才能远程连接到 Hive

  • hiveserver2 : 可以理解为一个 服务端
  • beeline : 可以理解为一个 客户端
# 它们在 Hive 的 bin/ 目录下
[root@master bin]# ll
总用量 32
-rwxr-xr-x. 1 root root 1031 4月   1 2017 beeline
drwxr-xr-x. 3 root root 4096 12月 26 16:43 ext
-rwxr-xr-x. 1 root root 7844 4月   1 2017 hive
-rwxr-xr-x. 1 root root 1900 1月   8 2016
-rwxr-xr-x. 1 root root  885 1月   8 2016 hiveserver2
-rwxr-xr-x. 1 root root  832 1月   8 2016 metatool
-rwxr-xr-x. 1 root root  884 1月   8 2016 schematool


搭建的是 Hadoop 伪分布式进行测试

开启两个窗口,一个运行 hiveserver2 ,另一个运行 beeline

运行 hiveserver2 当做服务端 下图这样挂住就算开启


另一个窗口执行 beeline 当做客户端,当然客户端不一定是 beeline ,还能是其他的一些客户端,但连接的地址、用户名、密码是一个道理


连接 Hive ,进行查询 连接地址:!connect jdbc:hive2://master:10000



beeline 的所有命令

0: jdbc:hive2://master:10000> help
!addlocaldriverjar  Add driver jar file in the beeline client side.
!addlocaldrivername Add driver name that needs to be supported in the beeline
                    client side.
!all                Execute the specified SQL against all the current connections
!autocommit         Set autocommit mode on or off
!batch              Start or execute a batch of statements
!brief              Set verbose mode off
!call               Execute a callable statement
!close              Close the current connection to the database
!closeall           Close all current open connections
!columns            List all the columns for the specified table
!commit             Commit the current transaction (if autocommit is off)
!connect            Open a new connection to the database.
!dbinfo             Give metadata information about the database
!describe           Describe a table
!dropall            Drop all tables in the current database
!exportedkeys       List all the exported keys for the specified table
!go                 Select the current connection
!help               Print a summary of command usage
!history            Display the command history
!importedkeys       List all the imported keys for the specified table
!indexes            List all the indexes for the specified table
!isolation          Set the transaction isolation for this connection
!list               List the current connections
!manual             Display the BeeLine manual
!metadata           Obtain metadata information
!nativesql          Show the native SQL for the specified statement
!nullemptystring    Set to true to get historic behavior of printing null as
                    empty string. Default is false.
!outputformat       Set the output format for displaying results
                    (table,vertical,csv2,dsv,tsv2,xmlattrs,xmlelements, and
                    deprecated formats(csv, tsv))
!primarykeys        List all the primary keys for the specified table
!procedures         List all the procedures
!properties         Connect to the database specified in the properties file(s)
!quit               Exits the program
!reconnect          Reconnect to the database
!record             Record all output to the specified file
!rehash             Fetch table and column names for command completion
!rollback           Roll back the current transaction (if autocommit is off)
!run                Run a script from the specified file
!save               Save the current variabes and aliases
!scan               Scan for installed JDBC drivers
!script             Start saving a script to a file
!set                Set a beeline variable
!sh                 Execute a shell command
!sql                Execute a SQL command
!tables             List all the tables in the database
!typeinfo           Display the type map for the current connection
!verbose            Set verbose mode on

Comments, bug reports, and patches go to ???
0: jdbc:hive2://master:10000>
发表评论 / Comment