每次我重启服务器时,都会出现与 cloud-init 相关的错误,导致启动速度减慢 5 分钟。这个错误来自哪里?我该如何修复?
[ 5.458859] cloud-init[869]: Cloud-init v. 22.1-14-g2e17a0d6-0ubuntu1~20.04.3 running 'init-local' at Sat, 09 Apr 2022 03:53:54 +0000. Up 5.34 seconds.
[ 5.461936] cloud-init[869]: 2022-04-09 03:53:54,863 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [0/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 6.460323] cloud-init[869]: 2022-04-09 03:53:55,864 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [1/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 7.462202] cloud-init[869]: 2022-04-09 03:53:56,866 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [2/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 8.463907] cloud-init[869]: 2022-04-09 03:53:57,868 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [3/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 9.466026] cloud-init[869]: 2022-04-09 03:53:58,870 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [4/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 10.467623] cloud-init[869]: 2022-04-09 03:53:59,871 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [5/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 12.470406] cloud-init[869]: 2022-04-09 03:54:01,874 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [7/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 14.472911] cloud-init[869]: 2022-04-09 03:54:03,877 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [9/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 16.475218] cloud-init[869]: 2022-04-09 03:54:05,879 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [11/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 18.478773] cloud-init[869]: 2022-04-09 03:54:07,883 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [13/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 20.481622] cloud-init[869]: 2022-04-09 03:54:09,885 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [15/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 23.485339] cloud-init[869]: 2022-04-09 03:54:12,889 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [18/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 26.489060] cloud-init[869]: 2022-04-09 03:54:15,893 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [21/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 29.492793] cloud-init[869]: 2022-04-09 03:54:18,896 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [24/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 32.496441] cloud-init[869]: 2022-04-09 03:54:21,900 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [27/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 35.499969] cloud-init[869]: 2022-04-09 03:54:24,904 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [30/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 39.505595] cloud-init[869]: 2022-04-09 03:54:28,909 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [34/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 43.510386] cloud-init[869]: 2022-04-09 03:54:32,914 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [38/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 47.516312] cloud-init[869]: 2022-04-09 03:54:36,919 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [42/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 51.520940] cloud-init[869]: 2022-04-09 03:54:40,925 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [46/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 55.526099] cloud-init[869]: 2022-04-09 03:54:44,929 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [50/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 60.531079] cloud-init[869]: 2022-04-09 03:54:49,935 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [55/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 65.536969] cloud-init[869]: 2022-04-09 03:54:54,941 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [60/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 70.543584] cloud-init[869]: 2022-04-09 03:54:59,947 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [65/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 75.549952] cloud-init[869]: 2022-04-09 03:55:04,953 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [70/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 80.554855] cloud-init[869]: 2022-04-09 03:55:09,959 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [75/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 86.561869] cloud-init[869]: 2022-04-09 03:55:15,965 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [81/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 92.568689] cloud-init[869]: 2022-04-09 03:55:21,972 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [87/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 98.575353] cloud-init[869]: 2022-04-09 03:55:27,979 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [93/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 104.581833] cloud-init[869]: 2022-04-09 03:55:33,986 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [99/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 110.589199] cloud-init[869]: 2022-04-09 03:55:39,992 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [105/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 117.596895] cloud-init[869]: 2022-04-09 03:55:47,000 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [112/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 124.604726] cloud-init[869]: 2022-04-09 03:55:54,008 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [119/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 131.612012] cloud-init[869]: 2022-04-09 03:56:01,016 - DataSourceEc2.py[WARNING]: IMDS's HTTP endpoint is probably disabled
[[0;32m OK [0m] Finished [0;1;39mInitial cloud-init job (pre-networking)[0m.
[[0;32m OK [0m] Reached target [0;1;39mNetwork (Pre)[0m.
Starting [0;1;39mNetwork Service[0m...
[[0;32m OK [0m] Started [0;1;39mNetwork Service[0m.
Starting [0;1;39mWait for Network to be Configured[0m...
Starting [0;1;39mNetwork Name Resolution[0m...
[[0;32m OK [0m] Started [0;1;39mNetwork Name Resolution[0m.
[[0;32m OK [0m] Reached target [0;1;39mNetwork[0m.
[[0;32m OK [0m] Reached target [0;1;39mHost and Network Name Lookups[0m.
[[0;32m OK [0m] Finished [0;1;39mWait for Network to be Configured[0m.
Starting [0;1;39mInitial cloud-ini… (metadata service crawler)[0m...
[ 134.126690] cloud-init[922]: Cloud-init v. 22.1-14-g2e17a0d6-0ubuntu1~20.04.3 running 'init' at Sat, 09 Apr 2022 03:56:03 +0000. Up 134.08 seconds.
[ 134.129254] cloud-init[922]: ci-info: +++++++++++++++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++++++++++++++
[ 134.131165] cloud-init[922]: ci-info: +--------+------+------------------------------+---------------+--------+-------------------+
[ 134.133074] cloud-init[922]: ci-info: | Device | Up | Address | Mask | Scope | Hw-Address |
[ 134.135367] cloud-init[922]: ci-info: +--------+------+------------------------------+---------------+--------+-------------------+
[ 134.137354] cloud-init[922]: ci-info: | ens5 | True | 172.31.72.80 | 255.255.240.0 | global | 16:86:10:06:d1:7b |
[ 134.139201] cloud-init[922]: ci-info: | ens5 | True | fe80::1486:10ff:fe06:d17b/64 | . | link | 16:86:10:06:d1:7b |
[ 134.141148] cloud-init[922]: ci-info: | lo | True | 127.0.0.1 | 255.0.0.0 | host | . |
[ 134.143015] cloud-init[922]: ci-info: | lo | True | ::1/128 | . | host | . |
[ 134.144955] cloud-init[922]: ci-info: +--------+------+------------------------------+---------------+--------+-------------------+
[ 134.146804] cloud-init[922]: ci-info: ++++++++++++++++++++++++++++++Route IPv4 info++++++++++++++++++++++++++++++
[ 134.148558] cloud-init[922]: ci-info: +-------+-------------+-------------+-----------------+-----------+-------+
[ 134.150148] cloud-init[922]: ci-info: | Route | Destination | Gateway | Genmask | Interface | Flags |
[ 134.151882] cloud-init[922]: ci-info: +-------+-------------+-------------+-----------------+-----------+-------+
[ 134.153532] cloud-init[922]: ci-info: | 0 | 0.0.0.0 | 172.31.64.1 | 0.0.0.0 | ens5 | UG |
[ 134.155166] cloud-init[922]: ci-info: | 1 | 172.31.64.0 | 0.0.0.0 | 255.255.240.0 | ens5 | U |
[ 134.156870] cloud-init[922]: ci-info: | 2 | 172.31.64.1 | 0.0.0.0 | 255.255.255.255 | ens5 | UH |
[ 134.158488] cloud-init[922]: ci-info: +-------+-------------+-------------+-----------------+-----------+-------+
[ 134.160173] cloud-init[922]: ci-info: +++++++++++++++++++Route IPv6 info+++++++++++++++++++
[ 134.161483] cloud-init[922]: ci-info: +-------+-------------+---------+-----------+-------+
[ 134.162778] cloud-init[922]: ci-info: | Route | Destination | Gateway | Interface | Flags |
[ 134.164191] cloud-init[922]: ci-info: +-------+-------------+---------+-----------+-------+
[ 134.165499] cloud-init[922]: ci-info: | 1 | fe80::/64 | :: | ens5 | U |
[ 134.166837] cloud-init[922]: ci-info: | 3 | local | :: | ens5 | U |
[ 134.168247] cloud-init[922]: ci-info: | 4 | multicast | :: | ens5 | U |
[ 134.169557] cloud-init[922]: ci-info: +-------+-------------+---------+-----------+-------+
[ 134.170885] cloud-init[922]: 2022-04-09 03:56:03,530 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [0/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 135.128814] cloud-init[922]: 2022-04-09 03:56:04,532 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [1/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 136.130722] cloud-init[922]: 2022-04-09 03:56:05,534 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [2/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 137.132591] cloud-init[922]: 2022-04-09 03:56:06,536 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [3/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 138.134159] cloud-init[922]: 2022-04-09 03:56:07,538 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [4/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 139.136039] cloud-init[922]: 2022-04-09 03:56:08,540 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [5/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 141.138877] cloud-init[922]: 2022-04-09 03:56:10,543 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [7/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 143.141259] cloud-init[922]: 2022-04-09 03:56:12,545 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [9/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 145.144132] cloud-init[922]: 2022-04-09 03:56:14,548 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [11/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 147.146866] cloud-init[922]: 2022-04-09 03:56:16,550 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [13/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 149.149246] cloud-init[922]: 2022-04-09 03:56:18,553 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [15/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 152.152800] cloud-init[922]: 2022-04-09 03:56:21,556 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [18/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 155.156223] cloud-init[922]: 2022-04-09 03:56:24,560 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [21/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 158.160763] cloud-init[922]: 2022-04-09 03:56:27,565 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [24/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 161.164337] cloud-init[922]: 2022-04-09 03:56:30,568 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [27/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 164.168144] cloud-init[922]: 2022-04-09 03:56:34,122 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [30/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 168.172608] cloud-init[922]: 2022-04-09 03:56:38,126 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [34/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 172.177107] cloud-init[922]: 2022-04-09 03:56:42,131 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [38/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 176.181797] cloud-init[922]: 2022-04-09 03:56:46,135 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [42/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 180.186514] cloud-init[922]: 2022-04-09 03:56:50,140 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [46/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 184.191532] cloud-init[922]: 2022-04-09 03:56:54,145 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [50/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 189.196838] cloud-init[922]: 2022-04-09 03:56:59,150 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [55/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 194.202670] cloud-init[922]: 2022-04-09 03:57:04,156 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [60/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 199.208055] cloud-init[922]: 2022-04-09 03:57:09,162 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [65/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 204.213959] cloud-init[922]: 2022-04-09 03:57:14,167 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [70/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 209.219749] cloud-init[922]: 2022-04-09 03:57:19,173 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [75/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 215.226638] cloud-init[922]: 2022-04-09 03:57:25,180 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [81/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 221.233325] cloud-init[922]: 2022-04-09 03:57:31,187 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [87/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 227.239863] cloud-init[922]: 2022-04-09 03:57:37,194 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [93/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 233.246984] cloud-init[922]: 2022-04-09 03:57:43,200 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [99/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 239.253433] cloud-init[922]: 2022-04-09 03:57:49,207 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [105/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 246.261211] cloud-init[922]: 2022-04-09 03:57:56,215 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [112/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 253.268705] cloud-init[922]: 2022-04-09 03:58:03,222 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/latest/api/token' failed [119/120s]: request error [Failed to parse: http://169.254.169.254/latest/api/token]
[ 260.276007] cloud-init[922]: 2022-04-09 03:58:10,229 - DataSourceEc2.py[WARNING]: IMDS's HTTP endpoint is probably disabled
[[0;32m OK [0m] Finished [0;1;39mInitial cloud-ini…ob (metadata service crawler)[0m.
[[0;32m OK [0m] Reached target [0;1;39mCloud-config availability[0m.
[[0;32m OK [0m] Reached target [0;1;39mNetwork is Online[0m.
[[0;32m OK [0m] Reached target [0;1;39mSystem Initialization[0m.
我的 EC2 VM 版本是 Ubuntu 20.04.4 LTS(GNU/Linux 5.13.0-1021-aws x86_64)
答案1
它正在尝试通过云初始化服务访问一些元数据,但无法访问元数据服务,因此它继续尝试所有条目。您可以在以下文件中禁用云初始化服务:
/etc/cloud/cloud.cfg.d/90_dpkg.cfg
使用以下命令使其指向无任何内容:
echo 'datasource_list: [ None ]' | sudo -s tee /etc/cloud/cloud.cfg.d/90_dpkg.cfg
然后执行以下操作,以重新配置云初始化包:
sudo dpkg-reconfigure -f noninteractive cloud-init
但是如果您想恢复其默认值,可以使用以下命令:
sudo rm /etc/cloud/cloud.cfg.d/90_dpkg.cfg
sudo dpkg-reconfigure -f noninteractive cloud-init
答案2
在您的 EC2 实例的 cloud-init 配置中,某些命令正在尝试获取可能用于必要功能的令牌,但元数据似乎在您的 ec2 实例上被禁用。
您可以通过以下命令从您的 ec2 实例验证元数据是否已启用。
curl -v http://169.254.169.254/latest/meta-data/
如果它没有提供任何实例元数据,它将被禁用。您可以使用 aws ec2 命令行工具通过以下命令启用它。
aws ec2 modify-instance-metadata-options --instance-id {{instance_id}} --http-endpoint enabled
验证元数据是否再次启用,以及 cloud-init 命令是否能获取令牌。此后,启动实例不会花费太多时间。