首页 \ 问答 \ Hadoop - namenode未启动(Hadoop - namenode is not starting up)

Hadoop - namenode未启动(Hadoop - namenode is not starting up)

我试图以root用户身份运行hadoop,当Hadoop文件系统运行时,我执行了namenode格式命令hadoop namenode -format

在此之后,当我尝试启动名称节点服务器时,它显示如下所示的错误

13/05/23 04:11:37 ERROR namenode.FSNamesystem: FSNamesystem initialization failed.
java.io.IOException: NameNode is not formatted.
        at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:330)
        at org.apache.hadoop.hdfs.server.namenode.FSDirectory.loadFSImage(FSDirectory.java:100)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.initialize(FSNamesystem.java:411)

我试图寻找任何解决方案,但找不到任何明确的解决方案。

任何人都可以建议

谢谢。


I am trying to run hadoop as a root user, i executed namenode format command hadoop namenode -format when the Hadoop file system is running.

After this, when i try to start the name node server, it shows error like below

13/05/23 04:11:37 ERROR namenode.FSNamesystem: FSNamesystem initialization failed.
java.io.IOException: NameNode is not formatted.
        at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:330)
        at org.apache.hadoop.hdfs.server.namenode.FSDirectory.loadFSImage(FSDirectory.java:100)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.initialize(FSNamesystem.java:411)

I tried to search for any solution, but cannot find any clear solution.

Can anyone suggest?

Thanks.


原文:https://stackoverflow.com/questions/16713011
更新时间:2021-11-30 11:11

最满意答案

1.我需要了解的所有命名约定是什么?

db表是复数,模型是单数,控制器是复数。 因此您拥有由users表支持的User模型,并可通过UsersController查看。

文件应该命名为类名的wide_cased版本。 所以FooBar类需要放在一个名为foo_bar.rb的文件中。 如果您使用模块命名空间,命名空间需要由文件夹来表示。 所以如果我们谈论Foo::Bar类,它应该在foo/bar.rb

2.控制器操作应如何构建和命名?

控制器操作应该是RESTful。 这意味着您应该将您的控制器视为公开资源,而不仅仅是启用RPC。 Rails具有成员操作与资源收集操作的概念。 成员动作是在特定实例上运行的,例如/users/1/edit将是用户的编辑成员动作。 收集行动是对所有资源进行操作的东西。 所以/users/search?name=foo会是一个集合操作。

上面的教程描述了如何在您的路线文件中实际实现这些想法。

3.什么是在视图中呈现信息的最佳方式(通过:content_for或呈现部分内容)以及我不应该使用哪些方式?

当您希望能够将内部模板中的html附加到外部模板时,应该使用content_for ,例如,可以将视图模板中的某些内容附加到布局模板中。 一个很好的例子是添加一个页面特定的JavaScript。

# app/views/layout/application.rb
<html>
  <head>
    <%= yield :head %>
...

# app/views/foobars/index.html.erb

<% content_for :head do %>
  <script type='text/javascript'>
    alert('zomg content_for!');
  </script>
<% end %>

部分文件要么分解大文件,要么多次渲染相同位置的信息。 例如

<table>
  <%= render :partial => 'foo_row', :collection => @foobars %>
</table>

# _foo_row.html.erb

<tr>
 <td>
  <%= foobar.name %>
 </td>
</tr>

4.什么应该进入帮手,什么不应该?

你的模板应该只有基本的分支逻辑。 如果你需要做更激烈的事情,它应该是一个帮手。 视图中的局部变量对世界上所有的好和正确的东西都是可憎的,所以这是一个很好的迹象,你应该帮助你。

另一个原因是纯粹的代码重用。 如果你只是一次又一次地做同样的事情,把它拉到一个帮手(如果它是完全一样的东西,它应该是在一个部分)。

5.什么是常见的陷阱或我需要从一开始就正确做的事情?

partials不应直接引用实例(@)变量,因为它会阻止重新使用该行。 总是将数据通过:locals => { :var_name => value }参数传递给render函数。

保持与视图呈现没有直接关系的视图之外的逻辑。 如果你有选择在视图中做某件事,并在其他地方做某件事,那么在其他地方做9次是更好的选择。

我们在轨道上有一个“脂肪模型,瘦身控制器”的口头禅。 一个原因是模型是面向对象的,控制器是非程序化的。 另一个是模型可以跨越控制器,但控制器不能跨越模型。 第三是模型更具可测性。 它只是一个好主意。

