CENTOS 7下failed to listen on TCP port 11211: Address already in use

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CENTOS 7下failed to listen on TCP port 11211: Address already in use相关的知识,希望对你有一定的参考价值。

最近在centos 7下面安装openstack进行测试。

安装到memcached这一步骤时启动服务后查看服务状态报错

系统内核版本:

[[email protected] ~]# uname -a

Linux openstack 3.10.0-514.16.1.el7.x86_64 #1 SMP Wed Apr 12 15:04:24 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

启动memcached服务并查看状态

[[email protected] sysconfig]# systemctl restart  memcached

[[email protected] sysconfig]# systemctl  status memcached

● memcached.service - memcached daemon

   Loaded: loaded (/usr/lib/systemd/system/memcached.service; enabled; vendor preset: disabled)

   Active: failed (Result: exit-code) since Mon 2017-04-24 13:36:10 CST; 8s ago

  Process: 14143 ExecStart=/usr/bin/memcached -p ${PORT} -u ${USER} -m ${CACHESIZE} -c ${MAXCONN} $OPTIONS (code=exited, status=71)

 Main PID: 14143 (code=exited, status=71)


Apr 24 13:36:10 openstack systemd[1]: Started memcached daemon.

Apr 24 13:36:10 openstack systemd[1]: Starting memcached daemon...

Apr 24 13:36:10 openstack memcached[14143]: failed to listen on TCP port 11211: Address already in use

Apr 24 13:36:10 openstack systemd[1]: memcached.service: main process exited, code=exited, status=71/n/a

Apr 24 13:36:10 openstack systemd[1]: Unit memcached.service entered failed state.

Apr 24 13:36:10 openstack systemd[1]: memcached.service failed.

又返回去查看/etc/sysconfig/memcached配置文件

[[email protected] sysconfig]# more memcached

PORT="11211"

USER="memcached"

MAXCONN="1024"

CACHESIZE="64"

OPTIONS="-l 127.0.0.1,openstack"

这么配置发现不行,然后去搜了相关报错内容,根据报错信息,以为是端口被占用,通过netstat -antup命令并没有发现相关端口被占用

[[email protected] sysconfig]# netstat -antup

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    

tcp        0      0 0.0.0.0:4369            0.0.0.0:*               LISTEN      1/systemd           

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      862/sshd            

tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1304/master         

tcp        0      0 0.0.0.0:25672           0.0.0.0:*               LISTEN      12914/beam          

tcp        0      0 192.168.20.143:3306     0.0.0.0:*               LISTEN      12517/mysqld        

tcp        0     52 192.168.20.143:22       192.168.20.210:58818    ESTABLISHED 14292/sshd: [email protected] 

tcp        0      0 127.0.0.1:42502         127.0.0.1:4369          ESTABLISHED 12914/beam          

tcp        0      0 127.0.0.1:4369          127.0.0.1:42502         ESTABLISHED 13000/epmd          

tcp        0      0 192.168.20.143:22       192.168.20.210:53631    ESTABLISHED 11895/sshd: [email protected] 

tcp6       0      0 :::22                   :::*                    LISTEN      862/sshd            

tcp6       0      0 ::1:25                  :::*                    LISTEN      1304/master         

tcp6       0      0 :::5672                 :::*                    LISTEN      12914/beam          

udp        0      0 127.0.0.1:323           0.0.0.0:*                           634/chronyd         

udp6       0      0 ::1:323                 :::*                                634/chronyd         

[[email protected] sysconfig]# 

通过搜索到相关的解决方案,原文地址:

https://serverfault.com/questions/286381/memcached-problems-failed-to-listen-on-tcp-port-11211

大意是memcached绑定到第一个IP地址上面,127.0.0.1与localhost是冲突的,所以偿试绑定到第二块网卡的地址上面,但是我的测试环境里面并没有第二块网卡,所以我就删除了/etc/sysconfig/memcached里面的option行并保存

然后重新启动服务

[[email protected] sysconfig]# systemctl restart memcached

[[email protected] sysconfig]# systemctl status  memcached

● memcached.service - memcached daemon

   Loaded: loaded (/usr/lib/systemd/system/memcached.service; enabled; vendor preset: disabled)

   Active: active (running) since Mon 2017-04-24 13:57:24 CST; 2s ago

 Main PID: 14485 (memcached)

   CGroup: /system.slice/memcached.service

           └─14485 /usr/bin/memcached -p 11211 -u memcached -m 64 -c 1024


Apr 24 13:57:24 openstack systemd[1]: Started memcached daemon.

Apr 24 13:57:24 openstack systemd[1]: Starting memcached daemon...

[[email protected] sysconfig]# 

这样就解决了这个问题

能不能通过添加另一块网卡解决这个问题我还没有测试。


以上是关于CENTOS 7下failed to listen on TCP port 11211: Address already in use的主要内容,如果未能解决你的问题,请参考以下文章

CentOS 7 防火墙 出现Failed to start iptables.service: Unit iptables.service failed to load

解决 RHEL 7/ CentOS 7/Fedora 出现Unit iptables.service failed to load

解决 RHEL 7/ CentOS 7/Fedora 出现Unit iptables.service failed to load

one or more listeners failed to start问题解决思路

CentOS 7告iptables防火墙提示Unit iptables.service failed to load

centos 7.3 错误设置selinux 导致不能启动 Failed to load SELinux policy. Freezing