Mongodb启动问题

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

我遇到了mongodb启动问题。我的厨师仓库中有以下代码:

cookbook_file "/etc/yum.repos.d/mongodb-org-4.2.repo" do
  source 'mongodb-org-4.2.repo'
  owner 'root'
  group 'root'
  mode 00644
end

yum_package 'mongodb-org' do
  action :install
  version '4.2.3-1.amzn2'
end

unless node['env']['is_dev']
  execute 'open mongo port' do
    command 'semanage port -a -t mongod_port_t -p tcp 27017'
    action :run
  end
end

Mongodb失败,出现以下错误:

================================================================================
    Error executing action `run` on resource 'execute[open mongo port]'
    ================================================================================
    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of semanage port -a -t mongod_port_t -p tcp 27017 ----
    STDOUT: 
    STDERR: ValueError: Port tcp/27017 already defined
    ---- End output of semanage port -a -t mongod_port_t -p tcp 27017 ----
    Ran semanage port -a -t mongod_port_t -p tcp 27017 returned 1
    Resource Declaration:
    ---------------------
    # In /var/chef/local-mode-cache/cache/cookbooks/spinnaker-edda/recipes/install.rb
     51:   execute 'open mongo port' do
     52:     command 'semanage port -a -t mongod_port_t -p tcp 27017'
     53:     action :run
     54:   end
     55: end

有人可以帮助我了解这里出了什么问题吗?我从文档中了解到mongodb的默认端口为27017。但是我不知道为什么会抱怨。我也尝试使用-m而不是-a,但问题仍然相同。任何帮助深表感谢。

mongodb chef chef-recipe
1个回答
0
投票

尝试避免(如果不是严格要求的话)在目标上手动执行shell命令,但始终首先寻找一些可用的有效食谱,这些食谱可在对不同情况的复杂研究中提供所需的功能。对于您的方案,您可以使用selinux_policy

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