部署步骤
初始化es配置文件
-- 拉取es镜像
docker pull elasticsearch:7.2.0
--创建挂载目录[data:存放索引数据,plugins:存放es插件]
mkdir -p /bkb/runtime/docker/es/config/data1
mkdir -p /bkb/runtime/docker/es/config/data2
mkdir -p /bkb/runtime/docker/es/config/data3
mkdir -p /bkb/runtime/docker/es/config/plugins1
mkdir -p /bkb/runtime/docker/es/config/plugins2
mkdir -p /bkb/runtime/docker/es/config/plugins3
-- 设置执行权限
chmod 777 -R /bkb/runtime/docker/es/config/
--data1/data2/data3 分别创建es.yml [network.publish_host:填写服务器ip]
vim /bkb/runtime/docker/es/config/es1.yml
->>
cluster.name: test-es
node.name: node1
network.host: 0.0.0.0
###如果是三台主机做,这里要加入内网ip,才能建立集群如下一行参数
# network.publish_host: 192.168.1.43
###如果是三台主机做,这里要加入内网ip,才能建立集群如上一行参数
http.port: 9201
transport.tcp.port: 9301
discovery.seed_hosts: ["192.168.3.214:9301","192.168.3.214:9302","192.168.3.214:9303"]
cluster.initial_master_nodes: ["node1"]
bootstrap.system_call_filter: false
bootstrap.memory_lock: false
http.cors.enabled: true
http.cors.allow-origin: "*"
vim /bkb/runtime/docker/es/config/es2.yml
->>
cluster.name: test-es
node.name: node2
network.host: 0.0.0.0
###如果是三台主机做,这里要加入内网ip,才能建立集群如下一行参数
# network.publish_host: 192.168.1.44
###如果是三台主机做,这里要加入内网ip,才能建立集群如上一行参数
http.port: 9202
transport.tcp.port: 9302
discovery.seed_hosts: ["192.168.3.214:9301","192.168.3.214:9302","192.168.3.214:9303"]
cluster.initial_master_nodes: ["node1"]
bootstrap.system_call_filter: false
bootstrap.memory_lock: false
http.cors.enabled: true
http.cors.allow-origin: "*"
vim /bkb/runtime/docker/es/config/es3.yml
->>
cluster.name: test-es
node.name: node3
network.host: 0.0.0.0
###如果是三台主机做,这里要加入内网ip,才能建立集群如下一行参数
# network.publish_host: 192.168.1.45
###如果是三台主机做,这里要加入内网ip,才能建立集群如上一行参数
http.port: 9203
transport.tcp.port: 9303
discovery.seed_hosts: ["192.168.3.214:9301","192.168.3.214:9302","192.168.3.214:9303"]
cluster.initial_master_nodes: ["node1"]
bootstrap.system_call_filter: false
bootstrap.memory_lock: false
http.cors.enabled: true
http.cors.allow-origin: "*"
调高JVM线程数限制数量
vim /etc/sysctl.conf
->>
vm.max_map_count=655300
# 刷新配置
sysctl -p
服务部署
es集群部署
# 服务1
docker run -e ES_JAVA_OPTS="-Xms2048m -Xmx2048m" \
-d -p 9201:9201 -p 9301:9301 \
-e ES_MIN_MEM=128m \
-e ES_MAX_MEM=4096m \
-v /bkb/runtime/docker/es/config/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /bkb/runtime/docker/es/config//data1/:/usr/share/elasticsearch/data/ \
-v /bkb/runtime/docker/es/config/plugins1/:/usr/share/elasticsearch/plugins \
--restart=always \
--name ES01 \
elasticsearch:7.2.0
# 服务2
docker run -e ES_JAVA_OPTS="-Xms2048m -Xmx2048m" \
-d -p 9202:9202 -p 9302:9302 \
-e ES_MIN_MEM=128m \
-e ES_MAX_MEM=4096m \
-v /bkb/runtime/docker/es/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /bkb/runtime/docker/es/config/data2/:/usr/share/elasticsearch/data/ \
-v /bkb/runtime/docker/es/config/plugins2/:/usr/share/elasticsearch/plugins \
--restart=always \
--name ES02 \
elasticsearch:7.2.0
# 服务3
docker run -e ES_JAVA_OPTS="-Xms2048m -Xmx2048m" \
-d -p 9203:9203 -p 9303:9303 \
-e ES_MIN_MEM=128m \
-e ES_MAX_MEM=4096m \
-v /bkb/runtime/docker/es/config/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /bkb/runtime/docker/es/config/data3/:/usr/share/elasticsearch/data/ \
-v /bkb/runtime/docker/es/config/plugins1/:/usr/share/elasticsearch/plugins \
--restart=always \
--name ES03 \
elasticsearch:7.2.0
# 防火墙设置
firewall-cmd --add-port=9301/tcp
firewall-cmd --add-port=9302/tcp
firewall-cmd --add-port=9303/tcp
firewall-cmd --add-port=9200/tcp
firewall-cmd --add-port=9201/tcp
firewall-cmd --add-port=9202/tcp
firewall-cmd --add-port=9203/tcp
firewall-cmd --complete-reload
确认集群配置
curl http://127.0.0.1:9201/_cat/nodes?pretty
上面是同一台主机建立的,没设置内网ip,所以显示的是docker网络ip,如果是三台内网主机建立集群,建立集群成功后如图所示:
IK分词器安装
# 进入容器
root@Ubuntu:/bkb/runtime/docker/es/config# docker exec -it ES01 bash
# 在线安装
elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.2.0/elasticsearch-analysis-ik-7.2.0.zip
# 复制es1安装的插件到es2和es3
root@Ubuntu:/bkb/runtime/docker/es/config# cp -rf plugins1/analysis-ik/ plugins2
root@Ubuntu:/bkb/runtime/docker/es/config# cp -rf plugins1/analysis-ik/ plugins3ls
# 重启es
root@Ubuntu:/bkb/runtime/docker/es/config# docker restart ES01
root@Ubuntu:/bkb/runtime/docker/es/config# docker restart ES02 ES03
esUI部署
部署elasticsearch-head 便于管理es数据
docker run -d \
--name=elasticsearch-head \
-p 9100:9100 \
-m 512m \
--memory-swap=1024m \
--restart=always
mobz/elasticsearch-head:5-alpine
确认效果
安装kibana
汉化:kibana 7.* 设置中文 汉化_121812的博客-CSDN博客_kibana7中文
启动后进入编辑yml文件指定es的地址
docker pull kibana:7.2.0
docker run -dit --name kibana -p 5601:5601 -v /bkb/runtime/docker/es/config/kibana.yml:/usr/share/kibana/config/kibana.yml --restart=always kibana:7.2.0
docker exec -it kibana /bin/bash
将容器后kibana.yml文件配置持久化,配置内容如下
Kibana配置内容:文章来源:https://www.toymoban.com/news/detail-536995.html
#** THIS IS AN AUTO-GENERATED FILE **
#
# Default Kibana configuration for docker target
server.name: kibana
server.host: "0"
elasticsearch.hosts: [ "http://192.168.3.214:9201","http://192.168.3.214:9202","http://192.168.3.214:9203" ]
#elasticsearch.hosts: [ "http://elasticsearch:9200" ]
xpack.monitoring.ui.container.elasticsearch.enabled: true
i18n.locale: "zh-CN"
汉化后的kibana,也可以看到集群信息
文章来源地址https://www.toymoban.com/news/detail-536995.html
到了这里,关于docker部署单机ES集群7.2.0的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!