【问题标题】:Exception : org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.AccessControlException): Permission denied: user=hbase, access=EXECUTE异常:org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.AccessControlException):权限被拒绝:user=hbase,access=EXECUTE
【发布时间】:2015-06-04 22:40:08
【问题描述】:

我正在尝试将 BulkLoad 执行到 Hbase。 map reduce 的输入是 hdfs 文件(来自 Hive)。 在 Tool(Job) 类中使用以下代码启动批量加载过程 HFileOutputFormat.configureIncrementalLoad(job, new HTable(config, TABLE_NAME));

在 Mapper 中,使用以下作为 Mapper 的输出 context.write(new ImmutableBytesWritable(Bytes.toBytes(hbaseTable)), put);

一旦映射器完成。使用

执行实际的批量加载
LoadIncrementalHFiles loadFfiles = new LoadIncrementalHFiles(configuration);    
HTable hTable = new HTable(configuration, tableName);   
loadFfiles.doBulkLoad(new Path(pathToHFile), hTable);

作业运行良好,但是一旦 Loadincrement 启动,它就会永远挂起。经过多次尝试后,我必须停止工作。然而,经过漫长的等待可能是 30 分钟,我终于得到了上述错误。经过广泛搜索后,我发现 Hbase 将尝试访问放置在输出文件夹中的文件(HFiles),并且该文件夹无权写入或执行。所以抛出上述错误。因此,替代解决方案是在执行批量加载之前在 java 代码中添加文件访问权限,如下所示。

FileSystem fileSystem = FileSystem.get(config);
fileSystem.setPermission(new Path(outputPath),FsPermission.valueOf("drwxrwxrwx"));

当我们从开发转向生产时,这是正确的方法吗?同样,一旦我添加了上面的代码,我在输出文件夹中创建的文件夹也出现了类似的错误。这次是列族文件夹。这是运行时的动态动作。

作为一种临时解决方法,我按照以下方式进行操作,并且能够继续前进。 fileSystem.setPermission(new Path(outputPath+"/col_fam_folder"),FsPermission.valueOf("drwxrwxrwx"));

这两个步骤似乎都是解决方法,我需要一个正确的解决方案才能投入生产。提前致谢

【问题讨论】:

  • 您是否同时拥有hadoophbase 用户?您是否以hbase 用户而不是hadoop 用户身份执行此代码?如果以 hadoop 用户身份执行此代码,则无需设置输出路径的权限。
  • 您好,如何识别您正在执行作业的用户。我想它不是我正在运行的 hbase 用户。
  • 在您将目录设为 777 之前,该目录的所有权/权限是什么?
  • 它们是通过 map reduce 作业在旅途中创建的。但是错误地显示为“drwxr-x---”

标签: hadoop mapreduce hbase bulk-load


【解决方案1】:

试试这个 System.setProperty("HADOOP_USER_NAME", "hadoop");

【讨论】:

  • 但这也是在生产中使用的正确方法吗?
【解决方案2】:

Secure bulk load 似乎是一个合适的答案。 This thread 解释了一个示例实现。 sn-p 复制如下。

import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.client.coprocessor.SecureBulkLoadClient;
import org.apache.hadoop.hbase.security.UserProvider;
import org.apache.hadoop.hbase.security.token.FsDelegationToken;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.security.UserGroupInformation;

String keyTab = "pathtokeytabfile";
String tableName = "tb_name";
String pathToHFile = "/tmp/tmpfiles/";
Configuration configuration = new Configuration();  

configuration.set("hbase.zookeeper.quorum","ZK_QUORUM");
configuration.set("hbase.zookeeper"+ ".property.clientPort","2181");
configuration.set("hbase.master","MASTER:60000");
configuration.set("hadoop.security.authentication", "Kerberos");
configuration.set("hbase.security.authentication", "kerberos");


//Obtaining kerberos authentication 

UserGroupInformation.setConfiguration(configuration);

UserGroupInformation.loginUserFromKeytab("here keytab", path to the key tab);

HBaseAdmin.checkHBaseAvailable(configuration);

System.out.println("HBase is running!");

HBaseConfiguration.addHbaseResources(configuration);    

Connection conn = ConnectionFactory.createConnection(configuration);

Table table = conn.getTable(TableName.valueOf(tableName));

HRegionInfo tbInfo = new HRegionInfo(table.getName());


//path to the HFiles that need to be loaded 

Path hfofDir = new Path(pathToHFile);

//acquiring user token for authentication 

UserProvider up = UserProvider.instantiate(configuration);

FsDelegationToken fsDelegationToken = new FsDelegationToken(up, "name of the key tab user");

    fsDelegationToken.acquireDelegationToken(hfofDir.getFileSystem(configuration));

//preparing  for the bulk load

SecureBulkLoadClient secureBulkLoadClient = new SecureBulkLoadClient(table);

String bulkToken = secureBulkLoadClient.prepareBulkLoad(table.getName());

System.out.println(bulkToken);

//creating the family list (list of family names and path to the hfile corresponding to the family name)

final List<Pair<byte[], String>> famPaths = new ArrayList<>();

Pair p = new Pair();

//name of the family 
p.setFirst("nameofthefamily".getBytes());

//path to the HFile (HFile are organized in folder with the name of the family)
p.setSecond("/tmp/tmpfiles/INTRO/nameofthefilehere");

famPaths.add(p);

//bulk loading ,using the secure bulk load client

secureBulkLoadClient.bulkLoadHFiles(famPaths, fsDelegationToken.getUserToken(), bulkToken, tbInfo.getStartKey());

System.out.println("Bulk Load Completed..");    

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-09
    相关资源
    最近更新 更多