6.你如何模块化代码? 这是lib文件夹的用途吗?

lib文件夹用于跨越模型问题的代码(即,不是模型的东西,但将被多个模型使用)。 当你需要在那里放置某些东西时,你会知道,因为你无法弄清楚应该使用什么模型。在这之前,你可以忽略lib。

需要注意的是,从rails 3开始,lib不在自动加载路径上,这意味着您需要任何内容​​(或将其添加回)

一种自动需要lib目录中所有模块的方法:

#config/initializers/requires.rb
Dir[File.join(Rails.root, 'lib', '*.rb')].each do |f|
  require f
end

1. What are all naming conventions I need to be aware of?

db table is plural, model is singular, controller is plural. so you have the User model that is backed by the users table, and visible through the UsersController.

files should be named as the wide_cased version of the class name. so the FooBar class needs to be in a file called foo_bar.rb. If you are namespacing with modules, the namespaces need to be represented by folders. so if we are talking about Foo::Bar class, it should be in foo/bar.rb.

2. How should controller actions be structured and named?

controller actions should be RESTful. That means that you should think of your controllers as exposing a resource, not as just enabling RPCs. Rails has a concept of member actions vs collection actions for resources. A member action is something that operates on a specific instance, for example /users/1/edit would be an edit member action for users. A collection action is something that operates on all the resources. So /users/search?name=foo would be a collection action.

The tutorials above describe how to actually implement these ideas in your routes file.

3. What are the best ways to render information in a view (via :content_for or render a partial) and what are ways I shouldn't use?

content_for should be used when you want to be able to append html from an inner template to an outer template -- for example, being able to append something from your view template into your layout template. A good example would be to add a page specific javascript.

# app/views/layout/application.rb
<html>
  <head>
    <%= yield :head %>
...

# app/views/foobars/index.html.erb

<% content_for :head do %>
  <script type='text/javascript'>
    alert('zomg content_for!');
  </script>
<% end %>

partials are either for breaking up large files, or for rendering the same bit of information multiple times. For example

<table>
  <%= render :partial => 'foo_row', :collection => @foobars %>
</table>

# _foo_row.html.erb

<tr>
 <td>
  <%= foobar.name %>
 </td>
</tr>

4.What should go into a helper and what shouldn't?

your templates should only have basic branching logic in them. If you need to do anything more intense, it should be in a helper. local variables in views are an abomination against all that is good and right in the world, so that is a great sign that you should make a helper.

Another reason is just pure code reuse. If you are doing the same thing with only slight variation over and over again, pull it into a helper (if it is the exact same thing, it should be in a partial).

5. What are common pitfalls or something I need to do correctly from the very beginning?

partials should never refer directly to instance (@) variables, since it will prevent re-use down the line. always pass data in via the :locals => { :var_name => value } param to the render function.

Keep logic out of your views that is not directly related to rendering your views. If you have the option to do something in the view, and do it somewhere else, 9 times out of 10 doing it somewhere else is the better option.

We have a mantra in rails that is "fat models, skinny controllers". One reason is that models are object oriented, controllers are inherantly procedural. Another is that models can cross controllers, but controllers cant cross models. A third is that models are more testable. Its just a good idea.

6. How can you modularize code? Is that what the lib folder is for?

