首页 \ 问答 \ Hadoop:java.net.ConnectException:连接被拒绝(Hadoop: java.net.ConnectException: Connection refused)

Hadoop:java.net.ConnectException:连接被拒绝(Hadoop: java.net.ConnectException: Connection refused)

您好我一直在尝试按照本教程: http//www.tutorialspoint.com/apache_flume/fetching_twitter_data.htm很长一段时间,我完全陷入第3步:在HDFS中创建目录。 我已经运行了start-dfs.sh和start-yarn.sh,两者似乎都正常工作,因为我得到了与教程相同的输出,但是当我尝试运行时:

hdfs dfs -mkdir hdfs://localhost:9000/user/Hadoop/twitter_data 

我一直收到同样的错误:

mkdir: Call From trz-VirtualBox/10.0.2.15 to localhost:9000 failed on connection exception: java.net.ConnectException: Connection refused; For more details see:  http://wiki.apache.org/hadoop/ConnectionRefused

我无法弄清楚为什么我到处搜索并尝试了一些解决方案,但似乎无法取得进展。 我将列出我认为可能导致此问题的所有文件,但我可能错了:我的core.site.xml是:

<configuration>
<property>  
<name>hadoop.tmp.dir</name>
<value>/Public/hadoop-2.7.1/tmp</value>
<description>A base for other temporary directories.</description>
</property>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>

我的mapred-site.xml是:

<configuration>
<property>
<name>mapred.job.tracker</name>
<value>hdfs://localhost:9001</value>
</property>
</configuration>

我的hdfs.site.xml是:

<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.permission</name>
<value>false</value>
</property>
</configuration>

我在虚拟机上运行Ubuntu 14.04.4 LTS。 我的〜/ .bashrc看起来如此:

