记录一次etcd报错: listen tcp xxx.xxx.xxx.xxx:2380:bind: cannot assign requested address
bind: cannot assign requested address
·
背景
今天打算在腾讯云环境上安装k8s(采用ansible脚本自动化部署安装),当安装完etcd之后,发现启动报错。
机器:腾讯云服务器(含内外网两个IP)
问题定位
先查看了下etcd服务的状态,采用如下命令:
systemctl status etcd
查询结果如下:
etcd.service - Etcd Server
Loaded: loaded (/etc/systemd/system/etcd.service; disabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: exit-code) since Wed 2022-01-26 13:59:27 CST; 3s ago
Process: 29215 ExecStart=/usr/bin/etcd --data-dir=/var/lib/etcd --name=etcd0 --cert-file=/etc/kubernetes/pki/etcd.pem --key-file=/etc/kubernetes/pki/etcd-key.pem --trusted-ca-file=/etc/kubernetes/pki/ca.pem --peer-cert-file=/etc/kubernetes/pki/etcd.pem --peer-key-file=/etc/kubernetes/pki/etcd-key.pem --peer-trusted-ca-file=/etc/kubernetes/pki/ca.pem --peer-client-cert-auth --client-cert-auth --listen-peer-urls=https://124.223.82.79:2380 --initial-advertise-peer-urls=https://124.223.82.79:2380 --listen-client-urls=https://124.223.82.79:2379,http://127.0.0.1:2379 --advertise-client-urls=https://124.223.82.79:2379 --initial-cluster-token=etcd-cluster-0 --initial-cluster=etcd0=https://124.223.82.79:2380 --initial-cluster-state=new (code=exited, status=1/FAILURE)
Main PID: 29215 (code=exited, status=1/FAILURE)
Jan 26 13:59:27 VM-4-9-centos systemd[1]: etcd.service: main process exited, code=exited, status=1/FAILURE
Jan 26 13:59:27 VM-4-9-centos systemd[1]: Failed to start Etcd Server.
Jan 26 13:59:27 VM-4-9-centos systemd[1]: Unit etcd.service entered failed state.
Jan 26 13:59:27 VM-4-9-centos systemd[1]: etcd.service failed.
发现启动失败,但是看不出具体的报错,因此想着查看下日志:
journalctl -xe |grep etcd
查询如下:
Jan 26 13:53:40 VM-4-9-centos etcd[23453]: Git SHA: 9fd7e2b80
Jan 26 13:53:40 VM-4-9-centos etcd[23453]: Go Version: go1.12.17
Jan 26 13:53:40 VM-4-9-centos etcd[23453]: Go OS/Arch: linux/amd64
Jan 26 13:53:40 VM-4-9-centos etcd[23453]: setting maximum number of CPUs to 2, total number of available CPUs is 2
Jan 26 13:53:40 VM-4-9-centos etcd[23453]: peerTLS: cert = /etc/kubernetes/pki/etcd.pem, key = /etc/kubernetes/pki/etcd-key.pem, ca = , trusted-ca = /etc/kubernetes/pki/ca.pem, client-cert-auth = true, crl-file =
Jan 26 13:53:40 VM-4-9-centos etcd[23453]: listen tcp 124.223.82.79:2380: bind: cannot assign requested address
Jan 26 13:53:40 VM-4-9-centos systemd[1]: etcd.service: main process exited, code=exited, status=1/FAILURE
-- Subject: Unit etcd.service has failed
-- Unit etcd.service has failed.
Jan 26 13:53:40 VM-4-9-centos systemd[1]: Unit etcd.service entered failed state.
Jan 26 13:53:40 VM-4-9-centos systemd[1]: etcd.service failed.
Jan 26 13:53:46 VM-4-9-centos systemd[1]: etcd.service holdoff time over, scheduling restart.
-- Subject: Unit etcd.service has finished shutting down
-- Unit etcd.service has finished shutting down.
-- Subject: Unit etcd.service has begun start-up
-- Unit etcd.service has begun starting up.
Jan 26 13:53:46 VM-4-9-centos etcd[23548]: etcd Version: 3.3.20
Jan 26 13:53:46 VM-4-9-centos etcd[23548]: Git SHA: 9fd7e2b80
Jan 26 13:53:46 VM-4-9-centos etcd[23548]: Go Version: go1.12.17
Jan 26 13:53:46 VM-4-9-centos etcd[23548]: Go OS/Arch: linux/amd64
Jan 26 13:53:46 VM-4-9-centos etcd[23548]: setting maximum number of CPUs to 2, total number of available CPUs is 2
Jan 26 13:53:46 VM-4-9-centos etcd[23548]: peerTLS: cert = /etc/kubernetes/pki/etcd.pem, key = /etc/kubernetes/pki/etcd-key.pem, ca = , trusted-ca = /etc/kubernetes/pki/ca.pem, client-cert-auth = true, crl-file =
Jan 26 13:53:46 VM-4-9-centos etcd[23548]: listen tcp 124.223.82.79:2380: bind: cannot assign requested address
Jan 26 13:53:46 VM-4-9-centos systemd[1]: etcd.service: main process exited, code=exited, status=1/FAILURE
-- Subject: Unit etcd.service has failed
-- Unit etcd.service has failed.
Jan 26 13:53:46 VM-4-9-centos systemd[1]: Unit etcd.service entered failed state.
Jan 26 13:53:46 VM-4-9-centos systemd[1]: etcd.service failed.
Jan 26 13:53:51 VM-4-9-centos systemd[1]: etcd.service holdoff time over, scheduling restart.
-- Subject: Unit etcd.service has finished shutting down
-- Unit etcd.service has finished shutting down.
-- Subject: Unit etcd.service has begun start-up
-- Unit etcd.service has begun starting up.
其中很重要的一句便是:
Jan 26 13:53:46 VM-4-9-centos etcd[23548]: listen tcp 124.223.82.79:2380: bind: cannot assign requested address
Jan 26 13:53:46 VM-4-9-centos systemd[1]: etcd.service: main process exited, code=exited, status=1/FAILURE
错误提示地址绑定失败,考虑两个地方:
① 端口被占用了
② IP地址不对(或者说网卡上没有使用的IP)
问题排查
先考虑检查端口,命令如下
netstat -anp|grep 2380
检查后发现端口并未占用,接下来就只能考虑IP的问题了
ip a
发现网卡绑定上并没有我使用的【公网IP】,自然也监听不到了
解决方案
- 修改etcd.service文件,路径一般为 /etc/systemd/system/etcd.service
vi /etc/systemd/system/etcd.service
将文件内的公网IP地址全部换成内网IP地址
修改完文件后执行如下命令
systemctl daemon-reload
systemctl restart etcd
查看状态
systemctl status etcd
小结
- 在使用腾讯云、华为云这种云环境时,配置选用内网IP
- 除etcd外,若其他组件在云环境中遇到bind: cannot assign requested address也可从这两方面(端口、IP)入手查看
更多推荐
已为社区贡献1条内容
所有评论(0)