elasticsearch8.x版本docker部署说明

前提,当前部署没有涉及证书和https访问
1、环境说明,我采用三个节点,每个节点启动两个es,用端口区分

主机 角色 ip和端口
服务器A master 192.168.2.223:9200
服务器A data 192.168.2.223:9201
服务器B data,master 192.168.2.224:9200
服务器B data 192.168.2.224:9201
服务器C data,master 192.168.2.225:9200
服务器C data 192.168.2.225:9201

2、三个节点都需要执行创建部署文件目录

#es1需要的文件目录
mkdir -p /mydata/es/node1/data
chmod 777  /mydata/es/node1/data
mkdir -p /mydata/es/node1/conf
chmod 777  /mydata/es/node1/conf
mkdir -p /mydata/es/node1/plugins
chmod 777  /mydata/es/node1/plugins
mkdir -p /mydata/es/node1/logs
chmod 777  /mydata/es/node1/logs
#es2需要的文件目录
mkdir -p /mydata/es/node2/data
chmod 777  /mydata/es/node2/data
mkdir -p /mydata/es/node2/conf
chmod 777  /mydata/es/node2/conf
mkdir -p /mydata/es/node2/plugins
chmod 777  /mydata/es/node2/plugins
mkdir -p /mydata/es/node2/logs
chmod 777  /mydata/es/node2/logs

2、服务器A编写es1的yml文件

cd /mydata/es/node1/conf
vi elasticsearch.yml
#输入以下内容

cluster.name: elasticsearch-cluster
#节点名称
node.name: es-node1
#节点通信ip
network.bind_host: 0.0.0.0
#节点ip
network.publish_host: 192.168.2.223
#节点通信端口
http.port: 9200
transport.port: 9300
#跨域配置
http.cors.enabled: true
http.cors.allow-origin: "*"
#节点角色
node.roles: [ master]
#和其他节点通信的ip端口
discovery.seed_hosts: ["192.168.2.223:9300","192.168.2.223:9301", "192.168.2.224:9300", "192.168.2.224:9301","192.168.2.225:9300","192.168.2.225:9301"]
#初始化master节点的配置,用于选举的mater节点ip,后续的节点不需要该配置
cluster.initial_master_nodes: [192.168.2.223,192.168.2.224,192.168.2.225]
#http配置
# Enable security features
xpack.security.enabled: false
xpack.security.enrollment.enabled: false
# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
  enabled: false
  #keystore.path: certs/http.p12

# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
  enabled: false
  #verification_mode: certificate
  #keystore.path: certs/transport.p12
  #truststore.path: certs/transport.p12

保存退出
2、服务器A编写es2的yml文件

cd /mydata/es/node2/conf
vi elasticsearch.yml
#输入以下内容

cluster.name: elasticsearch-cluster
node.name: es-node2
network.bind_host: 0.0.0.0
network.publish_host: 192.168.2.223
http.port: 9201
transport.port: 9301
http.cors.enabled: true
http.cors.allow-origin: "*"
node.roles: [ data]
discovery.seed_hosts: ["192.168.2.223:9300","192.168.2.223:9301", "192.168.2.224:9300", "192.168.2.224:9301","192.168.2.225:9300","192.168.2.225:9301"]

# Enable security features
xpack.security.enabled: false
xpack.security.enrollment.enabled: false

# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
  enabled: false
  #keystore.path: certs/http.p12

# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
  enabled: false
  #verification_mode: certificate
  #keystore.path: certs/transport.p12
  #truststore.path: certs/transport.p12

4、启动es1和es2

#设置yml文件权限,不然会报错
chmod 777  /mydata/es/node1/conf/*
chmod 777  /mydata/es/node2/conf/*
#启动
docker run --restart=always  -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 -v /mydata/es/node1/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /mydata/es/node1/data:/usr/share/elasticsearch/data -v /mydata/es/node1/plugins:/usr/share/elasticsearch/plugins --name es01 elasticsearch:8.6.2

docker run --restart=always  -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9201:9201 -p 9301:9301 -v /mydata/es/node2/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /mydata/es/node2/data:/usr/share/elasticsearch/data -v /mydata/es/node2/plugins:/usr/share/elasticsearch/plugins --name es02 elasticsearch:8.6.2

5、服务器B和服务器C配置参考服务器A进行部署,需要调整的就是ip和端口就行

6、安装kibana

docker run -d \
--name kibana \
-e ELASTICSEARCH_HOSTS=http://192.168.2.223:9200  \
-p 5601:5601  \
kibana:8.6.2

7、谷歌插件安装es-head,下载解压,拖到谷歌浏览器的插件上就好
百度云链接:https://pan.baidu.com/s/1V1tMlgPUQpcaKtqrFjGf2A
提取码:yzwf

8、验证,输入http://192.168.2.223:9200/_cat/nodes,生产环境需要自己去定义角色,自己去了解8.x的相关角色和架构,我这里就不解释了。
elasticsearch8.x版本docker部署说明_第1张图片
elasticsearch8.x版本docker部署说明_第2张图片
9、角色相关说明推荐博主博文链接
http://www.manongjc.com/detail/62-gdexfeqaydpetga.html

你可能感兴趣的:(docker,容器,运维)