[Hive基础]-- hive单用户及多用户的实现(已经实现多用户)

1. 启动hadoop集群,hdfs和yarn--->start-dfs.sh  start-yarn.sh

2. 关掉安全模式,hadoop dfsadmin -safemode leave(注意:每次进入时,都要先关闭h15和h18)

3. apache-hive-1.2.1-bin.tarTar包上传解压,进去conf目录(单用户则安装1个节点,多用户则安装2个节点)

4. 解压目录conf下复制一个配置文件,#cp hive-default.xml.template  hive-site.xml

5. 清空修改hive-site.xml内容

6. 单用户模式:(多用户则不用配置)

  

  hive.metastore.warehouse.dir  

  /user/hive_remote/warehouse  

 

  

  hive.metastore.local  

  true  

 

  

  javax.jdo.option.ConnectionURL  

  jdbc:mysql://192.168.142.115:3306/hive_remote?createDatabaseIfNotExist=true  

 

  

  javax.jdo.option.ConnectionDriverName  

  com.mysql.jdbc.Driver  

 

  

  javax.jdo.option.ConnectionUserName  

  hive  

 

  

  javax.jdo.option.ConnectionPassword  

  password  

  

7. 多用户模式分服务器端和客户端

a) Mysql h15服务器端的hive目录下hive-site.xml

  

  hive.metastore.warehouse.dir  

  /user/hive/warehouse  

  

   

  

  javax.jdo.option.ConnectionURL  

  jdbc:mysql://192.168.142.115:3306/hive?createDatabaseIfNotExist=true  

  

  

 

  javax.jdo.option.ConnectionDriverName  

 

  com.mysql.jdbc.Driver  

  

  

  javax.jdo.option.ConnectionUserName  

  root  

  

   

  

  javax.jdo.option.ConnectionPassword  

  1714****  

  

b) Mysql h18客户端的hive目录下hive-site.xml

  

  hive.metastore.warehouse.dir  

  /user/hive/warehouse  

  

   

  

  hive.metastore.local  

  false  

  

  

  

  hive.metastore.uris  

  thrift://h15:9083  h15是hive服务器的ip

  

将hadoop  “/home/hadoop-2.5.1/share/hadoop/yarn/lib”中的jline-0.9.94.jar包替换成hive中新版本的包jline-2.12.jar.

注意:在h18上也要替换

 

8. 安装mysql库,上面的配置文件里面的mysql地址就配置这个地址

9. 将mysql jdbc的驱动包mysql-connector-java-5.1.32-bin.jar放到hive/lib目录下

10. 复制hive到h18上

#scp -r /home/hive-1.2.1 root@h18:/home

同时修改conf/hive-site.xml文件为客户端的配置

  

  hive.metastore.warehouse.dir  

  /user/hive/warehouse  

  

   

  

  hive.metastore.local  

  false  

  

  

  

  hive.metastore.uris  

  thrift://h15:9083  h15是hive服务器的ip

  

11. yum –y install mysql-server

12. mysql –uroot –p 进去mysql,默认密码是空

   a)use mysql

   b)delete from user where user='';

   c)update user set host='%' where host='localhost';

   d)update user set password=PASSWORD('1714004716') where user='root';

   e)flush privileges;

13. 单用户启动bin/hive

14. 多用户启动,先在服务器端h15上启动:\sh hive  --service metastore

   然后再客户端h18上访问:hive 

 

注意:需要先启动mysql

注意:mysql的my.cnf文件中不要添加编码格式

错误:

Could not create ServerSocket on address 0.0.0.0/0.0.0.0:9083.

说明hive服务器端已经启动,需要杀死后,重新启动,或者重启hadoop集群

 

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes

解决:需要进入mysql目录下删除创建的hive库

Mysql》  drop database hive;

 

 

 

你可能感兴趣的:(Hive)