R中HIVE实战

R连接hive报错:

R中报错java.lang.NoClassDefFoundError: com/google/protobuf/ProtocolMessageEnum

hiveserver2端报错java.lang.RuntimeException: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.authorize.AuthorizationException): User: Administrator is not allowed to impersonate hive

解决办法:hadoop中配置文件core-site.xml加以下内容

 
hadoop.proxyuser.root.hosts
* 
 
 
hadoop.proxyuser.root.groups 
* 


hdfs-site.xml中加:

   
dfs.webhdfs.enabled   
true   

将root更改为被禁止的用户,这里是administrator

install.package("rJava")
install.package("DBI")
install.packages("RJDBC")
library('rJava')
library('DBI')
library('RJDBC')
drv<-JDBC("org.apache.hive.jdbc.HiveDriver","hive-jdbc-2.3.6-standalone.jar;hadoop-common-2.9.2.jar")
conn <- dbConnect(drv,"jdbc:hive2://ip:10000/default","hive","hive")
test_data<-dbGetQuery(conn,"select * from test ") 

向HIVE写入数据报错

org.apache.hadoop.security.AccessControlException Permission denied: user=hive, access=WRITE, inode="/hive/warehouse":Administrator:supergroup:drwxr-xr-x

更改权限:hdfs-site.xml文件中加

  
dfs.permissions.enabled  
false  

R连接HIVE并提取数据,提取数据的进程可以在hive的hiveserver2命令窗口看到 

drv<-JDBC("org.apache.hive.jdbc.HiveDriver","hive-jdbc-2.3.6-standalone.jar;hadoop-common-2.9.2.jar")
conn <- dbConnect(drv,"jdbc:hive2://IP:10000/default","hive","hive")
test_data<-dbGetQuery(conn,"select * from test")

对于向HIVE中插入/创建/更新数据遇到了个bug,虽然数据似乎可以进行操作,hive命令窗口显示成功操作,但R端口返回报错,暂未解决 

 

你可能感兴趣的:(SQL)