zoukankan      html  css  js  c++  java
  • 阿里云服务器上安装了es并在安全组中开启了9200端口仍然telnet不通

    前言

    安装启动es的过程中遇到的坑这里就不说了,基本上网上都能搜到,这里说telnet端口不通的事。

    阿里云相关

    阿里云默认很多端口都是不开放的,必须去配置安全组才能访问,但是有时候你配置了安全组仍然访问不了,就可以按照这篇文章的思路来试着排查一下。

    问题描述

    centos7上安装了es,启动的时候没有报错,查看端口有监听,进程存在。然后在阿里云上配置安全组,给9200端口入的权限。这个时候奇葩的事情发生了,9200端口本地怎么访问都不通,telnet也不通。

    解决问题

    先是在网上搜了一下,大多数都说的是防火墙的问题,主要是iptables和firewall-cmd。

    我看了一下自己的情况,firewall-cmd没运行,iptables一个拦截规则都没有配置,所以肯定不是防火墙的问题。

    继续在网上各种搜,没有结果。

    最后没有办法,提了阿里云的工单,阿里云的小哥先是让发一下这三个命令的截图:

    netstat  -ntulp   |  grep  9200
    iptables  -nL
    firewall-cmd --list-all
    

    可以看到小哥的思路也是,先看一下端口是否被监听,之后排查防火墙。

    我给小哥发了执行命令的截图,然后小哥给我的回复是:
    "当前您截图的9200端口似乎监听在本地回环端口127.0.0.1 是不行的,您看下配置修改使其监听在0.0.0.0 后您再测试看下。"

    我瞬间就恍然大悟了,我没有配置es的network.host。修改配置文件中的network.host: 0.0.0.0

    重启es,果然可以了。

    回环地址

    既然上面小哥哥说了一个名词,本地回环地址,而我又是一个还算好学的小青年,自然要搞一波这个名词。

    先说定义:
    127.0.0.1,通常被称为本地回环地址(Loopback Address),不属于任何一个有类别地址类。

    在安装网卡前就可以ping通这个本地回环地址。

    127.0.0.1 vs 0.0.0.0

    127.0.0.1 is normally the IP address assigned to the "loopback" or local-only interface. This is a "fake" network adapter that can only communicate within the same host. It's often used when you want a network-capable application to only serve clients on the same host. A process that is listening on 127.0.0.1 for connections will only receive local connections on that socket.

    "localhost" is normally the hostname for the 127.0.0.1 IP address. It's usually set in /etc/hosts (or the Windows equivalent named "hosts" somewhere under %WINDIR%). You can use it just like any other hostname - try "ping localhost" to see how it resolves to 127.0.0.1.

    0.0.0.0 has a couple of different meanings, but in this context, when a server is told to listen on 0.0.0.0 that means "listen on every available network interface". The loopback adapter with IP address 127.0.0.1 from the perspective of the server process looks just like any other network adapter on the machine, so a server told to listen on 0.0.0.0 will accept connections on that interface too.

    转自:https://stackoverflow.com/questions/20778771/what-is-the-difference-between-0-0-0-0-127-0-0-1-and-localhost/20778887#20778887

    大致的意思是,如果监听的是 127.0.0.1, 那么只能本地访问;如果监听的是0.0.0.0,那么所有的其他ip都能访问。

  • 相关阅读:
    spring boot web开发使用kindeditor中调用地图功能的异常情况"此内容不能显示在一个框架中"
    mysql在spring+mybatis中出现value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp的几种种解决办法
    spring oauth2 的认证流程
    mingw32 QT环境在集成一些librtmp代码由于zlib出现的一些错误:undefined reference to `inflate'
    QT下c和c++混编问题
    产品与开发那些事
    Qt5.6 windows下vs2015(vs2012)编译ODBC
    转 2018 疯狂微服务之死
    Source Tree时免登录安装
    Win7系统下局域连接OPC配置
  • 原文地址:https://www.cnblogs.com/lwmp/p/13664043.html
Copyright © 2011-2022 走看看