Cloud-init 未找到元数据服务器(Openstack)

Cloud-init 未找到元数据服务器(Openstack)

我试图了解为什么我的服务器无法连接到元数据服务器(因此无法使用 SSH 密钥登录)。

网上类似的问题似乎是由安全组问题,我相信这不是这里的问题。

它是一台单主机,IP 为192.168.160.100。客户机被赋予一个固定 IP 10.225.134.63。网络在 处有一个 neutron DHCP 服务器10.225.134.64

在主机上,我运行了以下命令,

# curl http://192.168.160.100:8775
1.0
...
2008-09-01
2009-04-04

# curl http://169.254.169.254
curl: (7) Failed connect to 169.254.169.254:80; No route to host

/etc/neutron/metadata_agent.ini

nova_metadata_ip = 192.168.160.100

/etc/nova/nova.conf

metadata_host=192.168.160.100

启动日志

cloud-init[827]: Cloud-init v. 0.7.5 running 'init' at Fri, 29 Sep 2017 09:50:08 +0000. Up 6.40 seconds.
cloud-init[827]: ci-info: +++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++
cloud-init[827]: ci-info: +--------+------+---------------+---------------+-------------------+
cloud-init[827]: ci-info: | Device |  Up  |    Address    |      Mask     |     Hw-Address    |
cloud-init[827]: ci-info: +--------+------+---------------+---------------+-------------------+
cloud-init[827]: ci-info: |  lo:   | True |   127.0.0.1   |   255.0.0.0   |         .         |
cloud-init[827]: ci-info: | eth0:  | True | 10.225.134.63 | 255.255.240.0 | fa:16:3e:0b:36:43 |
cloud-init[827]: ci-info: +--------+------+---------------+---------------+-------------------+
cloud-init[827]: ci-info: ++++++++++++++++++++++++++++++++Route info+++++++++++++++++++++++++++++++++
cloud-init[827]: ci-info: +-------+--------------+--------------+---------------+-----------+-------+
cloud-init[827]: ci-info: | Route | Destination  |   Gateway    |    Genmask    | Interface | Flags |
cloud-init[827]: ci-info: +-------+--------------+--------------+---------------+-----------+-------+
cloud-init[827]: ci-info: |   0   |   0.0.0.0    | 10.225.128.1 |    0.0.0.0    |    eth0   |   UG  |
cloud-init[827]: ci-info: |   1   | 10.225.128.0 |   0.0.0.0    | 255.255.240.0 |    eth0   |   U   |
cloud-init[827]: ci-info: +-------+--------------+--------------+---------------+-----------+-------+

cloud-init[827]: url_helper.py[WARNING]: Calling 'http://169.254.169.254/2009-04-04/meta-data/instance-id' failed [50/120s]: unexpected error ['NoneType' object has no attribute 'status_code']
cloud-init[827]: url_helper.py[WARNING]: Calling 'http://169.254.169.254/2009-04-04/meta-data/instance-id' failed [101/120s]: unexpected error ['NoneType' object has no attribute 'status_code']
cloud-init[827]: url_helper.py[WARNING]: Calling 'http://169.254.169.254/2009-04-04/meta-data/instance-id' failed [119/120s]: unexpected error ['NoneType' object has no attribute 'status_code']
cloud-init[827]: DataSourceEc2.py[CRITICAL]: Giving up on md from ['http://169.254.169.254/2009-04-04/meta-data/instance-id'] after 120 seconds
cloud-init[827]: url_helper.py[WARNING]: Calling 'http://10.225.134.64//latest/meta-data/instance-id' failed [0/120s]: unexpected error ['NoneType' object has no attribute 'status_code']
cloud-init[827]: url_helper.py[WARNING]: Calling 'http://10.225.134.64//latest/meta-data/instance-id' failed [1/120s]: unexpected error ['NoneType' object has no attribute 'status_code']
cloud-init[827]: url_helper.py[WARNING]: Calling 'http://10.225.134.64//latest/meta-data/instance-id' failed [2/120s]: unexpected error ['NoneType' object has no attribute 'status_code']
...
cloud-init[827]: url_helper.py[WARNING]: Calling 'http://10.225.134.64//latest/meta-data/instance-id' failed [119/120s]: unexpected error ['NoneType' object has no attribute 'status_code']
cloud-init[827]: DataSourceCloudStack.py[CRITICAL]: Giving up on waiting for the metadata from   ['http://10.225.134.64//latest/meta-data/instance-id'] after 126 seconds

答案1

事实证明,管理网络命名空间中缺少一些路由。使用以下命令添加了它们。

