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.2
installing, 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 Apache
the official website of , we can find many versions of , and the installation packages of each version Hive
can be found on https://dlcdn.apache.org/hive/ , here we chooseHive
Hive 3.1.2
Here we can see that there are many tar.gz
compressed packages, but if we choose apache-hive-3.1.2-bin.tar.gz
the compressed package, we can also see src
the packages below, here we also explain the difference between the two, bin
(binary binary) is used to place the compiled files The directory java
is .class
a 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.gz
yeslinux
zip
.zip
yeswindows
zip
bin.tar.gz
is the binary for thelinux
systemMacOsX
bin.zip
windows
is a binary for
src.tar.gz
islinux
the source code under
src.zip
iswindows
the source code of
wget
downloadHive 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 wget
command to download.
wget https://dlcdn.apache.org/hive/hive-3.1.2/apache-hive-3.1.2-bin.tar.gz -P ~/下载/
Unpack Hive 3.1.2
After the download is complete, we can ~/下载
find the downloaded installation package in the directory, and use ls
the command to check whether the installation package has been downloaded locally.
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 hadoop
is 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 # 修改文件权限
Configure environment variables
In the previous installment MongoDB
article, at the end we explained why we need to configure environment variables, mainly for the convenience of use, so we also configure them Hive
into environment variables here. The specific steps are to use vim
the editor to open .bashrc
the file, and then add Hive
the executable file. specific path
vim ~/.bashrc
Write the following two variables, if Hadoop
the environment variable of is not written, you also need to write Hadoop
the environment variable of
export HIVE_HOME=/usr/local/hive
export PATH=$PATH:$HIVE_HOME/bin
Then reload the environment variables to make our previous configuration take effect
source ~/.bashrc
2. Configure hive-site.xml
hive-default.xml.template
Contains Hive
default values for various configuration variables prepackaged in the distribution. In order to override the default value, we need to create hive-site.xml
and set the value in this file; hive-site.xml
it is Hive
the configuration document in , we modify the default value in order to use the metadata MySQL
saved 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.Hive
Hive
derby
hive-default.xml.template
conf
hive-site.xml
hive-default.xml.template
HiveConf
hive-site.xml
hive-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 # 新建一个配置文件
hive-site.xml
Enter 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>
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. MySQL
Analyze 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.xml
adjusted differently according to different situations in the production environment. Here is just a simple example for your reference.