Environmental requirements:
Mysql
Hadoop
The hive version is: Apache-hive-1.2.1-bin.tar
1. Setting Up Hive Users
Enter the MySQL command line to create a hive user and give all permissions:
Mysql-uroot-proot
Mysql>create user ' hive ' identified by ' hive ';
Mysql>grant all on * * to ' hive ' @ '% ' with GRANT option;
Mysql>flush privileges;
2. Create a hive Database
To create a hive database using hive User login:
Mysql-uhive-phive
Mysql>create database hive;
Mysql>show databases;
3. Installing hive
Download the hive installation file
can go to Apache Fund Hive website http://hive.apache.org/downloads.html, select Image: http://mirrors.cnnic.cn/apache/hive/Download a stable version,
Put the MySQL driver in the Lib directory of Hive
Put the downloaded hive installation package and the MySQL driver package, using the
Cd/home/hadoop/downloads
CP Mysql-connector-java-5.1.34-bin.jar/usr/local/hive-0.12.0/lib
4. Configuring/etc/profile Environment variables
Open the/etc/profile file using the following command:
sudo vi/etc/profile
#set Hive Path
Export Hive_home=/usr/local/hiveexport path= $PATH: $HIVE _home/binexport classpath= $CLASSPATH: $HIVE _home/bin
To make the configuration file effective:
Source/etc/profile
5. Setting the hive-env.sh configuration file
Go to hive-0.12.0/conf directory and copy Hive-env.sh.templaete to hive-env.sh:
Cd/usr/local/hive-0.12.0/conf
CP Hive-env.sh.template hive-env.sh
Ls
VI hive-env.sh
Set Hadoop_home and Hive_conf_dir two values respectively:
650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/7F/58/wKiom1caOZrS03NfAAEMH90xjB4785.jpg "title=" 1.jpg " alt= "Wkiom1caozrs03nfaaemh90xjb4785.jpg"/>
6. Setting the Hive-site.xml configuration file
Copy Hive-default.xml.templaete to Hive-site.xml
CP Hive-default.xml.template Hive-site.xml
sudo vi hive-site.xml
(1) Adding a configuration item
Default Metastore local, add configuration to non-local can ignore this step
<property> <name>hive.metastore.local</name> <value>false</value></property>
(2) Modifying configuration items
Hive defaults to the Derby database and needs to be adjusted to the MySQL database
<property> <name>hive.metastore.uris</name> <value>thrift:// hadoop1:9083</value> <description>thrift uri for the remote Metastore. ...</description></property><property> <name> javax.jdo.option.connectionurl</name> <value>jdbc:mysql://hadoop1: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>
(3) Correction error item
In configuration file 2000 line left and right configuration item Hive.server2.thrift.sasl.qop originally for <value>auth</auth>, modify as follows:
<property> <name>hive.server2.thrift.sasl.qop</name> <value>auth</value> <des .....</property>
and modify the Hive.metastore.schema.verification configuration item value to False
<property> <name>hive.metastore.schema.verification</name> <value>false</value> <desc....></property>
7. Verifying the deployment
Start Metastore and Hiveserver
Before using hive, you need to start the Metastore and Hiveserver services, which are enabled by the following command:
Copy the MySQL JDBC driver package to the Lib directory of hive.
Version of the JDBC driver package: Mysql-connector-java-5.1.18-bin.jar
The following can also be ignored
Hive--service Metastore &
Hive--service Hiveserver &
Start with the JPS command can see two run in the background
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M00/7F/56/wKioL1caOw_RahCCAAB-PSoPxk4535.jpg "title=" 2.jpg " alt= "Wkiol1caow_rahccaab-psopxk4535.jpg"/>
8. Working in Hive
Log in to hive, create a table in hive and view the table with the following command:
Hive
Hive>create table Test (a string, b int);
Hive>show tables;
Hive>desc test;
Does not start normally, handled as follows:
http://blog.csdn.net/olfisher/article/details/48730229
Terminal initialization failed; Falling back to unsupported because of the existence of the old version jline:/hadoop-2.5.2/share/hadoop/yarn/lib:-rw-r--r--1 root root 87325 Mar in the Hadoop directory The 18:10 Jline-0.9.94.jar solution is to copy the new version of hive under the JLine jar package to Hadoop: Cp/hive/apache-hive-1.1.0-bin/lib/jline-2.12.jar. /hadoop-2.5.2/share/hadoop/yarn/lib:-rw-r--r--1 root root 87325 Mar 18:10 jline-0.9.94.jar.bak-rw-r--r--1 root root 213854 Mar 22:22 Jline-2.12.jar
This article is from the "If you bloom, the breeze came in" blog, please be sure to keep this source http://iqdutao.blog.51cto.com/2597934/1766918
Seventh section of Hadoop Learning: Hive Installation Configuration