# Where,
#  Management network ID = qdhcp-88d57d45-e9y4-4b4c-ae8a-4d5d6654e7fa
#  Management network device = tap54ff6yfd-fb
#    from `sudo ip netns exec qdhcp-88d57d45-e9y4-4b4c-ae8a-4d5d6654e7fa ip addr`
sudo ip netns exec qdhcp-88d57d45-e9y4-4b4c-ae8a-4d5d6654e7fa ip route add 169.254.0.0/16 dev  tap54ff6yfd-fb  proto kernel  scope link  src 169.254.169.254
sudo ip netns exec qdhcp-88d57d45-e9y4-4b4c-ae8a-4d5d6654e7fa ip addr add 169.254.169.254/16 brd 169.254.255.255 scope global dev tap54ff6yfd-fb

答案2

我也遇到了同样的问题,因此尝试重新启动实例,一段时间后,在路由 Ipv4 信息中,我能够识别实例尝试获取元数据的第三个目的地。这不是问题的确切解决方案,而是一种替代方案。

[ 131.326590] cloud-init[548]: Cloud-init v. 18.4-0ubuntu1~16.04.2 running 'init' at Thu, 29 Nov 2018 13:01:17 +0000. Up 104.95 seconds. [ 131.373908] cloud-init[548]: ci-info: +++++++++++++++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++++++++++++++ [ 131.398661] cloud-init[548]: ci-info: +--------+-------+------------------------------+---------------+--------+-------------------+ [ 131.419546] cloud-init[548]: ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | [ 131.515524] cloud-init[548]: ci-info: +--------+-------+------------------------------+---------------+--------+-------------------+ [ 131.567586] cloud-init[548]: ci-info: | ens3 | True | 20.0.0.9 | 255.255.255.0 | global | fa:16:3e:fb:ba:81 | [ 131.595173] cloud-init[548]: ci-info: | ens3 | True | fe80::f816:3eff:fefb:ba81/64 | . | link | fa:16:3e:fb:ba:81 | [ 131.621358] cloud-init[548]: ci-info: | lo | True | 127.0.0.1 | 255.0.0.0 | host | . | [ 131.652707] cloud-init[548]: ci-info: | lo | True | ::1/128 | . | host | . | [ 131.681617] cloud-init[548]: ci-info: | sit0 | False | . | . | . | . | [ 131.716687] cloud-init[548]: ci-info: | tunl0 | False | . | . | . | . | [ 131.747621] cloud-init[548]: ci-info: +--------+-------+------------------------------+---------------+--------+-------------------+ [ 131.828146] cloud-init[548]: ci-info: ++++++++++++++++++++++++++++++Route IPv4 info+++++++++++++++++++++++++++++++ [ 131.891154] cloud-init[548]: ci-info: +-------+-----------------+----------+-----------------+-----------+-------+ [ 131.912601] cloud-init[548]: ci-info: | Route | Destination | Gateway | Genmask | Interface | Flags | [ 131.935481] cloud-init[548]: ci-info: +-------+-----------------+----------+-----------------+-----------+-------+ [ 131.981100] cloud-init[548]: ci-info: | 0 | 0.0.0.0 | 20.0.0.1 | 0.0.0.0 | ens3 | UG | [ 132.029476] cloud-init[548]: ci-info: | 1 | 20.0.0.0 | 0.0.0.0 | 255.255.255.0 | ens3 | U | [ 132.058772] cloud-init[548]: ci-info: | 2 | 169.254.169.254 | 20.0.0.1 | 255.255.255.255 | ens3 | UGH | [ 132.097319] cloud-init[548]: ci-info: +-------+-----------------+----------+-----------------+-----------+-------+ [ 132.126704] cloud-init[548]: ci-info: +++++++++++++++++++Route IPv6 info+++++++++++++++++++ [ 132.154971] cloud-init[548]: ci-info: +-------+-------------+---------+-----------+-------+ [ 132.179131] cloud-init[548]: ci-info: | Route | Destination | Gateway | Interface | Flags | [ 132.211508] cloud-init[548]: ci-info: +-------+-------------+---------+-----------+-------+ [ 132.219367] cloud-init[548]: ci-info: | 0 | fe80::/64 | :: | ens3 | U | [ 132.259315] cloud-init[548]: ci-info: | 4 | ff00::/8 | :: | ens3 | U | [ 132.283589] cloud-init[548]: ci-info: +-------+-------------+---------+-----------+-------+ [ 132.311049] cloud-init[548]: Generating public/private rsa key pair. [ 132.318065] cloud-init[548]: Your identification has been saved in /etc/ssh/ssh_host_rsa_key. [ 132.327114] cloud-init[548]: Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub. [ 132.364865] cloud-init[548]: The key fingerprint is: [ 132.378265] cloud-init[548]: SHA256:IhhdlSjJqLvj6PGiwTxA+SX7HbTHc4nSKBkqSIY3ye4 root@test1 [ 132.405438] cloud-init[548]: The key's randomart image is:

相关内容