资料:
- ${parameter/pattern/string}
- The pattern is expanded to produce a pattern just as in filename expansion. Parameter is expanded and the longest match of
- pattern against its value is replaced with string. If pattern begins with ‘/’, all matches of pattern are replaced with string.
- Normally only the first match is replaced. If pattern begins with ‘#’, it must match at the beginning of the expanded value of
- parameter. If pattern begins with ‘%’, it must match at the end of the expanded value of parameter. If string is null, matches of
- pattern are deleted and the / following pattern may be omitted. If parameter is ‘@’ or ‘*’, the substitution operation is
- applied to each positional parameter in turn, and the expansion is the resultant list. If parameter is an array variable
- subscripted with ‘@’ or ‘*’, the substitution operation is applied to each member of the array in turn, and the expansion is
- the resultant list.
- Bash supports the $"..." quoting syntax to do locale-specific translation of the characters between the double quotes.
这里能解开我之前的一个疑惑:master怎么去启动slaves的。
原来是通过ssh命令
Hadoop-config.sh
- # resolve links - $0 may be a softlink
- this="$0"
- while [ -h "$this" ]; do
- ls=`ls -ld "$this"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '.*/.*' > /dev/null; then
- this="$link"
- else
- this=`dirname "$this"`/"$link"
- fi
- done
不然就是相对链接,需要拼装上当前目录。
果然是bug。https://issues.apache.org/jira/browse/HADOOP-7089 我用的是0.20.203版本。可以看看fix好的版本
- # Resolve links ($0 may be a softlink) and convert a relative path
- # to an absolute path. NB: The -P option requires bash built-ins
- # or POSIX:2001 compliant cd and pwd.
- this="${BASH_SOURCE-$0}"
- common_bin=$(cd -P -- "$(dirname -- "$this")" && pwd -P)
- script="$(basename -- "$this")"
- this="$common_bin/$script"
-- 的作用是表示参数接收已结束 http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap01.html#tag_01_11
也就是说,比如
grep -- -v file-v是内容,不是grep的参数了。
man pwd ,找到
-P, --physical
avoid all symlinks
hadoop
- exec "$JAVA" -Dproc_$COMMAND $JAVA_HEAP_MAX $HADOOP_OPTS -classpath "$CLASSPATH" $CLASS "$@"
最终启动java class
相关阅读:
Hadoop datanode启动失败:Hadoop安装目录权限的问题 http://www.linuxidc.com/Linux/2011-12/49389.htm
在Eclipse下搭建Hadoop开发环境各种问题的解决 http://www.linuxidc.com/Linux/2012-02/54597.htm
