Premise = = = = Hive

Hive must be installed on a Hadoop cluster and used as a data warehouse for a Hadoop cluster. Therefore, you need to have a Hadoop cluster. For details about how to build a Hadoop cluster, see Hadoop3.X+HA (2). This article uses Hadoop3. x to build a Hadoop cluster. In fact, it is just installation. We need to use hadoop2.8.5 + Hive-2.3.5.

Download = = = = Hive

Hive 2.3.5 is used as an example.Archive.apache.org/dist/hive/h…Generally, you need to download the compiled bin.tar.gz package apache-hive-2.1.5-bin.tar. gz, as shown in Figure 1

== Install the metadata library ==

== Select MySQL and create a hive database ==

In order to match the Hadoop family spirit of open source, metadata is used to install MySQL on a machine in the cluster. If MySQL is not installed, contact the DBA. MySQL 5.7.30 MySQL 5.7.30 MySQL 5.7.30 MySQL 5.7.30 MySQL 5.7.30 MySQL 5.7.30 MySQL 5.7.30 Create a hive user on the MySQL server and grant all hive library permissions to Hive.

create DATABASE hive   DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Copy the code

== Prepare a driver to connect to MySQL for Hive. ==

Note that Hive metadata library is not necessarily MySQL, so different types of libraries must require different connection driver Jar packages, and the current version of Hive does not provide you with ready Jar packages. So the need to make sure the Hive under lib directory with mysql connection driver mysql connector – Java – XXX. Jar, XXX is compatible with the installation of mysql version of metadata, mine is mysql – 5.7.30, Jar/mysql-connector-java-8.0.13.jar/mysql-connector-java-8.0.13.jar/mysql-connector-java-8.0.13.jar/mysql-connector-java-8.0.13.jar/mysql-connector-java-8.0.13.jar/mysql-connector-java-8.0.13.jar/mysql-connector-java-8.0.13.jar For example, run /data/tools/ apache-hive-2.1.5-bin /lib to change the permission of the driver Jar package.

Chmod 755 the mysql connector - Java - 8.0.13. JarCopy the code

Mysql-connector-java-xxx. jar download portal;

== Installation configuration ==

Use chmod 755 apache-hive-2.1.5-bin.tar. gz to change the permission of the tar package. Then decompress the tar package tar -zxvf apache-hive-2.1.5-bin.tar. gz and go to folderapache-hive-2.1.5-bin. Bin is the boot-related folder.

[hadoop@node1 apache-hive-2.1.5-bin]$ll Total usage 56 drwxrwxr-x. 3 hadoop hadoop 133 May 5 10:59 bin drwxrwxr-x. 2 hadoop Hadoop 4096 5月 5 10:59 binary-package-licenses drwxrwxr-x. 2 Hadoop Hadoop 4096 5月 5 10:59 conf drwxrwxr-x. 4 Hadoop Hadoop 34 May 5 10:59 examples drwxrwxr-x. 7 Hadoop Hadoop 68 May 5 10:59 hCatalog drwxrwxr-x. 2 Hadoop Hadoop 44 May 5 10:59 JDBC drwxrwxr-x. 4 Hadoop Hadoop 12288 May 5 10:59 Lib-rw-r --r--. 1 Hadoop Hadoop 20798 May 7 2019 LICENSE -rw-r--r-- 1 Hadoop Hadoop 230 May 8 2019 notice-rw-r -- 1 Hadoop Hadoop 277 May 8 2019 release_notes.txt drwxrwxr-x 4 Hadoop Hadoop 35 May 5月 5 10:59 ScriptsCopy the code

== Configure environment variables ==

/data/tools/ apache-hive-2.1.5-bin is the root directory of Hive. $PATH:$HIVE_HOME/bin = $HIVE_HOME/bin = $HIVE_HOME/bin

Export HIVE_HOME = / data/tools/apache - hive - 2.3.5 - bin export PATH = $PATH: $HIVE_HOME/binCopy the code

Hive –version = Hive –version = Hive –version = Hive –version

[hadoop @ node1 tools] $hive - version hive 2.3.5 Git Git: / / HW13934 / Users/gates/Git/hive - r 76595628ae13b95162e77bba365fe4d2c60b3f29 Compiled by gates on Tue May 7 15:45:09 PDT 2019 From source with checksum c7864fc25abcb9cf7a36953ac6be4665Copy the code

==Hive layout in the cluster ==

