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

发布了70 篇原创文章 · 获赞 16 · 访问量 8万+

猜你喜欢

转载自blog.csdn.net/ucicno000/article/details/102823999