用php实现对HDFS的操作,大体步骤如下:
wget https://dist.apache.org/repos/dist/release/thrift/0.9.0/thrift-0.9.0.tar.gz tar zxvf thrift-0.9.0.tar.gz cd thrift-0.9.0 find / -name 'bootstrap.sh' yum install automake libtool flex bison pkgconfig gcc-c++ boost-devel libevent-devel zlib-devel python-devel ruby-devel /tmp/thrift-0.9.0/contrib/fb303/bootstrap.sh ./configure -prefix=/usr/local/thrift make //安装期间网络不可中断 make install cp -R ./lib/php/ /usr/local/thrift/lib/ cp -R /tmp/hadoop-1.0.4/src/contrib/thriftfs/gen-php/ /usr/local/thrift/lib/php/src/packages/hadoopfs/ cd ./lib/php/src/ext/thrift_protocol/ yum install php-devel /usr/bin/phpize ./configure make make test make install vim /etc/php.ini cd /tmp/hadoop-1.0.4/src/contrib/thriftfs/scripts/ /tmp/hadoop-1.0.4/src/contrib/thriftfs/scripts/start_thrift_server.sh
在修改了/tmp/hadoop-1.0.4/src/contrib/thriftfs/scripts/start_thrift_server.sh文件中对TOP和CLASSPATH行后,甚至更换了thrift版本到0.2.0依然出现如下错误(运行上述21行的结果)。
[root@srv211 hadoop-1.0.4]# /tmp/hadoop-1.0.4/src/contrib/thriftfs/scripts/start_thrift_server.sh 59256 log4j:ERROR Could not instantiate class [org.apache.hadoop.log.metrics.EventCounter]. java.lang.ClassNotFoundException: org.apache.hadoop.log.metrics.EventCounter at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:186) at org.apache.log4j.helpers.Loader.loadClass(Loader.java:179) at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:320) at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:121) at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:664) at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:647) at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:544) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:440) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:476) at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:471) at org.apache.log4j.LogManager.<clinit>(LogManager.java:125) at org.apache.log4j.Logger.getLogger(Logger.java:105) at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:289) at org.apache.commons.logging.impl.Log4JLogger.<init>(Log4JLogger.java:109) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(LogFactoryImpl.java:1116) at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:914) at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:604) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:336) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:704) at org.apache.hadoop.thriftfs.HadoopThriftServer$HadoopThriftHandler.<clinit>(HadoopThriftServer.java:41) at org.apache.hadoop.thriftfs.HadoopThriftServer.<init>(HadoopThriftServer.java:592) at org.apache.hadoop.thriftfs.HadoopThriftServer.main(HadoopThriftServer.java:612) log4j:ERROR Could not instantiate appender named "EventCounter". Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/conf/Configuration at org.apache.hadoop.thriftfs.HadoopThriftServer$HadoopThriftHandler.<init>(HadoopThriftServer.java:125) at org.apache.hadoop.thriftfs.HadoopThriftServer.<init>(HadoopThriftServer.java:592) at org.apache.hadoop.thriftfs.HadoopThriftServer.main(HadoopThriftServer.java:612) Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.conf.Configuration at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) ... 3 more [root@srv211 hadoop-1.0.4]#
从网上查找了一些方法(其中包括修改/tmp/hadoop-1.0.4/conf/log4j.properties文件,把log4j.appender.EventCounter=org.apache.hadoop.log.metrics.EventCounter替换成log4j.appender.EventCounter=org.apache.hadoop.log.metrics.jvm.EventCounter)试了试都不行。
既然别人的可以,自己的却不可以。那就要考虑软件环境问题了。与承载Hadoop的操作系统应该是关系不大。可能的就是Hadoop的版本和java SDK的版本了。
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索java
, hadoop
, apache
, classloader
, thrift
, at org apache
, mongo hadoop java
, java.lang.NoClassDefFoundError
, thrift安装
AT
php如何实现txt操作、spark hdfs文件操作、scala hdfs文件操作、spark 操作hdfs、java 操作hdfs,以便于您获取更多的相关知识。