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
最满意答案
代码对象的主要用途是将函数的静态部分(代码)与动态部分(函数)分开。 代码对象是存储在.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 ...
-
Python使用对象(Python working with objects)[2023-06-28]
我认为你的错误在于这一行: 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 ...