1:这个问题都被大家玩烂了,这里我也记载一下,方便以后脑补:
1 SLF4J: Class path contains multiple SLF4J bindings. 2 SLF4J: Found binding in [jar:file:/E:/360Downloads/hadoop-2.4.1/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] 3 SLF4J: Found binding in [jar:file:/E:/360Downloads/hbase-0.99.2/lib/slf4j-log4j12-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class] 4 SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. 5 SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] 6 2017-12-18 18:06:27,778 WARN [main] util.NativeCodeLoader (NativeCodeLoader.java:<clinit>(62)) - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 7 2017-12-18 18:06:27,786 ERROR [main] util.Shell (Shell.java:getWinUtilsPath(336)) - Failed to locate the winutils binary in the hadoop binary path 8 java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries. 9 at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:318) 10 at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:333) 11 at org.apache.hadoop.util.Shell.<clinit>(Shell.java:326) 12 at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:76) 13 at org.apache.hadoop.security.Groups.parseStaticMapping(Groups.java:93) 14 at org.apache.hadoop.security.Groups.<init>(Groups.java:77) 15 at org.apache.hadoop.security.Groups.getUserToGroupsMappingService(Groups.java:240) 16 at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:255) 17 at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:232) 18 at org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:718) 19 at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:703) 20 at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:605) 21 at org.apache.hadoop.hbase.security.User$SecureHadoopUser.<init>(User.java:256) 22 at org.apache.hadoop.hbase.security.User$SecureHadoopUser.<init>(User.java:252) 23 at org.apache.hadoop.hbase.security.User.getCurrent(User.java:156) 24 at org.apache.hadoop.hbase.security.UserProvider.getCurrent(UserProvider.java:88) 25 at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:215) 26 at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:119) 27 at com.hbaseTest.HbaseTest.init(HbaseTest.java:57) 28 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 29 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 30 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 31 at java.lang.reflect.Method.invoke(Method.java:606) 32 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) 33 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) 34 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) 35 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) 36 at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) 37 at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79) 38 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71) 39 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) 40 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) 41 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) 42 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) 43 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) 44 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) 45 at org.junit.runners.ParentRunner.run(ParentRunner.java:236) 46 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) 47 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 48 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) 49 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) 50 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) 51 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
我是测试Hbase创建数据表的时候遇到的这种问题,总之吧,window操作hadoop都会遇到这种问题:
1 第一步:自己配置window的环境变量(很明显应该是HADOOP_HOME的问题。如果HADOOP_HOME为空,必然fullExeName为null\bin\winutils.exe。解决方法很简单,配置环境变量,)。 2 第二步:不想重启电脑可以在程序里加上: 3 System.setProperty("hadoop.home.dir", "C:\\Users\\Administrator\\Desktop\\hadoop-2.7.3\\hadoop-2.7.3"); 4 比如我添加到此处: 5 @Before 6 public void init() throws Exception { 7 System.setProperty("hadoop.home.dir", "E:\\hadoop-2.6.4"); 8 // 配置 9 config = HBaseConfiguration.create(); 10 // zookeeper地址 11 config.set("hbase.zookeeper.quorum", "master,slaver1,slaver2"); 12 // zookeeper端口 13 config.set("hbase.zookeeper.property.clientPort", "2181"); 14 // 通过工厂模式创建一个Connection 15 connection = ConnectionFactory.createConnection(config); 16 // 通过Connection获取表连接 17 table = connection.getTable(TableName.valueOf("user")); 18 } 19 第三步:去https://github.com/srccodes/hadoop-common-2.2.0-bin/tree/master/bin 20 下载winutils.exe文件复制到自己的E:\hadoop-2.6.4\bin目录里面。 21 第四步:重新运行程序就OK了,问题解决。
停更......