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

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章