【发布时间】:2021-01-04 16:09:03
【问题描述】:
尝试在 magento 2.4 中搜索产品时返回以下错误
异常 #0 (Elasticsearch\Common\Exceptions\NoNodesAvailableException):在您的集群中找不到活动节点
以下配置:
- PHP 7.4.1
- Nginx 1.14
- MySql 8
- 弹性搜索 7.9
/etc/nginx/conf.d/100-magento2.conf
upstream fastcgi_backend {
server unix:/run/php-fpm/www.sock;
}
server {
listen 80;
server_name _;
set $MAGE_ROOT /var/www/magento2;
include /var/www/magento2/nginx.conf.sample;
}
/etc/nginx/conf.d/90-es.conf
upstream elasticsearch {
server 127.0.0.1:9200;
}
server {
server_name _;
listen 8080;
location / {
limit_except HEAD {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/passwd/.esnginx;
}
proxy_pass http://127.0.0.1:9200;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /_aliases {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/passwd/.esnginx;
proxy_pass http://127.0.0.1:9200;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
include /etc/nginx/auth/*.conf;
}
如果尝试:bin/magento config:show catalog/search/engine
结果:elasticsearch7
如果尝试: curl -i localhost:9200/_cluster/health?pretty
HTTP/1.1 200 OK
content-type: application/json; charset=UTF-8
content-length: 461
{
"cluster_name" : "magento2",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 3,
"active_shards" : 3,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 3,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 50.0
}
如果在网络上尝试:
Configuration by web
elasticsearch.yml: elasticsearch.yml
【问题讨论】:
-
问题是selinux,已解决
标签: elasticsearch nginx magento2 nginx-config proxypass