Hive configuration, select a Hive master, other nodes as slaves, the configuration of master and slaves is slightly different, not completely replicated, of course accurately speaking, it should be only one node is Hive server node is responsible for metadata and cluster internal communication, Other Hive nodes are actually installed as clients. When accessing the metadata database, these nodes switch to the Hive server node. Therefore, the configurations of the Hive server node and client node are slightly different. We have built a Hadoop development cluster of 4 nodes, we choose the following configuration, node1 as hive server node, install hive client on all four nodes, in fact, other nodes can not install Hive client, that is, you are using hive CLI can not use on other nodes. It makes sense, right? Other than that, it doesn’t matter.

  • NN Hadoop cluster namenode
  • DN Hadoop cluster Datanode
  • ZK Hadoop cluster ZooKeeper
  • ZKFC Hadoop cluster Zookeeper Failover Controller High availability Failover mechanism
  • JN Journal Node stores metadata of hadoop cluster
metadata(MySQL) hive master hive client NN DN ZK ZKFC JN RM DM
node1 1 1 1 1 1 1 1
node2 1 1 1 1 1 1 1
node3 1 1 1 1 1
node4 1 1 1 1

== Configure the Hive master node ==

Node1: hive master /conf: hive master /conf: hive master /conf: hive master /conf: hive master /conf: hive master /conf: hive master So we need to copy the hive-site. XML and edit the configuration. These shell instructions are as follows:

#Go to the conf directory of hiveCD/data/tools/apache - hive - 2.3.5 - bin/conf
#Generate a hive-site.xml file from the hive-default.xml.template source file
cp hive-default.xml.template hive-site.xml

#Edit the hive-site. XML file
vim hive-site.xml
Copy the code

The hive-site. XML configuration of hive master nodes is as follows. I simply borrowed some of the necessary hive configuration files, but fortunately I stole the baidu big man configuration file of 5000 lines, many configurations are adjusted relatively better, because 5000 lines can not write. The hive-2.3.5 configuration file can be downloaded from the hive-2.3.5 configuration file.


      

      <! -- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You are under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
<configuration>
 <! -- WARNING!!! This file is auto generated for documentation purposes ONLY! -->
 <! -- WARNING!!! Any changes you make to this file will be ignored by Hive. -->
 <! -- WARNING!!! You must make your changes in hive-site.xml instead. -->
 <! -- Hive Execution Parameters -->
 
<! Hive database connection configuration -->
<property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://node1:3306/hive? createDatabaseIfNotExist=true&amp;useUnicode=true&amp;characterEnconding=UTF-8</value>
</property>

<! -- Select JDBC driver for Hive metadata
<property>
        <name>javax.jdo.option.ConnectionDriverName</name>
        <value>com.mysql.cj.jdbc.Driver</value>
</property>

<! -- Hive metadata database login username -->
<property>
        <name>javax.jdo.option.ConnectionUserName</name>
        <value>hive</value>
</property>

<! -- Hive metadata database login password -->
<property>
        <name>javax.jdo.option.ConnectionPassword</name>
        <value>hive1234</value>
</property>

<property>
        <name>hive.metastore.schema.verification</name>
        <value>false</value>
   <description>Enforce metastore schema version consistency. True: Verify that version information stored in is compatible with one from Hive jars. Also disable automatic schema migration  attempt. Users are required to manually migrate schema after Hive upgrade which ensures proper metastore schema migration. (Default) False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.</description>
</property>

<property>
   <name>hive.server2.thrift.bind.host</name>
   <value>node1</value>
   <description>Bind host on which to run the HiveServer2 Thrift service.</description>
 </property>

<! -- Hive listening port -->
<property> 
   <name>hive.metastore.port</name>  
   <value>9083</value>  
   <description>Hive metastore listener port</description> 
 </property> 
<property>

<! Mysql > configure hive to connect to JDBC
<property>
   <name>hive.server2.thrift.port</name>
   <value>10000</value>
   <description>Port number of HiveServer2 Thrift interface when hive.server2.transport.mode is 'binary'.</description>
</property>

 <property>
   <name>hive.server2.thrift.http.port</name>
   <value>10001</value>
   <description>Port number of HiveServer2 Thrift interface when hive.server2.transport.mode is 'http'.</description>
 </property>
</configuration>
Copy the code

Hive slave configuration, that is, hive client configuration


      

      

