docker部署elasticsearch

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值