Hive integrates MySQL as meta data
By default, the hive metadata is saved in the embedded Derby database, allowing only one session connection and only for simple testing. In order to support multi-user multi-session, we need a separate meta-database, we use MySQL as a meta-database, the Hive has a good support for MySQL, configuring a separate metabase requires the following steps:
The first step: Install the MySQL server and MySQL client and start the MySQL service.
This step is omitted, see http://www.cnblogs.com/linjiqin/archive/2013/03/04/2942497.html for details
Step Two: Install Hive
This step is omitted, see http://www.cnblogs.com/linjiqin/archive/2013/03/04/2942402.html for details
Step three: Establish the appropriate MySQL account for hive and give sufficient privileges to execute the command as follows:
[Email protected]:~$ mysql-uroot-pmysql
Mysql> CREATE USER'Hive'Identified by'Hive';
Mysql> GRANT All privileges on * * to'Hive'@'%'With GRANT OPTION;
mysql> flush privileges; Restart MySQL service:sudoService MySQL Restart
Fourth Step: Create a hive-specific metabase , and remember to use the "hive" account you just created to log in.
mysql> CREATE DATABASE hive;
Fifth Step: Add the following configuration to the file "Hive-site.xml" in the Conf Directory of hive:
CD $HIVE _home/conf
CPHive-default.xml.template Hive-default.xml
CPHive-default.xml.template Hive-site.xml
From the front we know that our "hive-site.xml" is a copy of "Hive-default.xml.template", there are many configuration parameters, but not what we all need, we know, hive The system will load two configuration files, one default profile "Hive-default.xml" and the other is the user-defined file "Hive-site.xml". When the value of the configuration parameter in "Hive-site.xml" is inconsistent with the "hive-default.xml" file, the user-defined will prevail. So we're going to remove all the parameters we don't need, leaving only the content shown above.
Note: In fact, modify the configuration file here if it is very troublesome under Linux, altogether we have set up the FTP, why not, so the master.hadoop above the configuration file downloaded, as required to modify, Such a file in Windows to operate is very convenient, and after the upload, the original can be overwritten.
so you can hive-site.xml in the
<Configuration>Content empty
</configuration>
<?XML version= "1.0"?>
<?xml-stylesheet type= "text/xsl" href= "configuration.xsl "?>
<Configuration>
< Property>
<name>Hive.metastore.local</name>
<value>True</value>
</ Property>
< Property>
<name>Javax.jdo.option.ConnectionURL</name>
<value>Jdbc:mysql://192.168.1.78:3306/hive?characterencoding=utf-8</value>
</ Property>
< Property>
<name>Javax.jdo.option.ConnectionDriverName</name>
<value>Com.mysql.jdbc.Driver</value>
</ Property>
< Property>
<name>Javax.jdo.option.ConnectionUserName</name>
<value>Hive</value>
</ Property>
< Property>
<name>Javax.jdo.option.ConnectionPassword</name>
<value>Hive</value>
</ Property>
</Configuration>
Configure Hive to Etc/profile in $hive_home/bin configuration to path for ease of use
Copy the Mysql-connector-java-5.1.32.jar to the $hive_home/lib
Execute hive in Bash
Performing Hive encounters a bunch of problems
Terminal initialization failed; Falling back to unsupported
Java.lang.IncompatibleClassChangeError:FoundclassJLine. Terminal, butInterfacewas expected
At JLine. Terminalfactory.create (terminalfactory.java:101)
At JLine. Terminalfactory.get (terminalfactory.java:158)
At Jline.console.consolereader.<init> (consolereader.java:229)
At Jline.console.consolereader.<init> (consolereader.java:221)
At Jline.console.consolereader.<init> (consolereader.java:209)
At Org.apache.hadoop.hive.cli.CliDriver.getConsoleReader (clidriver.java:773)
At Org.apache.hadoop.hive.cli.CliDriver.executeDriver (clidriver.java:715)
At Org.apache.hadoop.hive.cli.CliDriver.run (clidriver.java:675)
At Org.apache.hadoop.hive.cli.CliDriver.main (clidriver.java:615)
At Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
At Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:57)
At Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:43)
At Java.lang.reflect.Method.invoke (method.java:606)
At Org.apache.hadoop.util.RunJar.run (runjar.java:221)
At Org.apache.hadoop.util.RunJar.main (runjar.java:136)
Exception in thread "main" Java.lang.IncompatibleClassChangeError:FoundclassJLine. Terminal, butInterfacewas expected
At Jline.console.consolereader.<init> (consolereader.java:230)
At Jline.console.consolereader.<init> (consolereader.java:221)
At Jline.console.consolereader.<init> (consolereader.java:209)
At Org.apache.hadoop.hive.cli.CliDriver.getConsoleReader (clidriver.java:773)
At Org.apache.hadoop.hive.cli.CliDriver.executeDriver (clidriver.java:715)
At Org.apache.hadoop.hive.cli.CliDriver.run (clidriver.java:675)
At Org.apache.hadoop.hive.cli.CliDriver.main (clidriver.java:615)
At Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
At Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:57)
At Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:43)
At Java.lang.reflect.Method.invoke (method.java:606)
At Org.apache.hadoop.util.RunJar.run (runjar.java:221)
At Org.apache.hadoop.util.RunJar.main (runjar.java:136)
Workaround: Add in/etc/profile
Export hadoop_user_classpath_first=true
Failed:error in Metadata:javax.jdo.JDOFatalDataStoreException:Access denied forUser ' hive ' @ ' Eidlink ' (using Password:yes)
Nestedthrowables:
Java.sql.SQLException:Access denied forUser ' hive ' @ ' Eidlink ' (using Password:yes)
Failed:execution Error,returnCode 1 from Org.apache.hadoop.hive.ql.exec.DDLTask
Solution:
Perform a view of hostname as Eidlink in bash
hostname
Log in to MySQL
Mysql-uhive-phive
Mysql> Grant all on hive.* to [email protected]'Eidlink'Identified by'Hive';
mysql>exit;
Service MySQL Restart
Execute hive to successfully hive the log file directory that is started by default for/tmp/login user/hive.log
The following table will be automatically created in the 192.168.1.78:3306/hive library
Hive> Show tables;
Ok
Time Taken:1.279Seconds
1) Set up a data table on hive
Hive> CREATE TABLE xp (ID int,name string) ROW FORMAT delimited fields TERMINATED by ' \ t ';
2) View metadata information from the MySQL database
SQL statement used:
Use hive; Using the Hive Database library
show tables; Displaying data tables in the Hive database
select * from TBLs; View the metadata information for hive
To this hive integrated MySQL as metadata has been completed.
success!
Hive and MySQL integrated installation