Port

RHEL6:httpd 無法綁定到埠

  • October 9, 2017

我們有 RHEL 6.5 伺服器作為本地 YUM 伺服器,並為此目的使用 httpd。它在 6809 埠上執行。直到昨天它執行良好。我的一位同事正在不同的伺服器上進行一些額外的部署,該伺服器應該使用 YUM 伺服器,但 yum 無法連接。他承認,他也在 YUM 伺服器上做一些工作,但他不知道做一些與 httpd 配置相關的事情。

所以我們意識到YUM伺服器上的httpd沒有執行並且拒絕啟動:

# service httpd start
Starting httpd: (98)Address already in use: make_sock: could not bind to address 172.29.84.41:6809
no listening sockets available, shutting down
Unable to open logs
                                                          [FAILED]

我們已經檢查了埠 6809 沒有被 lsof 和 netstat 佔用:

lsof -iTCP -sTCP:LISTEN -P -n

netstat -tupan | grep -Ei LISTEN

一切都清楚,沒有其他過程。

我們還在 /etc/httpd 目錄中搜尋了 Listen ,並且只有一個帶有 6809 埠的指令:

httpd# grep -Ri listen *
conf/httpd.conf:# Listen: Allows you to bind Apache to specific IP addresses and/or
conf/httpd.conf:# Change this to Listen on specific IP addresses as shown below to
conf/httpd.conf:#Listen 12.34.56.78:80
conf/httpd.conf:#Listen 80
conf.d/ssl.conf:# When we also provide SSL we have to listen to the
conf.d/ssl.conf:#Listen 443
conf.d/yum.conf:Listen yum-server:6809
logs/test.log:read(4, "Listen yum-server:6809\nServe"..., 4096) = 496
logs/test.log:listen(3, 511)                          = 0
logs/test.log:write(2, "no listening sockets available, "..., 46no listening sockets available, shutting down
Binary file modules/mod_info.so matches
Binary file modules/mod_wsgi.so matches
Binary file modules/mod_proxy_ftp.so matches
Binary file modules/mod_cgid.so matches

所以它不是重複的。

IP 是伺服器本地的。

也沒有 httpd 程序正在執行。

我們還重新安裝了 httpd RPM。

SELinux 沒有執行:

# sestatus
SELinux status:                 disabled

請問,還有什麼問題嗎?

非常感謝您的建議。

添加2:

致@André Fernandes:

# lsof -n -P -i :6809
# find /etc/httpd -type f | xargs grep Listen
/etc/httpd/conf.d/ssl.conf:#Listen 443
/etc/httpd/conf.d/yum.conf:Listen yum-server:6809
/etc/httpd/conf/httpd.conf:# Listen: Allows you to bind Apache to specific IP addresses and/or
/etc/httpd/conf/httpd.conf:# Change this to Listen on specific IP addresses as shown below to
/etc/httpd/conf/httpd.conf:#Listen 12.34.56.78:80
/etc/httpd/conf/httpd.conf:#Listen 80

對於@MadHatter,我縮短了輸出並刪除了真實姓名。但是別名 yum_server 在那裡:

# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.somewhe.re localhost trap-host
172.29.84.41    <FQDN and name> yum-server <other aliases>
...

添加3:

ip addr 顯示輸出:

# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
   inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP qlen 1000
   link/ether 3c:4a:92:ed:c0:28 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP qlen 1000
   link/ether 3c:4a:92:ed:c0:28 brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond1 state UP qlen 1000
   link/ether 68:b5:99:c6:42:4c brd ff:ff:ff:ff:ff:ff
5: eth3: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond1 state UP qlen 1000
   link/ether 68:b5:99:c6:42:4c brd ff:ff:ff:ff:ff:ff
6: eth4: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond2 state UP qlen 1000
   link/ether 68:b5:99:c6:42:4e brd ff:ff:ff:ff:ff:ff
7: eth5: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond2 state UP qlen 1000
   link/ether 68:b5:99:c6:42:4e brd ff:ff:ff:ff:ff:ff
8: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
   link/ether 3c:4a:92:ed:c0:28 brd ff:ff:ff:ff:ff:ff
   inet 172.29.84.41/26 brd 172.29.84.63 scope global bond0
9: bond1: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
   link/ether 68:b5:99:c6:42:4c brd ff:ff:ff:ff:ff:ff
   inet 192.168.1.1/24 brd 192.168.1.255 scope global bond1
10: bond2: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
   link/ether 68:b5:99:c6:42:4e brd ff:ff:ff:ff:ff:ff
   inet 10.1.212.71/24 brd 10.1.212.255 scope global bond2

我們找到了原因。它隱藏**在 /etc/hosts 中。IP 和所有線路內容在那裡列出了兩次。**在我們產品所需的其他條目中,再次添加了條目。當我們註釋掉第二個條目時,httpd 開始按預期執行並停止雙重綁定嘗試。

引用自:https://serverfault.com/questions/877215