elasticsearch elasticsearch,magento 1.9
我正在尝试在本地将弹性搜索扩展连接到Magento 1.9商店。 我创建了docker-compose.ymlelasticsearch elasticsearch,magento 1.9,elasticsearch,docker-compose,elasticsearch,Docker Compose,我正在尝试在本地将弹性搜索扩展连接到Magento 1.9商店。 我创建了docker-compose.yml version: "3" services: application: container_name: application build: docker/application volumes: - ./application:/app php: container_name:
version: "3"
services:
application:
container_name: application
build: docker/application
volumes:
- ./application:/app
php:
container_name: php_1
build: docker/php
ports:
- 80:80
- 443:443
volumes:
- ./application:/app
links:
- elasticsearch
mysql:
container_name: mysql
build: docker/mysql
ports:
- 3306:3306
volumes:
- ./docker/tmp/db/mysql:/var/lib/mysql
environment:
MYSQL_DATABASE: db
MYSQL_USER: db
MYSQL_PASSWORD: db
MYSQL_ROOT_PASSWORD: db
elasticsearch:
container_name: elasticsearch
build: docker/elasticsearch
ports:
- 9200:9200
- 9300:9300
volumes:
-./docker/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
environment:
ES_JAVA_OPTS: "-Xmx256m -Xms256m"
我的Dockerfile如下所示:
FROM docker.elastic.co/elasticsearch/elasticsearch-oss:6.3.1
cluster.name: "docker-cluster"
network.host: 0.0.0.0
discovery.zen.minimum_master_nodes: 1
discovery.type: single-node
我的elasticsearch.yml如下所示:
FROM docker.elastic.co/elasticsearch/elasticsearch-oss:6.3.1
cluster.name: "docker-cluster"
network.host: 0.0.0.0
discovery.zen.minimum_master_nodes: 1
discovery.type: single-node
docker compose up命令后,我可以到达localhost:9200,它返回:
{
"name" : "vzqbiF3",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "E7nRc0WrRKuD78knlR5zTQ",
"version" : {
"number" : "6.3.1",
"build_flavor" : "oss",
"build_type" : "tar",
"build_hash" : "eb782d0",
"build_date" : "2018-06-29T21:59:26.107521Z",
"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"
}
我也可以通过elasticsearch从容器中找到它。命令:
curl-X GET“”返回相同的值
问题是我无法从php容器访问此端口。我收到:
root@45a560f027fe:/app# curl -X GET 'http://localhost:9200'
curl: (7) Failed to connect to localhost port 9200: Connection refused
很明显,Magento无法连接到elasticsearch
2018-07-11T17:11:11+02:00 CRIT (2): Elasticsearch server is not reachable
我的错在哪里?有人吗?这种elasticsearch环境应该有助于解决这个问题
environment:
- xpack.security.enabled=false
- ES_JAVA_OPTS: "-Xmx256m -Xms256m"
但此标志将关闭验证其连接到的主机。所以在生产中是不安全的。但是,如果您不将端口暴露在compose文件之外,那么容器之间的一切都应该是安全和可用的
要从php容器内部连接到elasticsearch,您需要使用此url
http://elasticsearch:9200
来测试你可能应该能够
curl-X GET'http://elasticsearch:9200“
嗨,谢谢你的回答。这很有帮助。现在我可以从php docker连接到elasticsearch,但magento仍然返回“elasticsearch服务器不可访问”。您是否在magento配置中更改了elasticsearch主机?我是说你的主机可能是127.0.0.1
或localhost
你应该改成elasticsearch
。如果您没有提供默认连接到localhost的配置参数,也可能是指在配置->目录->目录->目录搜索->服务器中?我试过:,有没有“http://”,最后有没有“//”。还有‘localhost:9200’、‘127.0.0.1:9200’没有任何效果……我不是magento的专家,但默认值是什么。您的magento应用程序在哪里设置?在这个php
容器或应用程序
容器中?也可以尝试此System>Index Management
和reindex all
Thaks,以获得您的帮助。我终于解决了。Elasticsearch版本与支持的扩展版本不兼容。我将extension和elasticsearch更改为5.5.3。多谢。