ubuntu 20.04 创建elasticsearch cluster

  1. 准备两台20.04 的ubuntu服务器
  2. 在每台服务器上安装elasticsearch
sudo apt install openjdk-11-jdk
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo apt install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee –a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt update
sudo apt install elasticsearch
  1. 设置开机启动elasticsearch
sudo systemctl enable elasticsearch
  1. 设置节点名称
master
sudo hostnamectl set-hostname controller
worker名称
sudo hostnamectl set-hostname node-1
  1. 配置elasticsearch
    这一步需要在每个服务器上执行一次,我们将第一个节点称为controller,第二个节点称为node1.
    controller 配置
sudo nano /etc/elasticsearch/elasticsearch.yml

cluster.name: ellistest

# ------------------------------------ Node -------------------
node.name: controller
node.master: true #主节点设置true
node.data: false #主节点设置false
# ----------------------------------- Paths ------------------
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory ------------------
bootstrap.memory_lock: false
# ---------------------------------- Network ------------------
network.host: 192.168.214.134
http.port: 9200
# --------------------------------- Discovery -----------------
discovery.seed_hosts: ["192.168.214.134", "192.168.214.135"]

cluster.initial_master_nodes: ["192.168.214.134"]

node 配置

sudo nano /etc/elasticsearch/elasticsearch.yml

cluster.name: ellistest

# ------------------------------------ Node -------------------
node.name: node-1
node.master: false #主节点设置true
node.data: true#主节点设置false
# ----------------------------------- Paths ------------------
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory ------------------
bootstrap.memory_lock: false
# ---------------------------------- Network ------------------
network.host: 192.168.214.135
http.port: 9200
# --------------------------------- Discovery -----------------
discovery.seed_hosts: ["192.168.214.134", "192.168.214.135"]

cluster.initial_master_nodes: ["192.168.214.134"]
  1. 启动elasticsearch即可
  2. 验证集群成功
curl -XGET http://localhost:9200/_cat/nodes?v 查看工作节点
curl -XGET http://localhost:9200/_cat/master?v 查看主节点

https://developer.aliyun.com/article/1266948

https://logz.io/blog/elasticsearch-cluster-tutorial/

https://www.techrepublic.com/article/how-to-deploy-an-elasticsearch-cluster-on-ubuntu-server-20-04/

你可能感兴趣的:(elasticsearch,ubuntu,elasticsearch)