export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
export HADOOP_HOME=/usr/local/hadoop/bin 
export HADOOP_HOME=/usr/local/hadoop/bin
export HADOOP_INSTALL=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin
#flume
export FLUME_HOME=/usr/local/Flume
export PATH=$PATH:/FLUME_HOME/apache-flume-1.6.0-bin/bin
export CLASSPATH=$CLASSPATH:/FLUME_HOME/apache-flume-1.6.0-bin/lib/*

最后我的/ etc / hosts文件设置如下:

127.0.0.1  localhost
10.0.2.15  trz-VirtualBox
10.0.2.15  hadoopmaster


# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

添加的hadoopmaster我目前没有使用,这是我试图通过尝试不使用本地主机(没有工作)来解决这个问题之一。 trz-VirtualBox最初是127.0.1.1,但我读到你应该使用你的真实IP地址? 没有工作,所以我不确定。 我发布了所有这些文件,因为我不知道错误在哪里。 我不认为这是一个路径问题(在我完成这一步之前我已经做了很多事情并且能够自己解决它们)所以我没有想法。 我已经在这里工作了几个小时,所以任何帮助都表示赞赏。 谢谢。


Hello I have been trying to follow this tutorial: http://www.tutorialspoint.com/apache_flume/fetching_twitter_data.htm for a very long time now and I am absolutely stuck at Step 3: Create a Directory in HDFS. I have ran start-dfs.sh and start-yarn.sh and both seem to have worked correctly as I am getting the same output as the tutorial but when I try to run:

hdfs dfs -mkdir hdfs://localhost:9000/user/Hadoop/twitter_data 

I keep receiving the same error:

mkdir: Call From trz-VirtualBox/10.0.2.15 to localhost:9000 failed on connection exception: java.net.ConnectException: Connection refused; For more details see:  http://wiki.apache.org/hadoop/ConnectionRefused

I can not figure out why as I have searched everywhere and tried a number of solutions but can't seem to make progress. I am going to list all of the files that I think could cause this but I could be wrong: My core.site.xml is:

<configuration>
<property>  
<name>hadoop.tmp.dir</name>
<value>/Public/hadoop-2.7.1/tmp</value>
<description>A base for other temporary directories.</description>
</property>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>

My mapred-site.xml is:

<configuration>
<property>
<name>mapred.job.tracker</name>
<value>hdfs://localhost:9001</value>
</property>
</configuration>

My hdfs.site.xml is:

<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.permission</name>
<value>false</value>
</property>
</configuration>

I am running Ubuntu 14.04.4 LTS on virtual box. My ~/.bashrc looks as so:

export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
export HADOOP_HOME=/usr/local/hadoop/bin 
export HADOOP_HOME=/usr/local/hadoop/bin
export HADOOP_INSTALL=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin
#flume
export FLUME_HOME=/usr/local/Flume
export PATH=$PATH:/FLUME_HOME/apache-flume-1.6.0-bin/bin
export CLASSPATH=$CLASSPATH:/FLUME_HOME/apache-flume-1.6.0-bin/lib/*

And finally my /etc/hosts file is set up as so:

127.0.0.1  localhost
10.0.2.15  trz-VirtualBox
10.0.2.15  hadoopmaster


# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

The added hadoopmaster I am currently not using, that was one of my attempts to fix this by trying not to use local host (didn't work). trz-VirtualBox was originally 127.0.1.1 but I read that you should use your real IP address? Neither worked so I am not sure. I posted all of these files because I do not know where the error is. I do not think it is a path issue (I had a lot before I got to this step and was able to resolve them myself) so I am out of ideas. I've been at this for a number of hours now so any help is appreciated. Thank you.


原文:https://stackoverflow.com/questions/37637941
更新时间:2023-01-06 15:01

最满意答案

代码对象的主要用途是将函数的静态部分(代码)与动态部分(函数)分开。 代码对象是存储在.pyc文件中的东西,并且是在编译代码时创建的; 函数对象是在声明函数时从运行时创建的。 它们暴露出来用于调试器反射,并且通常不需要直接使用。

所有支持闭包的语言都有类似的东西; 他们并不总是接触Python,因为他们使用的Python比大多数语言更全面。

您可以使用代码对象通过types.FunctionType实例化函数对象,但很少有任何实际用途 - 换句话说,不要这样做:

def func(a=1):
    print a

func2 = types.FunctionType(func.func_code, globals(), 'func2', (2,))
func2()
# 2

The primary use of code objects is to separate the static parts of functions (code) from the dynamic parts (functions). Code objects are the things that are stashed in .pyc files, and are created when code is compiled; function objects are created from them at runtime when functions are declared. They're exposed for debugger reflection and don't often need to be used directly.

All languages that support closures have something like them; they're just not always exposed to the language as they are in Python, which has more comprehensive reflection than most languages.

You can use code objects to instantiate function objects via types.FunctionType, but that very rarely has any practical use--in other words, don't do this:

def func(a=1):
    print a

func2 = types.FunctionType(func.func_code, globals(), 'func2', (2,))
func2()
# 2

相关问答

更多
  • 内置函数没有代码对象,因为它们是用C实现的,而不是用Python实现的。 只有Python函数才有代码对象,因为代码对象是Python字节码编译的。 探索Python代码对象是对代码对象的一个很好的解释。 Built-in functions don't have code objects because they're implemented in C, not in Python. Only Python functions have code objects, because code objects ...
  • 对我来说看起来很好。 做得好。 你多久会运行一次这个脚本? 如果这是一次性的事情,你的大部分问题都没有意义。 我喜欢Employees.cleen_all_phone_numbers()委派给Employee.clean_phone_number() 你真的应该在这里使用索引(字典) 。 您可以在O(n)创建它们时通过hrid每个员工索引,然后在O(1)查找它们。 但是,只有在需要再次运行脚本时才能执行此操作。 只要养成使用字典的习惯。 它们是无痛的,使代码更易于阅读。 每当你编写一个方法lookup_*你 ...
  • 代码对象的主要用途是将函数的静态部分(代码)与动态部分(函数)分开。 代码对象是存储在.pyc文件中的东西,并且是在编译代码时创建的; 函数对象是在声明函数时从运行时创建的。 它们暴露出来用于调试器反射,并且通常不需要直接使用。 所有支持闭包的语言都有类似的东西; 他们并不总是接触Python,因为他们使用的Python比大多数语言更全面。 您可以使用代码对象通过types.FunctionType实例化函数对象,但很少有任何实际用途 - 换句话说,不要这样做: def func(a=1): pri ...
  • 我认为你的错误在于这一行: newObject = TransformUsing(objectSample,transformation[i]) 应该是: newObject = TransformUsing(newObject,transformation[i]) 除了您的代码使用新的ClassSample初始化newObject然后不使用它之外,会发生的事情是每次迭代都要修改ClassSample 的同一个实例 ,即存储在objectSample中的objectSample ,然后将其重新添加到列表 ...
  • 将square_number.pyx更改为: cdef public int square_me(int x): return x * x 运行“setup.py”后,它将生成头文件“square_number.h”。 在您的主应用程序中包含它。 见下文: 将您的“主要”功能更改为: #include #include "square_number.h" int main() { Py_Initialize(); initsquare_number(); ...
  • 假设当前代码的结构方式是正确的,每次调用update_image()方法时都会分配IMAGE_MAPPER 。 现在,因为这是一个不随时间变化的静态映射,从功能的角度来看这不是问题 - 它不像你重置一个应该在调用update_image()之间跟踪的值。 性能方面,在这种特殊情况下,缺点也绝对可以忽略不计。 但从纯逻辑角度来看,将这种映射作为类属性可能是有意义的: class Room1(Room): IMG_MAPPING = {(0, 0, 0) : 0, ...
  • 你的问题对我来说并不完全清楚,但如果你问的是如何break并continue工作,这可能有助于清除它: while True: # do_some_stuff if calculation_finished: break # exit from the innermost loop elif iteration_finished: continue # abort the current iteration and go to the sta ...
  • CPython使用引用计数来自动清理不再引用的对象。 每个名称,列表索引,字典值或键条目或属性都是对Python对象的引用,并且解释器根据需要递增和递减每个对象的引用计数。 当计数达到0时,将自动从内存中清除对象。 将populationList重新绑定到新列表对象时,旧列表的引用计数将降为0并将其清除。 这反过来清除了对包含对象的所有引用,并且它们也被清除,等等。 垃圾收集器进程还跟踪循环引用(仅引用彼此的对象),根据需要自动中断这些循环。 请参阅gc模块以获取内省和更改垃圾收集器行为的工具。 您可以通过 ...
  • 平等 : - 没有定义 __cmp__或 __eq__方法的对象 将引发错误,如果您尝试比较它继承其对象 object比较。 这意味着执行 a > b相当于执行 id(a) > id(b) 。 is关键字还用于查看两个变量是否指向同一个对象。 另一方面, ==运算符调用它正在比较的对象的__cmp__或__eq__方法。 Hashability : - 如果 __hash__定义了 __hash__方法,则对象是可 __hash__ 。 所有基本数据类型(包括字符串和元组)都具有为其定义的哈希函数。 如果没 ...
  • 在最常见的情况下,不可能将任意Python对象转储到Python源代码中。 例如,如果对象是套接字,则在新对象中重新创建相同的套接字是行不通的。 正如aix所解释的那样,对于简单的情况, repr被明确设计为可重现的源表示。 作为一个简单的概括,pprint模块允许通过PrettyPrinter类进行选择性定制。 如果你想要它更通用,如果你唯一的要求是你得到可执行的Python源代码,我建议将对象pickle成一个字符串,然后生成源代码 obj = pickle.loads(%s) 其中%s被repr(p ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)