Hive download and install, and configure the mysql database as metadata

hive Download:

http://www.apache.org/dyn/closer.cgi/hive/

Installation Deployment:

Extracting hive source:

sudo tar -zxvf ./apache-hive-1.2.1-bin.tar.gz -C / usr / local # extract to / usr / local in 
CD / usr / local / 
the sudo Music Videos Apache -hive-1.2.1- bin hive # folder name to Hive 
sudo chown -R dblab: dblab hive # modify file permissions

Configuration environment variable:

export HIVE_HOME=/usr/local/hive
export PATH=$PATH:$HIVE_HOME/bin

Save and exit, running source ~/.bashrcconfiguration to take effect immediately.

Modify /usr/local/hive/confhive-site.xml under

The hive-default.xml.template rename hive-default.xml; create a new file touch hive-site.xml, and hive-site.xml paste the following configuration:

<?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://localhost: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>
</configuration>

View hive is successfully installed:

First, under the hive before starting to run Hadoop, Hadoop into the sbin directory under the installation directory, enter the command to start

./start-all.sh

Enter the hive installation directory, enter the command

bin/hive

Basic operation of the hive:

Hive> Show Databases; // check the database 
Hive> use default ;        // open the default database 
Hive> Show the Tables;        // view the default database tables 
Hive> the Create the Table Student (the above mentioned id int , String name);   // create a table 
hive> Show tables;       // Check database contains several tables 
hive> desc student;      // view of the structure of the student table 
hive> iNSERT iNTO student values (1000, "SS"); // insert data into the table one 
hive > the SELECT * from Student;   // data query tables 
hive> quit;    // exit the hive

Mysql installation configuration

Use the following command to install

APT- sudo GET Update # source software update 
sudo APT -get install mysql-Server install mysql #

Mysql server startup and shutdown

service mysql start
service mysql stop

Confirm that started successfully:

sudo netstat -tap | grep mysql

mysql nodes in the LISTEN state indicates a successful start

Enter the mysql shell interface:

mysql -u root -p

Download mysql jdbc package:

MySQL-Connector--zxvf the tar-5.1.40 Java .tar.gz decompression # 
CP MySQL -connector-Java-5.1.40 / MySQL 5.1.40-Connector-Java--bin.jar / usr / local / Hive / lib # the mysql-connector-java-5.1.40- bin.jar copied to the / usr / local / hive / lib directory

Start and log mysql shell:

service mysql start # start mysql service 
 mysql -u root -p # login shell interface

New hive database:

mysql> create database hive; # the hive in the database and hive-site.xml localhost: 3306 / hive to hive corresponds to the metadata stored hive

Mysql configuration allows access hive:

mysql> grant all on * * to hive @ localhost identified by 'hive';. # all permissions for all tables in all databases assigned to the user hive, the hive is configured behind hive- connection password site.xml configured 
MySQL > flush privileges; # refresh system permissions table mysql

Start hive, before starting the first open Hadoop

Start- all.sh # start hadoop 
hive start hive #

 

Guess you like

Origin www.cnblogs.com/sakura--/p/11461259.html