转自地址:http://shanchao7932297.blog.163.com/blog/static/136362420115144647286/

Hadoop-----Unrecognized option: -jvm
情景描述:
        在VM虚拟机上,按照hadoop手册,搭建Single Node.
        启动hadoop时   #./start-all.sh
        报错:
        ###################
################## ##################
         localhost: Unrecognized option: -jvm
         localhost: Could not create the Java virtual machine. 
        
################## ################## ##################       

环境:
      服务器:RHEL4.7_x86_64 内存:512M
      hadoop版本:hadoop-0.20.203.0rc1.tar.gz
      java版本:jdk-6u25-linux-x64.bin
         
解决:
   可以修改的地方有两个
       第一个(次要的):/usr/local/hadoop/conf/hadoop-env.sh
       修改参数: export HADOOP_HEAPSIZE=256   #默认值为1000M,为Java虚拟机占用的内存的大小

   第二个(主要的)
       查看
/usr/local/hadoop/bin/hadoop 源码:
       ################################################
#### #### #### #### ## ##
       if [[ $EUID -eq 0 ]]; then
           HADOOP_OPTS="$HADOOP_OPTS -jvm server $HADOOP_DATANODE_OPTS"
       else
           HADOOP_OPTS="$HADOOP_OPTS -server $HADOOP_DATANODE_OPTS"
       fi
       
################################################ #### #### #### #### ####
       如果以root身份启动,则hadoop启动java虚拟机时,会带上-jvm参数。
       不同的java版本,启动参数可能会不一致,由此导致以上问题。

       [补充]:可以通过编辑bin下面的hadoop文件,修改掉上面的语句进行解决,修改为:
        
#if [[ $EUID -eq 0 ]]; then
        #   HADOOP_OPTS="$HADOOP_OPTS -jvm server $HADOOP_DATANODE_OPTS"
        #else
           HADOOP_OPTS="$HADOOP_OPTS -server $HADOOP_DATANODE_OPTS"
        #fi

       
       其他解释
       (详细见链接地址:
       http://mail-archives.apache.org/mod_mbox/hadoop-hdfs-user/201105.mbox
       /%3CBANLkTinm3q4EAo=GkeMjG67ZnXXRLRV+yw@mail.gmail.com%3E):
       ####################################################################       

            > I think, that code is there for jsvc. If you run hadoop in secure mode, it             
            > executes this path. There is nothing wrong in -jvm option since it meant for             
            > jsvc.             
            >             
            > In case of secure mode, jsvc process runs as root and invokes the datanode             
            > process as hdfs user (or any other configured user).            
            > But it seems there is a bug in the code, if you run as root in non-secured             
            > mode this issue can trigger.             
            >
       ####################################################################       
       因此,
       新建一个hadoop用户,
       重新初始化操作:#./
hadoop namenode -format
 
       再次启动hadoop: #./start-all.sh
       正常。
       
 补充: 修改JAVA_HEAP_MAX的大小:
        # vi bin/hadoop
          JAVA_HEAP_MAX=-Xmx1000m
    
       输出结果:
############################
############################ ############################ ###### ###### ###### ###### ##
[hadoop@localhost bin]$ ./start-all.sh 
starting namenode, logging to /usr/local/hadoop/bin/../logs/hadoop-hadoop-namenode-localhost.out
localhost: starting datanode, logging to /usr/local/hadoop/bin/../logs/hadoop-hadoop-datanode-localhost.out
localhost: starting secondarynamenode, logging to /usr/local/hadoop/bin/../logs/hadoop-hadoop-secondarynamenode-localhost.out
starting jobtracker, logging to /usr/local/hadoop/bin/../logs/hadoop-hadoop-jobtracker-localhost.out
localhost: starting tasktracker, logging to /usr/local/hadoop/bin/../logs/hadoop-hadoop-tasktracker-localhost.out
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