Installation and deployment of Hive-2.3.2 on Linux __linux

Source: Internet
Author: User
Tags xsl hadoop fs

Reference website: https://cwiki.apache.org/confluence/display/Hive/GettingStarted 1. Server Requirements:

Java1.7 or above, recommended java1.8 hadoop2.x 2. Get installation package

Website address: https://mirrors.tuna.tsinghua.edu.cn/apache/hive/can choose the appropriate version to download

Download Address: https://mirrors.tuna.tsinghua.edu.cn/apache/hive/hive-2.3.2/apache-hive-2.3.2-bin.tar.gz

You can download directly to a Linux server using the wget command.

wget https://mirrors.tuna.tsinghua.edu.cn/apache/hive/hive-2.3.2/apache-hive-2.3.2-bin.tar.gz
3. Decompression installation package is installed
Tar xvf apache-hive-2.3.2-bin.tar.gz
4. Start HDFs, create folders for hive and authorize them for data storage
$HADOOP _home/sbin/start-dfs.sh
$HADOOP _home/bin/hadoop fs-mkdir tmp
$HADOOP _home/bin/hadoop fs-mkdir/user /hive/warehouse
$HADOOP _home/bin/hadoop fs-chmod g+w/tmp
$HADOOP _home/bin/hadoop fs-chmod g+w/user/hive/ Warehouse

The data stored through hive actually exists on the HDFs. 5. Initialize

Hive metadata (such as table definitions) is stored in the Derby database or MySQL database. 5.1 using the Derby database

$HIVE _home/bin/schematool-dbtype "Derby"-initschema

Benefits: no additional installation required

Disadvantage: Derby only allows single connection, cannot two clients connect to hive;

Initialization in the current path will generate a Metastore file, when the switch path to start hive, will not find the file, error.

Using the Derby database is not recommended. 5.2 using MySQL database

(1) Configure Hive-site.xml files

Vim $HIVE _home/conf/hive-site.xml
<?xml version= "1.0" encoding= "UTF-8" standalone= "no"?> <?xml-stylesheet "type=" text/xsl "href=" Configuration.xsl "?> <configuration> <property> <name>hive.metastore.warehouse.dir</n Ame> <value>/user/hive/warehouse</value><!--The actual data is stored on the HDFs path--> </property> &L T;property> <name>hive.metastore.local</name> <value>true</value><!- -Metadata stored in local--> </property> <property> <name>javax.jdo.option.connectionurl</n Ame> <value>jdbc:mysql://127.0.0.1:3306/hive?createdatabaseifnotexist=true&usessl=false</value 
            > </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value><!--JDBC Driver--> </property> <property&
            Gt <name>javax.jdo.option.connectionusername</name> <value>root</value><!--mysql account--> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>roo tpassword</value><!--mysql password--> </property> </configuration>

(2) need to copy MySQL JDBC driver package to $hive_home/lib/

Website address: https://dev.mysql.com/downloads/connector/j/Select JDBC

Download Address: https://cdn.mysql.com//Downloads/Connector-J/mysql-connector-java-5.1.46.tar.gz

You can use the wget download and unzip it using the tar xvf command, copying the Mysql-connector-java-5.1.46.jar

(3) Initialization of MySQL database

$HIVE _home/bin/schematool-dbtype Mysql-initschema
6. Run Hive
$HIVE _home/bin/hive

7. Simple table operation, data operation

show databases;

Show tables;

CREATE TABLE test (id int, name string) row format delimited fields terminated by ';

Load data local inpath '/root/lbl/file/hivetest ' overwrite into table test;

SELECT * from Test;

The third line is to create the table where the table data exists in a HDFs file, one row of the table's data in the file, and the column and column at the ' interval '.

The four line reads the local file into the table, and the contents of the file are as follows:

1 a
2 b
3 C


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.