This article describes the Brew install hive and modifies the default Metastore storage scheme, changing the Derby database to the MySQL method and the solution to the problems that may be encountered.
1. Installing hive via Homebrew
2. Add environment variables for Hadoop and hive
123456 |
sudo vim ~/.bash_profile export HADOOP_HOME= /usr/local/Cellar/hadoop/hadoop .version.no export HIVE_HOME= /usr/local/Cellar/hive/hive .version.no /libexec source ~/.bash_profile |
3. Download MySQL connector
123 |
curl -L ‘http://www.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.22.tar.gz/from/http://mysql.he.net/‘ | tar xz sudo cp mysql-connector-java-5.1.15 /mysql-connector-java-5 .1.22-bin.jar /usr/local/Cellar/hive/hive .version.no /libexec/lib/ |
4. Create MySQL metastore
1234 |
mysql> CREATE DATABASE metastore; mysql> USE metastore; mysql> CREATE USER ‘hiveuser‘ @ ‘localhost‘ IDENTIFIED BY ‘password‘ ; mysql> GRANT SELECT , INSERT , UPDATE , DELETE , ALTER , CREATE ON metastore.* TO ‘hiveuser‘ @ ‘localhost‘ ; |
5. Configure configuration files for hive
123456789101112131415161718192021222324 |
cd /usr/local/Cellar/hive/hive
.version.no
/libexec/conf
cp hive-default.xml.template hive-site.xml
#添加或者编辑如下内容
<property>
<name>javax.jdo.option.ConnectionURL<
/name
>
<value>jdbc:mysql:
//localhost/metastore
<
/value
>
<
/property
>
<property>
<name>javax.jdo.option.ConnectionDriverName<
/name
>
<value>com.mysql.jdbc.Driver<
/value
>
<
/property
>
<property>
<name>javax.jdo.option.ConnectionUserName<
/name
>
<value>hiveuser<
/value
>
<
/property
>
<property>
<name>javax.jdo.option.ConnectionPassword<
/name
>
<value>password<
/value
>
<
/property
>
<property>
<name>datanucleus.fixedDatastore<
/name
>
<value>
false
<
/value
>
<
/property
>
|
6. Test whether Hive is working
123 |
$ hive; hive > show tables; hive> create table temp_table temp_col string; |
7. Revoke Few permissions on the MySQL metastore
12 |
$ mysql mysql> REVOKE ALTER,CREATE ON metastore.* FROM ‘hiveuser‘ @ ‘localhost‘ ; |
9. Further troubleshooting:
(a) If you get a bin log error saying statement format was not support. Login to your MySQL console as root
$ mysql-urootmysql > SET GLOBAL binlog_format = ' ROW ';
(b) You could also try reading the logs as follows. Logs can emitted to the bash prompt and running hive by setting Hive.root.logger to Info,console.
$ hive-hiveconf Hive.root.logger=info,console
(c) You could also read the RAW hive logs which are usually located at/tmp/user_name/hive.log
(d) If you still has any errors, feel free to comment.
problem solutions that you may encounter after configuration is complete: One, Reference error solution: Use sequel Pro, modify the permissions of the hive user, and add Reference global permissions. Second, "caused by:java.net.URISyntaxException:Relative path in absolute URI: ${system:java.io.tmpdir%7d/$%" encountered when starting hive 7bsystem:user.name%7d "Solution: Modify the following key value in the Hive-site.xml configuration: <name>hive.exec.scratchdir</name>< Value>/tmp/hive-${user.name}</value> <name>hive.exec.local.scratchdir</name> <value>/ Tmp/${user.name}</value> <name>hive.downloaded.resources.dir</name><value>/tmp/${ User.name}_resources</value> <name>hive.scratch.dir.permission</name> <value>733</ value> Restart Hive Metastore and Hiveserver2
Mac OSX on Brew install hive