使用mysql作为hive的元数据库

  1.hive下载安装
 
   2.下载mysql安装
 
   3.以root用户进入mysql命令行:mysql -uroot -p(提示输入密码)
 
   4.创建hive的元数据库:create database metahive【元数据库名metahive】
 
   5.创建hive用户:create user hive@'localhost' identified by 'hive'【mysql中为hive专用的user名:hive,密码为:hive】
 
   6.赋予权限:grant all privileges on metahive.* to hive;flush privileges;
 
   7.登出root用户:quit;
 
   8.使用hive用户登录mysql:mysql -uhive -p(提示输入密码)
 
   【登录后,show databases;可以看到有metahive这一数据库,OK!】
 
   9.配置hive:【主要是hive-site.xml文件】
 
   9.1.将hive的conf文件夹中的hive-default.xml.template文件拷贝为hive-site.xml文件:cp hive-default.xml.template hive-site.xml
 
   9.2.配置hive-site.xml文件:vim hive-site.xml
 
   需要修改的property有如下几个:【由于hive默认的元数据库为其内置的derby数据库,要修改为mysql】
 
   <property>
 
   <name>javax.jdo.option.ConnectionURL</name>
 
   <value>jdbc:mysql://localhost:3306/元数据库名?createDatabaseIfNotExist=true</value>
 
   <description>JDBCconnectstringforaJDBCmetastore</description>
 
   </property>
 
   <property>
 
   <name>javax.jdo.option.ConnectionDriverName</name>
 
   <value>com.mysql.jdbc.Driver</value>
 
   <description>DriverclassnameforaJDBCmetastore</description>
 
   </property>
 
   <property>
 
   <name>javax.jdo.option.ConnectionUserName</name>
 
   <value>mysql中为hive专用的用户名</value>
 
   <description>usernametouseagainstmetastoredatabase</description>
 
   </property>
 
   <property>
 
   <name>javax.jdo.option.ConnectionPassword</name>
 
   <value>123456</value>
 
   <description>passwordtouseagainstmetastoredatabase</description>
 
   </property>
 
   10.配置完后注意在/etc/profile(或者redhat OS下的。bash_profile和ubuntu OS下的。bashrc)中添加HIVE_HOME(hive安装路径下bin的上一层)
 
   以上步骤的顺序是没有严格要求的,至此,算是安装配置完毕,下面进入测试阶段
 
   11.进入hive cli:命令行输入hive
 
   12.在hive中建测试表test:create table test(id int,name string)row format delimited fields terminated by '\t' lines terminated by '\n' stored as textfile;托福答案     www.qcwyo68.com 
 
 

posted on 2014-02-12 17:54  haosola  阅读(680)  评论(0编辑  收藏  举报

toeflacttoeflieltstoefltoeflact