时间:2023-01-02 09:21:51 | 栏目: | 点击:次
需要在服务器中部署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
配置文件
临时启动
docker run -d \ --name=elasticsearch \ -p 9200:9200 -p 9300:9300 \ -e "cluster.name=elasticsearch" \ -e "discovery.type=single-node" \ -e "ES_JAVA_OPTS=-Xms512m -Xmx1024m" \ elasticsearch:7.5.1
拷贝文件
mkdir -p /data/elk7 docker cp elasticsearch:/usr/share/elasticsearch/data /data/elk7/elasticsearch/ docker cp elasticsearch:/usr/share/elasticsearch/logs /data/elk7/elasticsearch/ docker cp elasticsearch:/usr/share/elasticsearch/config /data/elk7/elasticsearch/ chmod 777 -R /data/elk7/elasticsearch/
编辑配置文件
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 rm -f elasticsearch
启动
docker run -d \ --name=elasticsearch \ --restart=always \ -p 9200:9200 \ -p 9300:9300 \ -e "cluster.name=elasticsearch" \ -e "discovery.type=single-node" \ -e "ES_JAVA_OPTS=-Xms512m -Xmx1024m" \ -v /data/elk7/elasticsearch/config:/usr/share/elasticsearch/config \ -v /data/elk7/elasticsearch/data:/usr/share/elasticsearch/data \ -v /data/elk7/elasticsearch/logs:/usr/share/elasticsearch/logs \ elasticsearch:7.5.1
等待30秒左右,查看docker日志,如果有出现
"publish_address {172.17.0.2:9300}, bound_addresses {0.0.0.0:9300}"
说明启动成功了。
测试访问
效果如下:
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地址,点击连接。效果如下:
本文参考链接: