preparatory work1. Built Hadoop Distributed System 2.apache-hive-1.2.1-bin.tar.gz and Mysql-connerctor-java-5.1.43-bin.jar
Create the Hive database on the MySQL database to save the hive meta data
#mysql-u root-p
> Input password
mysql>create database hive;
installation
Decompression apache-hive-1.2.1-bin.tar.gz
#tar-zxvf apache-hive-1.2.1-bin.tar.gz-c/usr/local/hadoop/
#cd/usr/local/hadoop
#mv Apache-hive-1.2.1-bin hive-1.2.1
Note:/usr/local/hadoop is my hive installation path configuration
1. Because hive needs to access the metadata on the MySQL database, you need to import Mysql-connerctor-java-5.1.43-bin.jar to the Hive-1.2.1/lib directory.
2. Edit configuration file
#cd/usr/local/hadoop/hive-1.2.1/conf
#vim hive-site.xml
Add the following record
<?xml version= "1.0" encoding= "UTF-8"?> <?xml-stylesheet type= "
text/xsl" href= "configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://123.207.101.174:3306/hive</value>
</property>
<property >
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.driver </value>
</property>
<property>
<name> javax.jdo.option.connectionusername</name>
<value> user name </value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value> Password </value>
</property>
</configuration>
3. Import hive into environment variables
#vim/etc/profile
Add the following record
hive_home=/usr/local/hadoop/hive-1.2.1
Export path= $HIVE _home/bin: $PATH
Make a configuration file effective
#source/etc/profile
Configure the Fetch task feature for a simple query
Simple query: No sort, no function query is called a simple query.
Fetch task function: Use this function to execute simple query, query statement will not be converted to MapReduce task, but query data directly in HDFs file, improve the efficiency of simple query.
How to configure the Fetch task feature:
-Hive>set Hive.fetch.task.conversion=more;
Or
-#hive –hiveconf Hive.fetch.task.conversion=more
Or
-Modify the configuration file Hive-site.xml add the following record:
<property>
<name>hive.fetch.task.conversion</name>
<value>more</value>
</property>
Validate
Enter hive into command line mode under Linux
# hive
Before, we created a MySQL database to save the hive metadata of the hive database, at this time, when seen as shown above, we can go to check whether the hive database of the metadata table is successful, if the success of the creation will be as follows:
As you can see, some metadata tables that hold metadata are initialized in the hive database that you created earlier. Over