<! -- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You are under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
<configuration> 
 <! -- WARNING!!! This file is auto generated for documentation purposes ONLY! -->  
 <! -- WARNING!!! Any changes you make to this file will be ignored by Hive. -->  
 <! -- WARNING!!! You must make your changes in hive-site.xml instead. -->  
 <! -- Hive Execution Parameters -->  
 <property> 
   <name>hive.metastore.local</name>  
   <value>false</value> 
 </property>  
 <property> 
   <name>hive.metastore.warehouse.dir</name>  
   <value>/hive/warehouse</value>  
   <description>location of default database for the warehouse</description> 
 </property>  
 <property> 
   <name>hive.metastore.uris</name>  
   <value>thrift://node1:9083</value>  
   <description>Thrift URI for the remote metastore. Used by metastore client to connect to remote metastore.</description> 
 </property>  
 <property> 
   <name>hive.metastore.schema.verification</name>  
   <value>false</value>  
   <description>Enforce metastore schema version consistency. True: Verify that version information stored in is compatible with one from Hive jars. Also disable automatic schema migration  attempt. Users are required to manually migrate schema after Hive upgrade which ensures proper metastore schema migration. (Default) False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.</description> 
 </property>  
 <property> 
   <name>hive.server2.transport.mode</name>  
   <value>binary</value>  
   <description>Expects one of [binary, http]. Transport mode of HiveServer2.</description> 
 </property>  
 <property> 
   <name>hive.server2.thrift.bind.host</name>  
   <value>node1</value>  
   <description>Bind host on which to run the HiveServer2 Thrift service.</description> 
 </property>  
 <property> 
   <name>hive.driver.parallel.compilation</name>  
   <value>false</value>  
   <description>Whether to enable parallel compilation of the queries between sessions and within the same session on HiveServer2. The default is false.</description> 
 </property>  
 <property> 
   <name>hive.server2.metrics.enabled</name>  
   <value>false</value>  
   <description>Enable metrics on the HiveServer2.</description> 
 </property>  
 <property> 
   <name>hive.server2.thrift.http.port</name>  
   <value>10001</value>  
   <description>Port number of HiveServer2 Thrift interface when hive.server2.transport.mode is 'http'.</description> 
 </property>  
 <property> 
   <name>hive.server2.thrift.http.path</name>  
   <value>cliservice</value>  
   <description>Path component of URL endpoint when in HTTP mode.</description> 
 </property>  
 <property> 
   <name>hive.server2.thrift.max.message.size</name>  
   <value>104857600</value>  
   <description>Maximum message size in bytes a HS2 server will accept.</description> 
 </property>  
 <property> 
   <name>hive.server2.thrift.http.max.idle.time</name>  
   <value>1800s</value>  
   <description>Expects a time value with unit (d/day, h/hour, m/min, s/sec, ms/msec, us/usec, ns/nsec), which is msec if not specified. Maximum idle time for a connection on the server when in HTTP mode.</description> 
 </property>  
 <property> 
   <name>hive.server2.thrift.http.worker.keepalive.time</name>  
   <value>60s</value>  
   <description>Expects a time value with unit (d/day, h/hour, m/min, s/sec, ms/msec, us/usec, ns/nsec), which is sec if not specified. Keepalive time for an idle http worker thread. When the number of workers exceeds min workers, excessive threads are killed after this time interval.</description> 
 </property>  
 <property> 
   <name>hive.metastore.port</name>  
   <value>9083</value>  
   <description>Hive metastore listener port</description> 
 </property> 
<property>
   <name> mapreduce.job.queuename</name>
   <value>etl</value>
   <description>
     Used to specify name of Hadoop queue to which
     jobs will be submitted.  Set to empty string to let Hadoop choose the queue.
   </description>
 </property>
</configuration>
Copy the code

== Initialize Hive==

Before starting the first need to initialize the metadata repository, is to write the related metadata of hive to prepare us to MySQL hive a repository, initialization of the shell commands schematool – dbType MySQL – initSchema, specific as follows:

