docker-compose.yml
version: '2'
services:
elasticsearch-head:
image: mobz/elasticsearch-head:5
container_name: elasticsearch-head
restart: always
networks:
extnetwork:
ipv4_address: 172.19.0.100
ports:
- 9100:9100
links:
- elasticsearch
elasticsearch:
image: elasticsearch:5.6
container_name: elasticsearch
restart: always
networks:
extnetwork:
ipv4_address: 172.19.0.101
ports:
- 9200:9200
- 9300:9300
expose:
- 9200
- 9300
networks:
extnetwork:
ipam:
config:
- subnet: 172.19.0.0/16
gateway: 172.19.0.1
若elasticsearch-head连接不上elasticsearch
在es/conf配置文件elasticsearch.yml加入:
http.cors.enabled: true
http.cors.allow-origin: “*”
重启elasticsearch解决
1.若报错:
NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{qkvT8FQ8QvO-jhx2FyOt0A}{10.1.1.34}{10.1.1.34:9300}]
// 配置信息
Settings esSetting = Settings.builder()
.put("cluster.name", clusterName)
.put("client.transport.sniff", false)//增加嗅探机制,找到ES集群
.put("thread_pool.search.size", Integer.parseInt(poolSize))//增加线程池个数,暂时设为5
.build();
注:a.版本要一致
b.client.transport.sniff设置false
另外:
config/elasticsearch.yml配置文件:
http.host: 0.0.0.0
#Uncomment the following lines for a production cluster deployment
transport.host: 0.0.0.0
#discovery.zen.minimum_master_nodes: 1
node.name: node-1
http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.name: my-application
http.port: 9200
network.host: 0.0.0.0