Database Reference
In-Depth Information
Next, you move the release to /usr/local/ and create a symbolic link to the release to simplify the path and
environment:
[root@hc1nn Downloads]# mv apache-hive-0.13.1-bin /usr/local
[root@hc1nn Downloads]# cd /usr/local
[root@hc1nn local]# ln -s apache-hive-0.13.1-bin hive
[root@hc1nn local]# ls -ld *hive*
drwxrwxr-x. 8 hadoop hadoop 4096 Jun 18 17:03 apache-hive-0.13.1-bin
lrwxrwxrwx. 1 root root 22 Jun 18 17:05 hive -> apache-hive-0.13.1-bin
You update the user environment for the Linux account hadoop via its $HOME/.bashrc. For instance, I added the
following to the end of the file:
#######################################################
# Set up Hive variables
export HIVE_HOME=/usr/local/hive
export PATH=$PATH:$HIVE_HOME/bin
Once installed, Hive needs to use several HDFS-based directories, including a temporary directory and a
warehouse directory. You first check that these exist and are group writeable:
[hadoop@hc1nn bin]$ hadoop fs -mkdir /tmp
[hadoop@hc1nn bin]$ hadoop fs -chmod g+w /tmp
[hadoop@hc1nn bin]$ hadoop fs -mkdir /user/hive/warehouse
[hadoop@hc1nn bin]$ hadoop fs -chmod g+w /user/hive/warehouse
After making one last check for the proper release via the Linux type command, which shows that the hive
command is accessible, you can start Hive by using the hive command, which results in the Hive> prompt:
[hadoop@hc1nn bin]$ type hive
hive is hashed (/usr/local/hive/bin/hive)
[hadoop@hc1nn bin]$ hive
Logging initialized using configuration in jar:file:/usr/local/apache-hive-0.13.1-bin/lib/hive-
common-0.13.1.jar!/hive-log4j.properties
hive>
The hive command starts the Hive command line interface (CLI), readying Hive for some Hive QL.
Hive Word-Count Example
With the Hive CLI running, you're ready to do a word count on HDFS data using HiveQL. Notice that you must
terminate each command with a semicolon. To create a table to hold the data file lines, use the CREATE TABLE
command. The first parameter is the table's name—in this case, “rawdata.” Next, you pass the column names and their
type. Here, you specify a single column named“line,”of type STRING :
hive> CREATE TABLE rawdata (line STRING);
 
Search WWH ::




Custom Search