[hadoop@node1 conf]$ schematool -dbType mysql -initSchema SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found the binding in [the jar: file: / data/tools/apache - hive - 2.3.5 - bin/lib/log4j - slf4j - impl - 2.6.2. Jar! /org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found the binding in [the jar: file: / data/tools/hadoop - 2.8.5 / share/hadoop/common/lib/slf4j - log4j12-1.7.10. Jar! /org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Metastore connection URL: jdbc:mysql://node1:3306/hive?createDatabaseIfNotExist=true&useUnicode=true&characterEnconding=UTF-8 Metastore Connection  Driver : com.mysql.cj.jdbc.Driver Metastore connection User: Hive Starting metastore schema initialization to 2.3.0 Initialization script hive-schema-2.3.0.mysql script completed schemaTool completedCopy the code

After the hive database is successfully initialized, you can see that many new tables are added to the Hive metadata database. These tables are used to store hive metadata.

Initialization is actually the/data/tools/apache – hive – 2.3.5 – bin/scripts/metastore/upgrade/mysql under relevant SQL statements try to run in mysql hive a repository, Ensure that metadata is successfully initialized from the Hive library. Schematool completed. If an initialization error occurs and you do not have permission to log in to Hive, check whether the Hive configuration of the login metadata database configured on hive-site. XML of your master node is correct. Note The following is not an example: The mysql version is not the same as the driver, or mysql has limited the length of the index, resulting in a failure to initialize the Hive table, or the IP address, port, user name, and password for logging in to the Hive metadata database are written incorrectly. You can use Hive on the master node first.

[hadoop@node1 conf]$ hive which: no hbase in (/ data/tools/jdk1.8.0 _211 / bin: / usr/local/bin: / usr/bin: / usr/local/sbin, / usr/sbin/data/tools/apache - hive - 2.3.5 - bin/bin: / d Ata/tools/zookeeper - 3.4.14: / data/tools/hadoop - 2.8.5 / sbin/data/tools/hadoop - 2.8.5 / bin: / data/tools/mysql - 5.7.30 - Linux - gli Bc2.12 - x86_64 / bin: / home/hadoop/local/bin: / home/hadoop/bin) SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found the binding in [the jar: file: / data/tools/apache - hive - 2.3.5 - bin/lib/log4j - slf4j - impl - 2.6.2. Jar! /org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found the binding in [the jar: file: / data/tools/hadoop - 2.8.5 / share/hadoop/common/lib/slf4j - log4j12-1.7.10. Jar! /org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Logging initialized using configuration in The jar: file: / data/tools/apache - hive - 2.3.5 - bin/lib/hive - common - 2.3.5. Jar! /hive-log4j2.properties Async: true Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.hive> show databases;OK default Time taken: 31.212 seconds, touch_type: 1 row(s)hive> create database dw;
OK
Time taken: 0.884 seconds
Copy the code

This is because we use the master node as the server mode, so we need to start the Hive server to ensure that the client mode can be accessed.

[hadoop@node2 conf]$ hive which: no hbase in (/ data/tools/jdk1.8.0 _211 / bin: / data/tools/jdk1.8.0 _211 / bin: / usr/local/bin: / usr/bin: / usr/local/sbin, / usr/sbin/data/tools / zookeeper - 3.4.14: / data/tools/hadoop - 2.8.5 / sbin/data/tools/hadoop - 2.8.5 / bin: / home/hadoop/local/bin: / home/hadoop/bin: / d Ata/tools/apache - hive - 2.3.5 - bin/bin: / data/tools/zookeeper - 3.4.14: / data/tools/hadoop - 2.8.5 / sbin/data/tools/hadoop - 2.8.5 / bin) SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found the binding in [the jar: file: / data/tools/apache - hive - 2.3.5 - bin/lib/log4j - slf4j - impl - 2.6.2. Jar! /org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found the binding in [the jar: file: / data/tools/hadoop - 2.8.5 / share/hadoop/common/lib/slf4j - log4j12-1.7.10. Jar! /org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Logging initialized using configuration in The jar: file: / data/tools/apache - hive - 2.3.5 - bin/lib/hive - common - 2.3.5. Jar! /hive-log4j2.properties Async: true Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.hive> show databases;
FAILED: SemanticException org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

Copy the code

== Start the Hive service ==

Sh shell command vim /data/tools/ apache-hive-2.1.5-bin /start_hive.sh. The contents in the file are as follows, and then save and exit.

#! /usr/bin/env bash

#Start the Hive Service in the background
nohup hive --service metastore >> /data/logs/hive/meta.log 2>&1 &

#Start the JDBC service of hive in the background
nohup  hive --service hiveserver2 >> /data/logs/hive/hiveserver2.log 2>&1 &

Copy the code

To restart Hive, run the JPS script to kill the two runjars and run the JPS script. If you change the HDFS or Hive configuration using JDBC, you may not be able to refresh the new configuration. If you change the HDFS block size, you may even report an error. If you change the HDFS block size using JDBC, you may even report an error. An exception may be raised. In this case, you need to restart the HIVE JDBC service.

[hadoop@node1 apache-hive-2.1.5-bin]$JPS 8195 DFSZKFailoverController 15686 JPS 7607 NameNode 15303 RunJar 6408 QuorumPeerMain 15304 RunJarCopy the code

Hive = = = = cli connection

Blog Hive from the beginning to give up — Hive background and infrastructure introduction (a) talked about the connection to Hive several forms, which is more commonly used cli mode, because we configured the Hive environment variables, only need to directly in the shell Hive can enter, specific as follows;

[hadoop@node2 conf]$ hive which: no hbase in (/ data/tools/jdk1.8.0 _211 / bin: / data/tools/jdk1.8.0 _211 / bin: / usr/local/bin: / usr/bin: / usr/local/sbin, / usr/sbin/data/tools / zookeeper - 3.4.14: / data/tools/hadoop - 2.8.5 / sbin/data/tools/hadoop - 2.8.5 / bin: / home/hadoop/local/bin: / home/hadoop/bin: / d Ata/tools/apache - hive - 2.3.5 - bin/bin: / data/tools/zookeeper - 3.4.14: / data/tools/hadoop - 2.8.5 / sbin/data/tools/hadoop - 2.8.5 / bin) SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found the binding in [the jar: file: / data/tools/apache - hive - 2.3.5 - bin/lib/log4j - slf4j - impl - 2.6.2. Jar! /org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found the binding in [the jar: file: / data/tools/hadoop - 2.8.5 / share/hadoop/common/lib/slf4j - log4j12-1.7.10. Jar! /org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Logging initialized using configuration in The jar: file: / data/tools/apache - hive - 2.3.5 - bin/lib/hive - common - 2.3.5. Jar! /hive-log4j2.properties Async: true Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.hive> show databases;
FAILED: SemanticException org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

Copy the code

== Connect to hive using JDBC ==

Ensure that the JDBC connection has been configured for hive and the JDBC Service has been enabled, and the JDBC connection using shell commands is as follows:

Method 1 beeline

! Connect JDBC :hive2:// DW-test-cluster-007:10000 Enter the user name and password. Method 2: or beeline -u “JDBC :hive2:// DW-test-cluster-007:10000” -n hadoop hadoop -u: specifies the link information of the metadata database. -n: specifies the user name and password

The JDBC connection effect in a shell environment is as follows:

[hadoop@node1 apache-hive-2.1.5-bin]$beeline -u "JDBC :hive2://node1:10000" -n hadoop Hadoop SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found the binding in [the jar: file: / data/tools/apache - hive - 2.3.5 - bin/lib/log4j - slf4j - impl - 2.6.2. Jar! /org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found the binding in [the jar: file: / data/tools/hadoop - 2.8.5 / share/hadoop/common/lib/slf4j - log4j12-1.7.10. Jar! /org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Connecting to jdbc:hive2://node1:10000 Connected To: Apache Hive (Version 2.3.5) Driver: Hive JDBC (Version 2.3.5) Transaction Isolation: TRANSACTION_REPEATABLE_READ Beeline version 2.3.5 by Apache Hive 0: JDBC :hive2://node1:10000> show databases; + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + | database_name | + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + | default | | dw | + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + 2 rows selected (5.817) seconds) 0: jdbc:hive2://node1:10000>Copy the code

You can also use ide tools that support JDBC to connect. For details, see Hive from Getting started to Giving up. Note: JDBC stability is not as good as cli. First, JDBC in Hive is cold loaded. You may not be able to obtain JDBC in real time if you change HDFS or Hive configuration. If you can’t connect properly using any of the above JDBC commands in your shell environment, consider whether the JDBC service is broken.

== Basic use ==

After baidu and Bing solve all installation problems and start up normally, directly enter hive in the shell environment inside the cluster, it will be called as shown in Figure 2. Note that normal startup is also clean, if an error is reported during startup, even if the CLI environment of ‘hive>’ finally jumps out. If the configuration is not perfect, you can use the CLI or JDBC mode to log in to Hive and test whether hive is available.

Hive SQL is similar to MySQL, but not exactly the same, with different data types
show databases; - check the DBs
use default; Switch to the default library

- build table
Note that primary keys and indexes are not popular in Hive.
- Allows data to be appended to a file, not deleted at the row level
create table if not exists user(
id string comment 'openId', 
phone string comment 'phone', 
user_name string comment 'Username', 
sex string comment 'Gender, male and female.', 
certificate_no string comment Identity card,  
create_time string 
)
row format delimited fields terminated by '\t' NULL DEFINED AS ' ' stored as textfile;

select * from user limit 10;- the query

Copy the code

Note: Hive does not require user name and password authentication as mysql does, but requires a combination of other technologies and secondary development. However, many hive implementations do not care about this, but instead use firewall ports and other technologies to restrict secure access to Hive.