1. Hive MySQL metastore installation Preparation
Unzip the hive-0.12.0.tar.gz to the/zzy/.
# TAR-ZXVF Hive-0.12.0.tar.gz-c/zzy (-c Specifies the path after unpacking)
Modify the/etc/profile file to add hive to the environment variable
# Vim/etc/profile
Export java_home=/usr/java/jdk1.7.0_79
Export hadoop_home=/itcast/hadoop-2.4.1
Export hive_home=/itcast/hive-0.12.0
Export path= $PATH: $JAVA _home/bin: $HADOOP _home/bin: $HADOOP _home/sbin: $HIVE _home/bin
Source a bit, let the configuration take effect
# Source/etc/profile
Installation is complete!
Tip: Metastore is the central place to store hive metadata. Metastore uses the built-in Derby database as the storage engine by default. Derby Engine Disadvantage: Only one session can be opened at a time, using MySQL as an external storage engine, multi-user access at the same time.
2. Install MySQL Database
(Note: No network, you can configure the local Yum source, please refer to this blog Hadoop configuration local Yum source)
# yum-y Install Mysql-server
Start the MySQL database
# service Mysqld Start
Initialize the MySQL database (the default root password is empty, follow the prompts to step through)
#/usr/bin/mysql_secure_installation
Add MySQL to boot
# Chkconfig Mysqld on
Allow remote logins to MySQL
First log in the MySQL data, and then execute the following two lines of statements: (Login mysql:mysql–u username –p password)
A. GRANT all privileges on * * to ' root ' @ '% ' identified by Zzy with GRANT OPTION;
B.flush privileges; (MySQL new user or change password after the need to flush privileges refresh the MySQL system permission related table, otherwise there will be access denied,
Another way is to restart the MySQL server for the new settings to take effect. )
Modify the $hive_home/bin hive-config.sh to add the following three lines
Export java_home=/usr/java/jdk1.7.0_79
Export hive_home=/itcast/hive-0.12.0
Export hadoop_home=/itcast/hadoop-2.4.1
3. Configure Metastore for MySQL
A. Uploading the database driver Mysql-connector-java-5.1.28.jar to/zzy/hive-0.12.0/lib
B. Modify $hive_home/conf/hive-site.xml
# vim/zzy/hive-0.12.0/conf/hive-site.xml (cp hive-default.xml.template Hive-site.xml)
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>lg</value>
</property>
</configuration>
Configuration Complete!
4. Test whether the configuration is correct
Start hive (input #hive--service CLI boot)
# hive
Create a database
hive> CREATE DATABASE test_db;
Show all databases
show databases;
Working with Database test_db
hive> use test_db;
Create student Tables
Hive> CREATE TABLE Student (ID int,name string);
See if the following folder is stored in HDFs
Http://19.168.0.140:50070/explorer.html#/user/hive/warehouse/test_db.db/student
---------------------------------------Bug----------------------------------------
1. Service Mysqld Start
Another MySQL daemon already running with the same UNIX socketservice mysqld stop
Mv/var/lib/mysql/mysql.sock/var/lib/mysql/mysql.sock.bak
Service mysqld Start
2. hive> CREATE DATABASE test_db;
Failed:execution Error, return code 1 from Org.apache.hadoop.hive.ql.exec.DDLTask. Java.lang.RuntimeException:Unable to instantiate Org.apache.hadoop.hive.metastore.HiveMetaStoreClient
The hive installation of Hadoop