Winse Blog

走走停停, 熙熙攘攘, 忙忙碌碌, 不知何畏.

hbase-0.94启动脚本在cygwin环境的BUG

该Bug的问题本质,其实是不同系统classpath的分隔符不同。

问题原由:

搞了一天,简单的本地默认的hbase的环境搭不起,郁闷!

最后,原来是hbase脚本的bug!!

1
2
3
Winseliu@WINSE ~/hbase-0.94.2
$ bin/hbase classpath
C:\cygwin\home\Winseliu\hbase-0.94.2\conf;C:\Java\jdk1.7.0_02\lib\tools.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\;C:\cygwin\home\Winseliu\hbase-0.94.2\hbase-0.94.2.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\hbase-0.94.2-tests.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\activation-1.1.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\asm-3.1.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\avro-1.5.3.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\avro-ipc-1.5.3.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\commons-beanutils-1.7.0.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\commons-beanutils-core-1.8.0.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\commons-cli-1.2.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\commons-codec-1.4.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\commons-collections-3.2.1.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\commons-configuration-1.6.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\commons-digester-1.8.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\commons-el-1.0.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\commons-httpclient-3.1.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\commons-io-2.1.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\commons-lang-2.5.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\commons-logging-1.1.1.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\commons-math-2.1.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\commons-net-1.4.1.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\core-3.1.1.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\guava-11.0.2.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\hadoop-core-1.0.3.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\high-scale-lib-1.1.1.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\httpclient-4.1.2.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\httpcore-4.1.3.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jackson-core-asl-1.8.8.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jackson-jaxrs-1.8.8.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jackson-mapper-asl-1.8.8.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jackson-xc-1.8.8.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jamon-runtime-2.3.1.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jasper-compiler-5.5.23.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jasper-runtime-5.5.23.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jaxb-api-2.1.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jaxb-impl-2.2.3-1.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jersey-core-1.8.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jersey-json-1.8.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jersey-server-1.8.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jettison-1.1.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jetty-6.1.26.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jetty-util-6.1.26.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jruby-complete-1.6.5.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jsp-2.1-6.1.14.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jsp-api-2.1-6.1.14.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\jsr305-1.3.9.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\junit-4.10-HBASE-1.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\libthrift-0.8.0.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\log4j-1.2.16.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\metrics-core-2.1.2.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\netty-3.2.4.Final.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\protobuf-java-2.4.0a.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\servlet-api-2.5-6.1.14.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\slf4j-api-1.4.3.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\slf4j-log4j12-1.4.3.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\snappy-java-1.0.3.2.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\stax-api-1.0.1.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\velocity-1.7.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\xmlenc-0.52.jar;C:\cygwin\home\Winseliu\hbase-0.94.2\lib\zookeeper-3.4.3.jar:

环境变量最后应该是一个“;”而现在是“:”

解决问题

修改如下(其实就是把cygwin路径转换的代码位置移动了一下):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Winseliu@WINSE ~/hbase-0.94.2/bin
$ diff -urN hbase-old hbase
--- hbase-old   2012-10-08 04:04:16.000000000 +0800
+++ hbase       2012-11-25 19:08:06.408506700 +0800
@@ -199,13 +199,6 @@
   HBASE_LOGFILE='hbase.log'
 fi

-# cygwin path translation
-if $cygwin; then
-  CLASSPATH=`cygpath -p -w "$CLASSPATH"`
-  HBASE_HOME=`cygpath -d "$HBASE_HOME"`
-  HBASE_LOG_DIR=`cygpath -d "$HBASE_LOG_DIR"`
-fi
-
 function append_path() {
   if [ -z "$1" ]; then
     echo $2
@@ -227,6 +220,13 @@
   CLASSPATH=$(append_path "${CLASSPATH}" `${HADOOP_IN_PATH} classpath 2>/dev/null`)
 fi

+# cygwin path translation
+if $cygwin; then
+  CLASSPATH=`cygpath -p -w "$CLASSPATH"`
+  HBASE_HOME=`cygpath -d "$HBASE_HOME"`
+  HBASE_LOG_DIR=`cygpath -d "$HBASE_LOG_DIR"`
+fi
+
 if [ -d "${HBASE_HOME}/build/native" -o -d "${HBASE_HOME}/lib/native" ]; then
   if [ -z $JAVA_PLATFORM ]; then
     JAVA_PLATFORM=`CLASSPATH=${CLASSPATH} ${JAVA} org.apache.hadoop.util.PlatformName | sed -e "s/ /_/g"`

或者修改下append_path方法也可以。


【原文地址】

–END

Comments