Ubuntu 16.04 - Hive 3.1.2 Installation

zero, environment

Host version: Windows11

Virtual machine version: ubuntukylin-16.04-desktop-amd64

VMware version: VMware® Workstation 17 Pro

NIC: bridge mode

jdk version: jdk-8u162

Hadoop version: hadoop-3.1.3

Note: The hardware version used is compatible with VMware 12.X.

It needs to be explained here. Before Hive 3.1.2installing, please make sure that it has been installed Hadoop 3.1.3. If it has not been installed Hadoop 3.1.3, you can refer to Ubuntu 16.04——Hadoop Cluster Installation Configuration to install it.

1. Install Hive 3.1.2

On Apachethe official website of , we can find many versions of , and the installation packages of each version Hivecan be found on https://dlcdn.apache.org/hive/ , here we chooseHiveHive 3.1.2

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-JkZlmoU1-1684458841848) (Z:\Huang Zhicheng\Data\Typora\Linux\Ubuntu\Hive3.1.2installation.assets \image-20230518120253175.png)]

Here we can see that there are many tar.gzcompressed packages, but if we choose apache-hive-3.1.2-bin.tar.gz the compressed package, we can also see srcthe packages below, here we also explain the difference between the two, bin(binary binary) is used to place the compiled files The directory javais .classa file, and some languages ​​are used to place binary files; src(source source), the directory to place the source code.

The difference between compressed packages:

.tar.gzyes linuxzip

.zipyes windowszip

bin.tar.gzis the binary for the linuxsystemMacOsX

bin.zipwindowsis a binary for

src.tar.gzis linuxthe source code under

src.zipis windowsthe source code of

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-Nfbibc4n-1684458841849) (Z:\Huang Zhicheng\Data\Typora\Linux\Ubuntu\Hive3.1.2installation.assets \image-20230518120410208.png)]

wgetdownloadHive 3.1.2

Many installation methods have been introduced in previous articles, so I won’t introduce too many download methods here. Here we use the wgetcommand to download.

wget https://dlcdn.apache.org/hive/hive-3.1.2/apache-hive-3.1.2-bin.tar.gz -P ~/下载/

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-tPGzZqBf-1684458841850) (Z:\Huang Zhicheng\Data\Typora\Linux\Ubuntu\Hive3.1.2installation.assets \image-20230518123306994.png)]

Unpack Hive 3.1.2

After the download is complete, we can ~/下载find the downloaded installation package in the directory, and use lsthe command to check whether the installation package has been downloaded locally.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-5wudv5Ut-1684458841850) (Z:\Huang Zhicheng\Data\Typora\Linux\Ubuntu\Hive3.1.2installation.assets \image-20230518123559234.png)]

Next, we unzip the compressed package to /usr/local/the directory. After the decompression is complete, we enter /usr/local/, modify the directory name to make it shorter, and change the owner and group permissions to the current user. The following command hadoopis the user name of the current user, please Make adjustments according to the actual situation.

sudo tar -zxvf ~/下载/apache-hive-3.1.2-bin.tar.gz -C /usr/local # 将压缩包解压到/usr/local中
cd /usr/local/ # 进入 /usr/local/ 目录
sudo mv apache-hive-3.1.2-bin hive # 将文件夹名改为 hive
sudo chown -R hadoop:hadoop hive # 修改文件权限

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-UsUEoItc-1684458841851) (Z:\Huang Zhicheng\Data\Typora\Linux\Ubuntu\Hive3.1.2installation.assets \image-20230518124315001.png)]

Configure environment variables

In the previous installment MongoDBarticle, at the end we explained why we need to configure environment variables, mainly for the convenience of use, so we also configure them Hiveinto environment variables here. The specific steps are to use vimthe editor to open .bashrcthe file, and then add Hivethe executable file. specific path

vim ~/.bashrc

Write the following two variables, if Hadoopthe environment variable of is not written, you also need to write Hadoopthe environment variable of

export HIVE_HOME=/usr/local/hive
export PATH=$PATH:$HIVE_HOME/bin

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-zm85vQfL-1684458841851) (Z:\Huang Zhicheng\Data\Typora\Linux\Ubuntu\Hive3.1.2installation.assets \image-20230518125135519.png)]

Then reload the environment variables to make our previous configuration take effect

source ~/.bashrc

2. Configure hive-site.xml

hive-default.xml.templateContains Hivedefault values ​​for various configuration variables prepackaged in the distribution. In order to override the default value, we need to create hive-site.xmland set the value in this file; hive-site.xmlit is Hivethe configuration document in , we modify the default value in order to use the metadata MySQLsaved by the database instead of using the metadata that comes with data. is located in the directory of the installation root , and should also be created in the same directory. Note that template files are not used by Hive at all (as of Hive 0.9.0), and the canonical list of configuration options is managed only in java classes. The template file has the required format, so we can paste the configuration variables from the template file into and change their values ​​to the desired configuration.HiveHivederbyhive-default.xml.templateconfhive-site.xmlhive-default.xml.templateHiveConfhive-site.xmlhive-site.xml

The following are some specific configuration items that we need to configure this time. For more detailed configuration, please refer to the Hive language manual .

  • javax.jdo.option.ConnectionURL: Used to specify the JDBC connection string, and the specified database to be connected is the local MySQL Hive database.
  • javax.jdo.option.ConnectionDriverName: Specifies the MySQL driver used to connect to the JDBC metastore.
  • javax.jdo.option.ConnectionUserName: Specify the user name to connect to the metastore database as "hive".
  • javax.jdo.option.ConnectionPassword: Specify the password to connect to the metastore database as "hive".
cd /usr/local/hive/conf # 进入 hive 配置目录
vim hive-site.xml # 新建一个配置文件

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-mk41soK7-1684458841851) (Z:\Huang Zhicheng\Data\Typora\Linux\Ubuntu\Hive3.1.2installation.assets \image-20230519091319875.png)]

hive-site.xmlEnter the following configuration item settings in the configuration file

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
    <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>
    <description>JDBC connect string for a JDBC metastore</description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>com.mysql.jdbc.Driver</value>
    <description>Driver class name for a JDBC metastore</description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionUserName</name>
    <value>hive</value>
    <description>username to use against metastore database</description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>hive</value>
    <description>password to use against metastore database</description>
  </property>
</configuration>

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-jIa59Vi6-1684458841852) (Z:\Huang Zhicheng\Data\Typora\Linux\Ubuntu\Hive3.1.2installation.assets \image-20230519090921277.png)]

3. Write at the end

The download and installation are relatively simple, and the final configuration file part does not necessarily need to be used. MySQLAnalyze and modify according to your own specific situation. This article is a bit short, because there is indeed nothing special to explain about the installation, but the configuration file needs to be hive-site.xmladjusted differently according to different situations in the production environment. Here is just a simple example for your reference.

Guess you like

Origin blog.csdn.net/m0_68192925/article/details/130759450