Implantar cluster Elasticsearch por meio do Docker

1. Implantação em máquina única

1. Configuração do sistema

1.1. Modifique o número máximo de arquivos abertos no sistema

vi /etc/security/limits.conf
# 在end前追加下面内容 
* soft nofile 65536
* hard nofile 65536

Faça login novamente após a modificação e use o seguinte comando para verificar se a modificação foi bem-sucedida.

ulimit -Hn

1.2. Aumente o tamanho de vm.max_map_count

vi /etc/sysctl.conf 
# 在最后面追加下面内容 
vm.max_map_count=262144 

Use sysctl -p para visualizar os resultados modificados

sysctl -p

2. Instale o Elasticsearch

2.1. Configurar elasticsearch.yml

# 新建目录
mkdir /home/southgisdata/elasticsearch/config
# 新建文件
vi /home/southgisdata/elasticsearch/config/elasticsearch.yml
# 文件中写入
network.host: 0.0.0.0
cluster.name: "docker-cluster"
http.cors.enabled: true
http.cors.allow-origin: "*"
#cluster.initial_master_nodes: ["node-1"]
xpack:
  ml.enabled: false
  monitoring.enabled: false
  security.enabled: false
  watcher.enabled: false
# 文件目录赋权
chmod -R 777 /home/southgisdata/elasticsearch/config/elasticsearch.yml 
# 开启http身份认证使用
network.host: 0.0.0.0
cluster.name: "docker-cluster"
http.cors.enabled: true
http.cors.allow-origin: "*"
#cluster.initial_master_nodes: ["node-1"]
xpack:
  ml.enabled: false
  monitoring.enabled: false
  security.enabled: false
  watcher.enabled: false
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true

2.2. Crie um novo diretório de dados do ElasticSearch

# 新建数据目录
mkdir /home/southgisdata/elasticsearch/data
# 文件目录赋权
chmod -R 777 /home/southgisdata/elasticsearch/data

2.3. Execute o contêiner elasticsearch

Endereço de download da imagem: https://www.docker.elastic.co/r/elasticsearch/elasticsearch

# 单节点启动
docker run -d --restart=always --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -v /home/southgisdata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/southgisdata/elasticsearch/data:/usr/share/elasticsearch/data 172.16.51.238:1180/product/elasticsearch:7.4.1

2. Implantação de cluster

1. Configuração do sistema

Todos os hosts incluídos no cluster modificam a configuração do sistema de acordo com a implantação autônoma.

e modificará o seguinte

1、准备机器
准备3台机器,安装CentOS7.6。ip计划如下:
192.168.2.11  es-master          #主节点
192.168.2.12  es-node1           #数据节点
192.168.2.13  es-node2           #数据节点
2、关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
3、禁用SELINUX
vim /etc/selinux/config
将SELINUX设置为disabled:
SELINUX=disabled
4、修改主机名
#设置主机名
hostnamectl set-hostname es-node1
通过hostname命令查看主机名。
4、配置IP映射
vim /etc/hosts
最后增加以下内容:
192.168.2.11   es-master
192.168.2.12   es-node1
192.168.2.13   es-node2

2. Implante nós ES

2.1. Configurar elasticsearch.yml

# 新建目录
mkdir /home/southgisdata/elasticsearch/config
# 新建文件
vi /home/southgisdata/elasticsearch/config/elasticsearch.yml
# 文件目录赋权
chmod -R 777 /home/southgisdata/elasticsearch/config/elasticsearch.yml 
2.1.1. Configuração do nó mestre
cluster.name: "docker-cluster"               #集群名,同一集群必须相同
node.name: 10.0.13.124                       #指定节点主机名
node.master: true                            #允许成为主节点
node.data: true                              #数据节点
path.data: /usr/share/elasticsearch/data                #数据存放路径
path.logs: /usr/share/elasticsearch/logs                #日志路径
bootstrap.memory_lock: false                            #关闭锁定内存,设置为true会报错
network.host: 0.0.0.0                                   #监听ip
network.publish_host: 10.0.13.124                       #集群通讯ip
http.port: 9200                                         #http端口
transport.tcp.port: 9300
cluster.initial_master_nodes: ["10.0.13.124:9300"]      #初始主结点列表
discovery.zen.ping.unicast.hosts: ["10.0.13.103:9300","10.0.13.123:9300","10.0.13.124:9300"]     #初始主机列表
discovery.zen.minimum_master_nodes: 2               # n/2+1
http.cors.enabled: true                             #允许head插件访问es
http.cors.allow-origin: "*"
xpack:
  ml.enabled: false
  monitoring.enabled: false
  security.enabled: false
  watcher.enabled: false
2.1.2. Configuração do nó de dados
cluster.name: "docker-cluster"               #集群名,同一集群必须相同
node.name: 10.0.13.123                       #指定节点主机名
node.master: false                           #允许成为主节点
node.data: true                              #数据节点
path.data: /usr/share/elasticsearch/data                #数据存放路径
path.logs: /usr/share/elasticsearch/logs                #日志路径
bootstrap.memory_lock: false                            #关闭锁定内存,设置为true会报错
network.host: 0.0.0.0                                   #监听ip
network.publish_host: 10.0.13.123                       #集群通讯ip
http.port: 9200                                         #http端口
transport.tcp.port: 9300
cluster.initial_master_nodes: ["10.0.13.124:9300"]      #初始主结点列表
discovery.zen.ping.unicast.hosts: ["10.0.13.103:9300","10.0.13.123:9300","10.0.13.124:9300"]     #初始主机列表
discovery.zen.minimum_master_nodes: 2               # n/2+1
http.cors.enabled: true                             #允许head插件访问es
http.cors.allow-origin: "*"
xpack:
  ml.enabled: false
  monitoring.enabled: false
  security.enabled: false
  watcher.enabled: false

2.2. Crie um novo diretório de dados do ElasticSearch

# 新建数据目录
mkdir /home/southgisdata/elasticsearch/data
# 文件目录赋权
chmod -R 777 /home/southgisdata/elasticsearch/data

2.3. Execute o contêiner elasticsearch

# 集群启动
docker run -d --restart=always --name elasticsearch -p 9200:9200 -p 9300:9300 -v /home/southgisdata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/southgisdata/elasticsearch/data:/usr/share/elasticsearch/data 172.16.51.238:1180/product/elasticsearch:7.4.1

Acho que você gosta

Origin blog.csdn.net/weixin_41166785/article/details/120865288
Recomendado
Clasificación