使用sc-mongodb的Chef MongoDB Replication

问题描述 投票:0回答:1

我是厨师的新手,我正在使用sc-mongodb,我无法让它工作。是否有更好的方法与厨师一起为MongoDB进行复制?

我能够使默认配方正常工作

include_recipe "sc-mongodb::default"

但是当我尝试为mongo进行复制时,我开始遇到一些奇怪的错误。

include_recipe "sc-mongodb::replicaset"

错误:

 ================================================================================
   Recipe Compile Error in /tmp/kitchen/cache/cookbooks/c_mongo/recipes/default.rb
   ================================================================================

   Net::HTTPServerException
   ------------------------
   400 "Bad Request"

   Cookbook Trace:
   ---------------
     /tmp/kitchen/cache/cookbooks/sc-mongodb/definitions/mongodb.rb:236:in `block in from_file'
     /tmp/kitchen/cache/cookbooks/sc-mongodb/recipes/replicaset.rb:36:in `from_file'
     /tmp/kitchen/cache/cookbooks/c_mongo/recipes/default.rb:54:in `from_file'

   Relevant File Content:
   ----------------------
   /tmp/kitchen/cache/cookbooks/sc-mongodb/definitions/mongodb.rb:

   229:      notifies :run, 'ruby_block[config_sharding]', :immediately if new_resource.is_mongos && new_resource.auto_configure_sharding
   230:      # we don't care about a running mongodb service in these cases, all we need is stopping it
   231:      ignore_failure true if new_resource.name == 'mongodb'
   232:    end
   233:
   234:    # replicaset
   235:    if new_resource.is_replicaset && new_resource.auto_configure_replicaset
   236>>     rs_nodes = search(
   237:        :node,
   238:        "mongodb_cluster_name:#{new_resource.cluster_name} AND "\
   239:        'mongodb_is_replicaset:true AND '\
   240:        "mongodb_config_mongod_replication_replSetName:#{new_resource.replicaset_name} AND "\
   241:        "chef_environment:#{node.chef_environment}"
   242:      )
   243:
   244:      ruby_block 'config_replicaset' do
   245:        block do

   System Info:
   ------------
   chef_version=13.8.5
   platform=centos
   platform_version=7.4.1708
   ruby=ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]
   program_name=chef-client worker: ppid=28997;start=00:31:33;
   executable=/opt/chef/bin/chef-client


   Running handlers:
   [2018-03-27T00:31:35+00:00] ERROR: Running exception handlers
   Running handlers complete
   [2018-03-27T00:31:35+00:00] ERROR: Exception handlers complete
   Chef Client failed. 0 resources updated in 01 seconds
   [2018-03-27T00:31:35+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
   [2018-03-27T00:31:35+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
   [2018-03-27T00:31:35+00:00] ERROR: 400 "Bad Request"
   [2018-03-27T00:31:35+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

我已经尝试了很多方法来解决这个问题,从github存储库查看issues。从错误中看,属性没有设置,因此人们手动设置它们。 :

# attempt1------------

#node.default['mongodb']['config']['replSet'] = true
#node.default[:mongodb][:cluster_name] = "repl-name"
#include_recipe "sc-mongodb::replicaset"

# attempt2----------

#node.normal['mongodb']['install_method'] = 'mongodb-org'
#node.normal['mongodb']['config']['bind_ip'] = '0.0.0.0'
#node.normal['mongodb']['dbconfig_file'] = '/etc/mongod.conf'
#node.normal['mongodb']['config']['replSet'] = true
#node.normal['mongodb']['is_replicaset'] = true
#node.normal['mongodb']['cluster_name'] = 'scribe'
#node.normal['mongodb']['replSet'] = 'scribe'
#node.normal['mongodb']['is_shard'] = false
#include_recipe "sc-mongodb::replicaset"

#attempt3------------
#node.default[:mongodb][:cluster_name] = "cluster_name"
#include_recipe "sc-mongodb::replicaset"

#attempt4------------

#if node['mongodb']['config']['replSet'].nil?
#  node.default['mongodb']['config']['replSet'] = "repl-name"
#end
#include_recipe "sc-mongodb::replicaset"

#attempt5-------------

#https://github.com/sous-chefs/mongodb/issues/167
#node.default['mongodb']['config']['mongod']['replication']['replSetName'] = "rs-name"
#include_recipe "sc-mongodb::replicaset"

这个给了我一个不同的错误:

#attempt6-----------
node.default['mongodb']['config']['mongod']['replication']['replSetName']= 'rs_default'
node.default['mongodb']['cluster_name'] = 'cluster'
node.default['mongodb']['auto_configure']['replicaset'] = true
include_recipe "sc-mongodb::replicaset"

堆栈跟踪:

           ================================================================================
       Error executing action `run` on resource 'ruby_block[config_replicaset]'
       ================================================================================

       NoMethodError
       -------------
       undefined method `[]' for nil:NilClass

       Cookbook Trace:
       ---------------
       /tmp/kitchen/cache/cookbooks/sc-mongodb/libraries/mongodb.rb:74:in `configure_replicaset'
       /tmp/kitchen/cache/cookbooks/sc-mongodb/definitions/mongodb.rb:246:in `block (3 levels) in from_file'

       Resource Declaration:
       ---------------------
       # In /tmp/kitchen/cache/cookbooks/sc-mongodb/definitions/mongodb.rb

       244:     ruby_block 'config_replicaset' do
       245:       block do
       246:         MongoDB.configure_replicaset(node, replicaset_name, rs_nodes) unless new_resource.replicaset.nil?
       247:       end
       248:       action :nothing
       249:     end
       250:

       Compiled Resource:
       ------------------
       # Declared in /tmp/kitchen/cache/cookbooks/sc-mongodb/definitions/mongodb.rb:244:in `block in from_file'

       ruby_block("config_replicaset") do
         params {:mongodb_type=>"mongod", :action=>[:enable, :start], :logpath=>"/var/log/mongodb/mongod.log", :configservers=>[], :replicaset=>true, :notifies=>[], :not_if=>[], :name=>"mongod"}
         action [:nothing]
         retries 0
         retry_delay 2
         default_guard_interpreter :default
         block_name "config_replicaset"
         declared_type :ruby_block
         cookbook_name "sc-mongodb"
         recipe_name "replicaset"
         block #<Proc:0x00000003ebdec8@/tmp/kitchen/cache/cookbooks/sc-mongodb/definitions/mongodb.rb:245>
       end

       Platform:
       ---------
       x86_64-linux
mongodb chef cookbook
1个回答
0
投票

这本食谱我遇到了很多麻烦,你并不孤单。

根据我收集的内容,您需要多次运行此烹饪书和/或以不同的配置运行,具体取决于您要实现的目标或节点的状态。例如,我认为auto_configure属性只应设置为在其他节点被设置为false的情况下被裁掉之后,集合中的最后一个节点。类似地,对于他们的用户配方,mongodb仅允许在主服务器上执行admin coll操作,因此您应该确保在指定的主节点上执行此配方。

不幸的是,文档并不清楚,对于像我这样的新手Chef和Ruby,src和错误很难解释。我仍然在弄清楚这本食谱,并且可以报告我是否有具体的东西可以给你,你的帖子以后你能够得到这个吗?抱歉,我无法提供更多帮助,您必须尝试使用​​测试厨房VM进行配置。

© www.soinside.com 2019 - 2024. All rights reserved.