发布时间:2020-09-17 13:03:35编辑:admin阅读(2493)
需要在服务器中部署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
47303
45507
36587
34101
28810
25424
24274
19469
18914
17483
5304°
5904°
5403°
5488°
6376°
5220°
5219°
5731°
5687°
6996°