我开始使用Elastic search。我成功在服务器上安装了elasticsearch(与应用程序服务器不同),但是当我尝试从应用程序服务器调用Elatic搜索时出现错误 Fatal error: Uncaught exception 'Elasticsearch\Common\Exceptions\NoNodesAvailableException' with message 'No alive nodes found in your cluster'
当我检查Elastic search状态时,它显示 Active 。
如何将Elastic search从我的应用程序服务器调用到elasticsearch服务器。
<?php
require 'vendor/autoload.php';
$hosts = [
'ip_address:9200' // IP + Port
];
$client = Elasticsearch\ClientBuilder::create()->setHosts($hosts)->build();
$params = [
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id',
'body' => ['testField' => 'abc']
];
$response = $client->index($params);
?>
我的elasticsearch.yml设置
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please see the documentation for further information on configuration options:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>
#
# ---------------------------------- 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.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
# path.data: /path/to/data
#
# Path to log files:
#
# path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
# bootstrap.memory_lock: true
#
# Make sure that the `ES_HEAP_SIZE` environment variable 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
#network.bind_host: 0
#
# Set a custom port for HTTP:
#
# http.port: 9200
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
#
# --------------------------------- 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: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
#
# discovery.zen.minimum_master_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
# gateway.recover_after_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>
#
# ---------------------------------- Various -----------------------------------
#
# Disable starting multiple nodes on a single system:
#
# node.max_local_storage_nodes: 1
#
# Require explicit names when deleting indices:
#
# action.destructive_requires_name: true
elasticsearch.yml设置不起作用
network.host: 127.0.0.1
network.host: 0
network.host: 0.0.0.0
network.host: IP_Address
network.bind_host: 0
network.bind_host: IP_Address
当我设置以上设置时,elasticsearch将显示失败状态。
注意:elasticsearch与我的应用程序服务器安装在不同的服务器上。
我发现了错误。错误是由于 node.name 和 cluster.name 之前的 空格 而引起的。 删除
该空格及其正常工作。
更新了elasticsearch.yml文件
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please see the documentation for further information on configuration options:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: my-application-shakedeal
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: shakedeal-1
#
# Add custom attributes to the node:
#
# node.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
# path.data: /path/to/data
#
# Path to log files:
#
# path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
# bootstrap.memory_lock: true
#
# Make sure that the `ES_HEAP_SIZE` environment variable 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: 127.0.0.1
network.bind_host: IP_ADDRESS
#
# Set a custom port for HTTP:
#
# http.port: 9200
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
#
# --------------------------------- 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: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
#
# discovery.zen.minimum_master_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
# gateway.recover_after_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>
#
# ---------------------------------- Various -----------------------------------
#
# Disable starting multiple nodes on a single system:
#
# node.max_local_storage_nodes: 1
#
# Require explicit names when deleting indices:
#
# action.destructive_requires_name: true
PHP代码
<?php
require 'vendor/autoload.php';
$indexParams = [
'index' => 'my_index',
'body' => [
'settings' => [
'number_of_shards' => 5,
'number_of_replicas' => 1
]
]
];
$client = Elasticsearch\ClientBuilder::create()
->setSSLVerification(false)
->setHosts(["IP_ADDRESS:9200"])->build();
$response = '';
try {
/* Create the index */
$response = $client->indices()->create($indexParams);
print_r($response);
print_r($response);
} catch(Exception $e) {
echo "Exception : ".$e->getMessage();
}
die('End : Elastic Search');
?>
成功回应 :
Array
(
[acknowledged] => 1
)
尝试在magento 2.4中搜索产品时返回以下错误 异常#0(Elasticsearch\Common\Exceptions\NoNodes可用性异常):在集群中找不到活动节点 以下配置: PHP 7.4.1 Nginx 1.14 MySql 8 ElasticSearch 7.9 /etc/nginx/conf.d/100-magento2.conf /etc/nginx/conf.d/90-
根据如何在Ubuntu中安装Apache Hadoop2.6.0(多节点/集群设置),我将Hadoop2.6.0设置为1个主服务器和2个从服务器。毕竟,我在master和slaves上检查了jps,看起来都很好:master上的NameNode、SecondaryNameNode、ResourceManager;和DataNode,从服务器上的NodeManager。但是当我浏览到Hadoopma
我正在使用springboot和gradle,我正在尝试在控制器中执行下面的代码。 在编译时,我得到以下错误 错误:找不到symbol=List.of(“水星”,“金星”,“地球”,“火星”,^symbol:方法of(String,String,String,String,String,String,String,String,String,String) 位置:接口列表 我的分级档案 sourc
问题内容: 我只是不明白发生了什么。我的go应用程序无法连接到elasticsearch。该节点可用,已启动并正在运行。我在这里做错了什么? 这里有什么不对的地方?错误说 这是我在浏览器中命中GET请求时从elasticsearch返回的数据 } 问题答案: 当您继续在客户端中进行嗅探但群集没有可用节点时,通常会发生错误。您可以通过点击来检查集群的状态。 如果您不禁用嗅探功能,则Golang客户端
问题内容: 当我在Android Studio 2.0中创建空白活动并尝试在API 16上运行该活动时,它将正确编译。当我在具有API 23的仿真器上运行它时,它运行无误。当我在API 16上运行它时,在应用启动时会给我很多错误。见下文。奇怪的是该应用程序运行正常。 这可能是什么原因? 在Android Studio中,我无效并清除了缓存。还清理了项目并对其进行了重建。 供参考的代码: Andro