Hive-0.14.0版本,本地独立模式,MySQL作为元数据库
系统 |
Red hat linux 6.4 |
Hadoop版本 |
2.5.2 |
Hive版本 |
0.14.0 |
Mysql数据库版本 |
5.6.15 |
1.安装JDK,这个步骤在部署hadoop分布式集群时候已经操作过了,可以略过。
2.安装Mysql 数据库
数据库的安装顺序
(1)Mysql-server
(2)mysql-client
(3)启动mysql服务
(4)用root用户登录,以授权方式创建hive元数据库,和hive用户
grant all on hive.* to ‘hive‘@‘%‘ identified by ‘hive‘; 这个hive数据库,及其 用户和密码,是后面配置hive要用到的 !!!
备注:Red Hat linux 下的mysql 安装 可参考 http://blog.itpub.net/28929558/viewspace-1192693/
3.部署Hive
(1)到官网下载hive http://mirror.bit.edu.cn/apache/hive/
(2)解压到自己需要的安装路径
(3)配置hive环境变量
点击(此处)折叠或打开
- #set hive_env
- export HIVE_HOME=/home/zhang/hive
- export PATH=$PATH:/home/zhang/hive/bin
- export CLASS_PATH=$CLASS_PATH:/home/zhang/hive/lib
(4)修改$HIVE_HOME/conf 下面配置文件(将需要配置的两个模板,拷贝重命名)
点击(此处)折叠或打开
- cp hive-env.sh.template hive-env.sh
- cp hive-default.xml.template hive-site.xml
点击(此处)折叠或打开
- # Set HADOOP_HOME to point to a specific hadoop install directory
- HADOOP_HOME=/home/zhang/hadoop-2.5.2
修改的内容如下所示:
点击(此处)折叠或打开
-
<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>
-
-
<property>
-
<name>hive.metastore.local</name>
-
<value>true</value>
-
<description></description>
- </property>
在hive下创建临时IO的tmp文件夹。然后将路径配置到下列参数中
点击(此处)折叠或打开
-
<property>
-
<name>hive.querylog.location</name>
-
<value>/home/zhang/hive/iotmp</value>
-
<description>Location of Hive run time structured log file</description>
-
</property>
-
-
<property>
-
<name>hive.exec.local.scratchdir</name>
-
<value>/home/zhang/hive/iotmp</value>
-
<description>Local scratch space for Hive jobs</description>
-
</property>
-
-
<property>
-
<name>hive.downloaded.resources.dir</name>
-
<value>/home/zhang/hive/iotmp</value>
-
<description>Temporary local directory for added resources in the remote file system.</description>
- </property>
点击(此处)折叠或打开
- [zhang@namenode ~]$ hive
- 14/12/17 03:04:45 WARN conf.HiveConf: DEPRECATED: Configuration property hive.metastore.local no longer has any effect. Make sure to provide a valid value for hive.metastore.uris if you are connecting to a remote metastore.
- 14/12/17 03:04:45 WARN conf.HiveConf: HiveConf of name hive.metastore.local does not exist
- Logging initialized using configuration in jar:file:/home/zhang/hive/lib/hive-common-0.14.0.jar!/hive-log4j.properties
- SLF4J: Class path contains multiple SLF4J bindings.
- SLF4J: Found binding in [jar:file:/home/zhang/hadoop-2.5.2/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
- SLF4J: Found binding in [jar:file:/home/zhang/hive/lib/hive-jdbc-0.14.0-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class]
- SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
- SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
- Exception in thread \"main\" java.lang.RuntimeException: java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D
- at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:444)
- at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:672)
- at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:616)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.lang.reflect.Method.invoke(Method.java:483)
- at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
- Caused by: java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D
- at org.apache.hadoop.fs.Path.initialize(Path.java:206)
- at org.apache.hadoop.fs.Path.<init>(Path.java:172)
- at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:487)
- at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:430)
- ... 7 more
- Caused by: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D
- at java.net.URI.checkPath(URI.java:1823)
- at java.net.URI.<init>(URI.java:745)
- at org.apache.hadoop.fs.Path.initialize(Path.java:203)
- ... 10 more
(7)下载 mysql-connector-java-5.1.34-bin.jar 文件,并放到$HIVE_HOME/lib目录下 (到官网自行下载即可)
如果没有此jar包,启动hive会报如下错误:
点击(此处)折叠或打开
- Caused by: org.datanucleus.store.rdbms.connectionpool.DatastoreDriverNotFoundException: The specified datastore driver (\"com.mysql.jdbc.Driver\") was not found in the CLASSPATH. Please check your CLASSPATH specification, and the name of the driver.
- at org.datanucleus.store.rdbms.connectionpool.AbstractConnectionPoolFactory.loadDriver(AbstractConnectionPoolFactory.java:58)
- at org.datanucleus.store.rdbms.connectionpool.BoneCPConnectionPoolFactory.createConnectionPool(BoneCPConnectionPoolFactory.java:54)
- at org.datanucleus.store.rdbms.ConnectionFactoryImpl.generateDataSources(ConnectionFactoryImpl.java:238)
- ... 66 more
至此,部署完毕,可以启动,测试下:
看到如下结果,说明启动成功
点击(此处)折叠或打开
- [zhang@namenode ~]$ hive
- 14/12/17 18:48:22 WARN conf.HiveConf: DEPRECATED: Configuration property hive.metastore.local no longer has any effect. Make sure to provide a valid value for hive.metastore.uris if you are connecting to a remote metastore.
- 14/12/17 18:48:22 WARN conf.HiveConf: HiveConf of name hive.metastore.local does not exist
- Logging initialized using configuration in jar:file:/home/zhang/hive/lib/hive-common-0.14.0.jar!/hive-log4j.properties
- SLF4J: Class path contains multiple SLF4J bindings.
- SLF4J: Found binding in [jar:file:/home/zhang/hadoop-2.5.2/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
- SLF4J: Found binding in [jar:file:/home/zhang/hive/lib/hive-jdbc-0.14.0-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class]
- SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
- SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
- hive> show tables;
- OK
- Time taken: 0.924 seconds
- hive> show databases;
- OK
- default
- Time taken: 0.051 seconds, Fetched: 1 row(s)
创建表测试:如果这部分没有报错,那么去检查HDFS下面是否生成了相关文件
点击(此处)折叠或打开
- hive> create table test(t_id int,t_name string) row format delimited fields terminated by \‘|\‘ stored as textfile;
- OK
- Time taken: 1.586 seconds
- hive> show tables;
- OK
- test
- Time taken: 0.078 seconds, Fetched: 1 row(s)
- hive> select * from test;
- OK
- Time taken: 0.599 seconds
点击(此处)折叠或打开
- [zhang@datanode01 ~]$ hdfs dfs -ls /
- 14/12/17 18:55:05 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
- Found 3 items
- drwxr-xr-x - zhang supergroup 0 2014-12-16 02:21 /input
- drwx-wx-wx - zhang supergroup 0 2014-12-17 01:25 /tmp
- drwxr-xr-x - zhang supergroup 0 2014-12-17 18:54 /user
- [zhang@datanode01 ~]$ hdfs dfs -ls /user/
- 14/12/17 18:55:20 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
- Found 1 items
- drwxr-xr-x - zhang supergroup 0 2014-12-17 18:54 /user/hive
- [zhang@datanode01 ~]$ hdfs dfs -ls /user/hive/
- 14/12/17 18:55:27 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
- Found 1 items
- drwxr-xr-x - zhang supergroup 0 2014-12-17 18:54 /user/hive/warehouse
- [zhang@datanode01 ~]$ hdfs dfs -ls /user/hive/warehouse/
- 14/12/17 18:55:34 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
- Found 1 items
- drwxr-xr-x - zhang supergroup 0 2014-12-17 18:54 /user/hive/warehouse/test
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。