the lib folder is for code that crosses the concerns of models (i.e. something that isn't a model, but will be used by multiple models). When you need to put something in there, you will know, because you wont be able to figure out what model to put it in. Until that happens, you can just ignore lib.

Something to keep in mind is that as of rails 3, lib is not on the autoload path, meaning that you need to require anything you put in there (or add it back in)

A way to automatically require all modules in the lib directory:

#config/initializers/requires.rb
Dir[File.join(Rails.root, 'lib', '*.rb')].each do |f|
  require f
end

相关问答

更多
  • 关于Ruby[2022-10-11]

    Ruby on Rails是一个用于编写网络应用程序的框架,它基于计算机软件语言Ruby,给程序开发人员提供强大的框架支持。Ruby on Rails包括两部分内容:Ruby语言和Rails框架。 什么是Ruby? Ruby 语言是一种动态语言,它与Python、Smalltalk和Perl这3种编程语言有些类似。Ruby语言起源于日本,它的研发者是日本人松本行弘(Matsumoto Yukihiro)。松本行弘在1993年开始着手Ruby语言的研发工作,他开发Ruby语言的初衷是为了提高编程的效率。 19 ...
  • Ruby on Rails是一个 Web 应用程序框架,是一个相对较新的 Web 应用程序框架,构建在 Ruby 语言之上。它被宣传为现有企业框架的一个替代,而它的目标,简而言之,就是让生活,至少是 Web 开发方面的生活,变得更轻松。 J2EE是一种利用Java 2平台来简化企业解决方案的开发、部署和管理相关的复杂问题的体系结构。J2EE技术的基础就是核心Java平台或Java 2平台的标准版,J2EE体系结构提供中间层集成框架用来满足无需太多费用而又需要高可用性能高可靠性以及可扩展性的应用的需求。 ...
  • rubygems RubyGems(简称 gems)是一个用于对 Rails 组件进行打包的 Ruby 打包系统。 它提供一个分发 Ruby 程序和库的标准格式,还提供一个管理程序包安装的工具。 RubyGems的功能类似于Linux下的apt-get。使用它可以方便第从远程服务器下载并安装Rails。 gem ruby一些打好包的插件,使用rubygems进行安装 irb 交互式ruby,命令行工具。将命令和表达式键入irb后,它会立刻执行 sqlite3 数据库的一种 ruby on rails, ra ...
  • 1.我需要了解的所有命名约定是什么? db表是复数,模型是单数,控制器是复数。 因此您拥有由users表支持的User模型,并可通过UsersController查看。 文件应该命名为类名的wide_cased版本。 所以FooBar类需要放在一个名为foo_bar.rb的文件中。 如果您使用模块命名空间,命名空间需要由文件夹来表示。 所以如果我们谈论Foo::Bar类,它应该在foo/bar.rb 。 2.控制器操作应如何构建和命名? 控制器操作应该是RESTful。 这意味着您应该将您的控制器视为公开资 ...
  • 不错不错,楼主貌似木有小JJ, 学吧,脱离MVC了,你很有发展前途 把分给哥加上
  • RVM允许您创建不同的gemset以及不同的ruby版本。 您可以使用rvm install来安装不同版本的ruby。 rvm install 1.8.7 rvm install 1.9.2 rvm list known会告诉您可以安装的可用ruby实现。 比方说,你有两个项目:project_one和project_two,并且它们都有不同的gem依赖关系。 所以你需要用Ruby 1.9.2创建两个空的gemset。 rvm gemset create 1.9.2@project_one rvm gems ...
  • 根据发行说明( http://edgeguides.rubyonrails.org/4_0_release_notes.html ): 强调 Ruby 2.0首选; 1.9.3+必需 这是不言而喻的。 强参数 允许您为控制器的质量分配指定允许的属性。 在此处阅读更多内容: http : //blog.remarkablelabs.com/2012/12/strong-parameters-rails-4-countdown-to-2013 Turbolinks “而不是让浏览器在每次页面更改之间重新编译Ja ...
  • 就GoDaddy而言,我猜想这是一个营销事物/把戏。 除了Rails之外,还有其他一些用Ruby编写的框架,例如Sinatra ,你可以在没有框架的情况下编写你的web应用程序(你自己的服务器,完全是你需要它做的)。 尽管如此,包括Rails在内的所有功能都可以称为Ruby hosting 。 Well I would guess it's a marketing thing/trick as far as GoDaddy is concerned. There are other frameworks w ...
  • 将语法上的一种语言翻译成另一种语言的范式几乎总是一种灾难。 你总是试图弯曲PHP来做“ruby / rails方式”,而不是PHP中的正确方法。 相反,清除你对Ruby / Rails所知的一切(除了一般的软件工程原理),读一本书,阅读一些教程,并在YouTube上观看一些“学习PHP”视频。 将它看作完全不同的东西而不是试图进行苹果与苹果的比较,你会发现它变得更容易学习。 最后http://www.php.net是你最大的资源。 The paradigm of translating what you k ...
  • which是一个Unix实用程序,它搜索PATH以查找与您提供的参数匹配的可执行文件,并返回该可执行文件的完整路径。 您可以使用路径中包含的任何可执行文件执行此操作,而不仅仅是Ruby或Rails。 另一方面,当你键入ruby -v ,你实际上是用-v作为命令行参数调用Ruby可执行文件,告诉它返回它的版本。 你总是会得到你当前Ruby的版本。 同样适用于Rails。 Ruby和Rails的切换版本取决于您正在使用的管理工具。 对于RVM (Ruby版本管理器), use ruby 2.5.0将当前版本的R ...

相关文章

更多

最新问答

更多
  • 您如何使用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)