Installation and configuration of hive

Source: Internet
Author: User
Tags email string xsl hdfs dfs hadoop fs

1, because I use MySQL as a hive metabase, so install MySQL first.

Reference: http://www.cnblogs.com/hunttown/p/5452205.html

Login command: Mysql-h host address-u user name-P user Password

Mysql–u root    # initial login without password

Change Password

Format: Mysqladmin-u username-P Old password password new password

Mysql>mysqladmin-uroot–password 123456

Note: Because Root does not have a password at the beginning, the-p old password can be omitted.

Create a user hadoopuser for hive

Create user command: ' username ' @ ' host ' identified by ' password ';

mysql> CREATE USER ' [email protected] ' identified by ' password ';

Authorization command: Grant privileges on databasename.tablename to ' username ' @ ' host '

Mysql> Grant all privileges on *. * to ' [e-mail protected] ' with GRANT OPTION;

Creating users and authorizations can be done together:

Mysql> GRANT All privileges on * * to [e-mail protected] identified by ' 123456 ' with GRANT OPTION;

Create DATABASE hive for the Hive data store

Mysql> CREATE DATABASE Hive

2. Extract Hive to/home/hadoopuser/

3. Switch to the root user and add the environment variables:

Export hive_home=/home/hadoopuser/hiveexport PATH=$PATH:$HIVE _home/bin

4, use root user, give Hive/bin add permission

chmod 777/hive/bin/*

5. Configuration Files

Switch to/hive/conf

CP hive-default. xml.template  hive-SITE.XMLCP Hive-log4j.properties.template Hive-log4j.properties

(1) Configuration Hive-site.xml

<?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://192.168.254.156: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>Hadoop</value>    <Description>Username to use against Metastore database</Description>  </ Property>  < Property>    <name>Javax.jdo.option.ConnectionPassword</name>    <value>123456</value>    <Description>Password to use against Metastore database</Description>  </ Property>  < Property>    <name>Hive.metastore.warehouse.dir</name>    <value>/user/hive/warehouse</value>    <Description>Location of the default database for the warehouse</Description>  </ Property></Configuration>

Note 1: The warehouse directory if you do not want to create

HDFs dfs–mkdir/user//user/hive/warehouse

Note 2:mysql Drive jar package to upload to Hive/lib

(2) Configuration hive-log4j.properties

# Log4j.appender.eventcounter=org.apache.hadoop.metrics.jvm.eventcounterlog4j.appender.eventcounter= Org.apache.hadoop.log.metrics.EventCounter

6. Create/tmp and/user/hive/warehouse in HDFs and set permissions

Hadoop fs-mkdir/-mkdir/user/hive/-chmod g+w/-chmod g+w/user/hive/warehouse

Note: The Hadoop command was replaced with the HDFs command, and the command above

HDFs fs-mkdir/-mkdir/user/hive/-chmod g+w/-chmod g+w/user/hive/warehouse

7. Manually upload the MySQL JDBC Library to the Hive/lib directory.

http://mirror.bit.edu.cn/mysql/Downloads/Connector-J/

Mysql-connector-java-5.1.22-bin.jar

8. Start Hive

Hive--service Metastore &        # start metastore service hive--service Hiveserver2 &      # Start hiveserver service hive Shell                        # start hive client

Hive Use

1. Create a database

CREATE DATABASE myhive;

2. Create a table

CREATE TABLE doc_hive (id int, username string, sex int, age int, email string, createtime string) ROW FORMAT delimited FI ELDs TERMINATED by ' \ t ';

3. Import data

LOAD DATA LOCAL inpath '/home/hadoopuser/doc/t-1.txt ' OVERWRITE into TABLE doc_hive;

Verification: SELECT * from Myhive.doc_hive;

The specific use of hive will be reflected in the following blog post.


--Solemn statement: This article is only for the author's personal notes, please do not reprint! ——

Installation and configuration of hive

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.