我花了两天时间,在stackoverflow和许多论坛上进行了很多搜索,但无法使其正常工作并且仍然感到困惑。我会保持简单。
我使用我的Laravel(PHP框架)WEB应用程序的数据库的ElasticSearch作为数据库。
Elasticsearch部署在Google计算引擎实例(即UBUNTU 16.0 LTS服务器)上。
我希望在整个开发过程中从笔记本电脑向Elasticsearch发送RESTful请求。 (我知道我可以在本地安装elasticsearch,但是那不是问题)
,这意味着从我的ubuntu服务器的Ssh cli中,当我执行'curl -X GET localhost:9200'
时,它完美地响应了Elasticsearch正在运行。即
{
"name" : "T1Xfr06",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "NqdJol0ZQ6imGOZxIVvnNA",
"version" : {
"number" : "6.3.0",
"build_flavor" : "default",
"build_type" : "deb",
"build_hash" : "424e937",
"build_date" : "2018-06-11T23:38:03.357887Z",
"build_snapshot" : false,
"lucene_version" : "7.3.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
但是我想用笔记本电脑curl -X GET
'http://MY_Server's_PUblic_IP:9200'
来做,但是它没有响应。
这是我尝试使其工作的方式。
sudo nano /etc/elasticsearch/elasticsearch.yml
中,我更改了network.host之类的内容,例如network.host: 0.0.0.0
,然后更改了sudo systemctl restart elasticsearch
,这到处都被告知可以允许所有IP地址的流量通过,但不能响应我的笔记本电脑的卷曲仍然请求!sudo ufw
status
为Status: inactive
的所有ufw防火墙设置
(这意味着每个IP地址都可以连接吗?)curl -X GET 'http://MY_Server's_PUblic_IP:9200'
是否合法即可。我在UBUNTU服务器上安装了nginx,然后从笔记本电脑上进行了curl -X GET 'http://MY_Server's_PUblic_IP:80'
的操作。它会立即响应!经过所有这些操作之后,当我从笔记本电脑上进行$ curl -X GET 'http://35.237.107.165:9200'
时,响应为curl: (7) Failed to connect to 35.237.107.165 port 9200: Timed out
我是一个初学者,我知道Elasticsearch有很多我不知道的地方。我想念什么?为什么我无法从本地计算机访问http
上安装在服务器上的elasticsearch?我根本没有防火墙设置。
更新:为什么我的yml文件中没有network.bind_host参数?
#---------------------------------- Cluster -----------------------------------
#Use a descriptive name for your cluster:
#
#cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
http.port: 8080
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["35.237.107.165"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes:
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
# Require explicit names when deleting indices:
#action.destructive_requires_name: true
答案 0 :(得分:0)
在“ http.port:”行中的elasticsearch.yml文件中更改端口号(默认情况下,在elasticsearch.yml文件中,这些字段已注释,您需要删除“#”以取消注释)。然后重新启动elasticsearch并尝试访问新端口。如果您可以共享elasticsearch.yml文件,则更好。
根据我的经验,一旦更改主机,就需要执行“启用内存锁定”功能,否则将引发错误。
选中以下文档的“启用内存锁定”部分以启用内存锁定
谢谢