发布时间:2020-09-17 13:03:35编辑:admin阅读(2661)
需要在服务器中部署elasticsearch和head插件
操作系统:centos 7.6
docker版本:19.03.12
ip地址:192.168.31.190
docker pull elasticsearch:7.5.1 docker pull mobz/elasticsearch-head:5-alpine
vi /etc/sysctl.conf
调整参数
vm.max_map_count=262144
刷新参数
sysctl -p
mkdir -p /data/elk7/elasticsearch/{data,logs,config} vi /data/elk7/elasticsearch/config/elasticsearch.yml
内容如下:
cluster.name: "docker-cluster" network.host: 0.0.0.0 http.cors.enabled: true http.cors.allow-origin: "*"
注意:最后2行一定要添加,否则head插件连接时,会出现跨域拒绝访问。
docker run -d --name=elasticsearch \ -p 9200:9200 -p 9300:9300 \ -e "discovery.type=single-node" elasticsearch:7.5.1
等待30秒左右,查看docker日志,如果有出现
"publish_address {172.17.0.2:9300}, bound_addresses {0.0.0.0:9300}"
说明启动成功了。
拷贝数据到持久化目录,并重新启动elasticsearch
docker cp elasticsearch:/usr/share/elasticsearch/data /data/elk7/elasticsearch/ docker cp elasticsearch:/usr/share/elasticsearch/logs /data/elk7/elasticsearch/ chmod 777 -R /data/elk7/elasticsearch/ docker rm -f elasticsearch docker run -d --name=elasticsearch \ --restart=always \ -p 9200:9200 -p 9300:9300 \ -e "discovery.type=single-node" \ -v /data/elk7/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \ -v /data/elk7/elasticsearch/data:/usr/share/elasticsearch/data \ -v /data/elk7/elasticsearch/logs:/usr/share/elasticsearch/logs \ elasticsearch:7.5.1
测试访问
http://192.168.31.190:9200/
效果如下:
docker run -d \ --name=elasticsearch-head \ --restart=always \ -p 9100:9100 \ docker.io/mobz/elasticsearch-head:5-alpine
访问页面
http://192.168.31.190:9100/
输入es地址,点击连接。效果如下:
本文参考链接:
https://www.cnblogs.com/wxy0126/p/11381598.html
下一篇: docker安装logstash
47782
46307
37189
34674
29267
25928
24819
19901
19465
17957
5751°
6361°
5870°
5924°
7024°
5859°
5886°
6393°
6348°
7719°