vagrant - CoreOS:flecttl list-machines 显示错误

标签 vagrant service-discovery coreos

我对 CoreOS 还很陌生,我正在尝试使用 official doc使用 Vagrant 创建一个包含 3 个节点的集群。但是,当我访问其中一个节点并执行命令:fleetctl list-machines 输出显示一些错误:

E0729 09:29:05.725714 01013 fleetctl.go:141] error attempting to check latest fleet version in Registry: 501: All the given peers are not reachable (Tried to connect to each peer twice and failed) [0]
Error retrieving list of active machines: 501: All the given peers are not reachable (Tried to connect to each peer twice and failed) [0]

我可以通过代理访问互联网 --> 172.23.1.0:3128

我怀疑发生错误是因为节点无法连接到 https://discovery.etcd.io/2bef6823259cdef6751632f1f7052ff3 但我不确定问题是什么,也不知道如何解决。

我正在使用:

Vagrant -----> 1.6.3

VirtualBox --> 4.3.10_Ubuntu

CoreOS 盒子 --> 367.1.0(稳定)

这些是我的资源文件:

Vagrantfile

# -*- mode: ruby -*-
# # vi: set ft=ruby :

require 'fileutils'

Vagrant.require_version ">= 1.6.0"

CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "user-data")
CONFIG = File.join(File.dirname(__FILE__), "config.rb")

# Defaults for config options defined in CONFIG
$num_instances = 1
$update_channel = "stable"
$enable_serial_logging = false
$vb_gui = false
$vb_memory = 1024
$vb_cpus = 1

# Attempt to apply the deprecated environment variable NUM_INSTANCES to
# $num_instances while allowing config.rb to override it
if ENV["NUM_INSTANCES"].to_i > 0 && ENV["NUM_INSTANCES"]
  $num_instances = ENV["NUM_INSTANCES"].to_i
end

if File.exist?(CONFIG)
  require CONFIG
end

Vagrant.configure("2") do |config|
  config.vm.box = "coreos-%s" % $update_channel
  #config.vm.box_version = ">= 308.0.1"
  config.vm.box_url = "coreos_production_vagrant.box"

  config.vm.provider :vmware_fusion do |vb, override|
      override.vm.box_url = "coreos_production_vagrant.box"
  end

  config.vm.provider :virtualbox do |v|
     v.check_guest_additions = false
     v.functional_vboxsf     = false
     v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
     v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
  end

  # plugin conflict
  if Vagrant.has_plugin?("vagrant-vbguest") then
     config.vbguest.auto_update = false
  end

  (1..$num_instances).each do |i|
    config.vm.define vm_name = "core-%02d" % i do |config|
    config.vm.hostname = vm_name

    if $enable_serial_logging
      logdir = File.join(File.dirname(__FILE__), "log")
      FileUtils.mkdir_p(logdir)

      serialFile = File.join(logdir, "%s-serial.txt" % vm_name)
      FileUtils.touch(serialFile)

      config.vm.provider :vmware_fusion do |v, override|
        v.vmx["serial0.present"] = "TRUE"
        v.vmx["serial0.fileType"] = "file"
        v.vmx["serial0.fileName"] = serialFile
        v.vmx["serial0.tryNoRxLoss"] = "FALSE"
      end

      config.vm.provider :virtualbox do |vb, override|
        vb.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
        vb.customize ["modifyvm", :id, "--uartmode1", serialFile]
      end
    end

    if $expose_docker_tcp
      config.vm.network "forwarded_port", guest: 2375, host: ($expose_docker_tcp + i - 1), auto_correct: true
    end

    config.vm.provider :vmware_fusion do |vb|
      vb.gui = $vb_gui
    end

    config.vm.provider :virtualbox do |vb|
      vb.gui = $vb_gui
      vb.memory = $vb_memory
      vb.cpus = $vb_cpus
    end

    ip = "33.33.33.#{i+100}"
    config.vm.network :private_network, ip: "#{ip}"
    config.vm.synced_folder ".", "/home/core/share", id: "core", :nfs => true, :mount_options => ['nolock,vers=3,udp']

    if File.exist?(CLOUD_CONFIG_PATH)
      config.vm.provision :file, :source => "#{CLOUD_CONFIG_PATH}", :destination => "/tmp/vagrantfile-user-data"
      config.vm.provision :shell, :inline => "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/", :privileged => true
    end

   end
 end
end

用户数据:

#cloud-config

coreos:
  etcd:
      # generate a new token for each unique cluster from https://discovery.etcd.io/new
      # WARNING: replace each time you 'vagrant destroy'
      discovery: https://discovery.etcd.io/2bef6823259cdef6751632f1f7052ff3
      addr: $public_ipv4:4001
      peer-addr: $public_ipv4:7001
  fleet:
      public-ip: $public_ipv4
  units:
    - name: etcd.service
      command: start
    - name: fleet.service
      command: start

config.rb:

# Size of the CoreOS cluster created by Vagrant
$num_instances=3

# Official CoreOS channel from which updates should be downloaded
$update_channel='stable'

最佳答案

最后,我从 github repo 下载了 etcd并通过 IP 地址为 10.10.10.10 的永久主机在后台运行 etcd。然后,受到CoreOS指令的启发,运行your own discovery endpoint ,我在 user-data: 中设置发现地址如下:

discovery: http://10.10.10.10:4001/v2/keys/2bef6823259cdef6751632f1f7052ff3

之后,我可以执行vagrant up,当我检查http://10.10.10.10:4001/v2/keys/2bef6823259cdef6751632f1f7052ff3时,所有CoreOS实例都已注册。

关于vagrant - CoreOS:flecttl list-machines 显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25019355/

相关文章:

vagrant - 我如何在第一次 vagrant up 期间提供个人数据库?

php - Laravel 数据库队列,几秒钟后为 "Killed"

kubernetes - 使用 kubeconfig 在 coreos 上安装 kubernetes(而不是弃用的 --api-server)

logging - kubernetes如何设置日志文件的最大大小?

docker - 在 Vagrant 上安装 docker 的最佳方法

bash - 如何设置 Laravel 安装程序和 Laravel Spark 安装程序的 bash PATH?

embedded - SSDP用于设备发现

.net - Windows 中的 IP 发现

android - 网络服务发现 Android

docker - dnsmasq 跨 docker 容器的奇怪行为