Install the data warehouse tool in two Hive modes to convert the raw structured data under Hadoop into tables in Hive. HiveQL, a language almost identical to SQL, supports updates, indexes, and transactions. It can be seen as a er from SQL to Map-Reduce. Provides interfaces such as shell, JDBCODBC, thrift, and Web. I. Embedded Mode
Install the data warehouse tool in two Hive modes to convert the raw structured data under Hadoop into tables in Hive. HiveQL, a language almost identical to SQL, supports updates, indexes, and transactions. It can be seen as a er from SQL to Map-Reduce. Provides interfaces such as shell, JDBC/ODBC, thrift, and Web. I. Embedded Mode
Install in two Hive Modes
The data warehouse tool can convert raw structured data under Hadoop into tables in Hive.
HiveQL, a language almost identical to SQL, supports updates, indexes, and transactions.
It can be seen as a er from SQL to Map-Reduce.
Provides interfaces such as shell, JDBC/ODBC, thrift, and Web.
I. Embedded mode installation
In this way, the installed metadata is kept in the embedded Derby database and only one session connection is allowed. This is only applicable to simple tests.
1. Decompress Hive
[Coder @ h1 ~] $ Tar-zxvf hive-0.10.0.tar.gz
2. Configure the environment variable/etc/profile
Add the Hive installation directory and configure the Hive bin directory to PATH
HIVE_HOME =/home/coder/hive-0.10.0.
PATH = $ HADOOP_INSTALL/bin: $ PIG_INSTALL/bin: $ JAVA_HOME/bin: $ HIVE_HOME/bin: $ PATH
Run the source/etc/profile command to make the configuration take effect.
3. Create a directory for Hive
Create/tmp and/user/hive/warehouse directories on HDFS, and grant the group user write permission. This is the default Hive data file storage directory that can be configured in the hive-site.xml file.
[Coder @ h1 hadoop-0.20.2] $ bin/hadoop fs-mkdir/tmp
[Coder @ h1 hadoop-0.20.2] $ bin/hadoop fs-mkdir/user/hive/warehouse
[Coder @ h1 hadoop-0.20.2] $ bin/hadoop fs-chmod g + w/tmp
[Coder @ h1 hadoop-0.20.2] $ bin/hadoop fs-chmod g + w/user/hive/warehouse
4. input the hive command and the following content appears, indicating that the installation is successful.
[Coder @ h1 hadoop-0.20.2] $ hive
Logging initialized using configuration in jar: file:/home/coder/hive-0.10.0/lib/hive-common-0.10.0.jar! Hive-log4j.properties
Hive history file =/tmp/coder/hive_job_log_coder_201305072118_1_2944282.txt
Hive>
Hive> show tables;
OK
Time taken: 24.479 seconds
Hive> exit;
Ii. Independent Installation
Supports multi-user sessions and requires an independent metadatabase. MySQL is commonly used as the metadatabase.
1. Start MySQL
[Root @ h1 ~] # Service mysqld start
Starting mysqld: [OK]
[Root @ h1 ~] #
2. Create a MySQL account for Hive
[Root @ h1 ~] # Mysql
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 2
Server version: 5.1.66 Source distribution
Copyright (c) 2000,201 2, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.
Mysql> create user 'hive' identified by '201312 ';
Query OK, 0 rows affected (0.00 sec)
Mysql> grant all privileges on *. * TO 'hive' @ 'localhost' identified by '000000' with grant option;
Query OK, 0 rows affected (0.00 sec)
Mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Mysql> exit
Bye
[Root @ h1 ~] #
Then log on to MySQL using the hive account from the client.
3. Create a Hive dedicated metadatabase
Mysql> create database hive;
4. Configure Hive
In the conf directory of the Hive installation directory, copy the hive-default.xml.template and name it: hive-site.xml
Modify the following content to configure mysql Data Connection, driver, user name, and password.
Javax. jdo. option. ConnectionURL
Jdbc: mysql: // localhost: 3306/hive? CreateDatabaseIfNotExist = true
Javax. jdo. option. ConnectionDriverName
Com. mysql. jdbc. Driver
Javax. jdo. option. ConnectionUserName
Hive
Javax. jdo. option. ConnectionPassword
123456
5. Copy the mysql driver package to the lib directory in the Hive installation path.
6. If you enter Hive, if no error is reported, the independent mode is successfully installed.
[Coder @ h1 ~] $ Hive
Logging initialized using configuration in jar: file:/home/coder/hive-0.10.0/lib/hive-common-0.10.0.jar! Hive-log4j.properties
Hive history file =/tmp/coder/hive_job_log_coder_201305072212_717503278.txt
Hive> show tables;
OK
Time taken: 24.783 seconds
Hive> exit;