ElasticSearch docker集群

参考

https://blog.csdn.net/belonghuang157405/article/details/83301937

 


 docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 -v /opt/es-cluster/config/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /opt/es-cluster/data1:/usr/share/elasticsearch/data --name ES01 docker.elastic.co/elasticsearch/elasticsearch:6.2.4
 
 docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9201:9201 -p 9301:9301 -v /opt/es-cluster/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /opt/es-cluster/data2:/usr/share/elasticsearch/data --name ES02 docker.elastic.co/elasticsearch/elasticsearch:6.2.4

 docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9202:9202 -p 9302:9302 -v /opt/es-cluster/config/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /opt/es-cluster/data3:/usr/share/elasticsearch/data --name ES03 docker.elastic.co/elasticsearch/elasticsearch:6.2.4
 

/------------------------------------------------------------------------

这里需要特别指出的是要在elasticsearhc.yml中添加如下配置:

 http.cors.enabled: true
 http.cors.allow-origin: "*"
 http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
http.cors.allow-headers官网给的配置是:http.cors.allow-headers: Authorization 亲测不能正常访问,不明白为什么

重启ES就可以通过:http://192.168.1.215:9100/?auth_user=elastic&auth_password=passwd 访问head插件了

 

elasticsearch head + xpack 用户名密码访问

 

修改配置文件elasticsearch.yml,增加
http.cors.allow-headers: Authorization(不起作用,换成下面一行)

 http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

访问head时,url如下所示:
http://192.168.100.100:9100/?auth_user=elastic&auth_password=changeme

 

/_-------------------------------------------------

elasticsearch-head安装

3.1 拉取镜像
docker pull yanliangzhong/elasticsearch-head
3.2 运行容器
docker run -d –name es_admin -p 9100:9100 yanliangzhong/elasticsearch-head

3.3 配置跨域及用户名

 

 

/--------------------------------------------------------------

x-pack 修改密码

进入docker elasticsearch容器中

cd /data/elasticsearch-6.2.4/bin/x-pack

 

bin/elasticsearch-setup-passwords interactive

设置elastic/kibana/logstack的密码;

修改密码

  • curl -H "Content-Type:application/json" -XPOST -u elastic 'http://127.0.0.1:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'

 

修改kibana配置文件,config下的kibana.yml,添加如下内容

  1. elasticsearch.username: "elastic"

  2. elasticsearch.password: "123456"

 

 

成功后显示

 

es1.yml

cluster.name: elasticsearch-cluster
node.name: es-node1
network.bind_host: 0.0.0.0
network.publish_host: 192.168.1.215
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
#http.cors.allow-headers: Authorization
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
node.master: true 
node.data: true  
discovery.zen.ping.unicast.hosts: ["192.168.1.215:9300","192.168.1.215:9301","192.168.1.215:9302"]
discovery.zen.minimum_master_nodes: 2

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值