Elasticsearch Cluster Master-Master Node CentOS7
1 min read

Elasticsearch Cluster Master-Master Node CentOS7

1) Import Elasticsearch PGP Key

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

2) Add Repo Elasticsearch

โดยเข้าไปที่ /etc/yum.repos.d/ สร้างไฟล์ไว้ในนี้ชื่อ elasticsearch.repo แล้วใส่คำสั่งต่อไปนี้ไว้ในไฟล์

[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/oss-7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

3) Install elasticsearch

yum install elasticsearch-oss

3) Config Elasticsearch cluster master node

ไปที่ไฟล์ /etc/elasticsearch/elasticsearch.yml แล้วเพิ่มคำสั่งต่อไปนี้ไว้ที่ท้ายไฟล์

Config Master Node 1

***cluster.name ต้องเหมือนกันทุกโหนด***

cluster.name: ใส่ชื่อ cluster ที่จะตั้งหรือใส่ชื่อ app
node.name: ชื่อโหนด
network.host: ip-เครื่อง
discovery.seed_hosts: ["ip-master-1","ip-master-2","ip-master-3"]
cluster.initial_master_nodes: ["ip-master-1","ip-master-2","ip-master-3"]

Config Master Node 2

cluster.name: ใส่ชื่อ cluster ที่จะตั้งหรือใส่ชื่อ app
node.name: ชื่อโหนด
network.host: ip-เครื่อง
discovery.seed_hosts: ["ip-master-1","ip-master-2","ip-master-3"]
cluster.initial_master_nodes: ["ip-master-1","ip-master-2","ip-master-3"]

จากนั้นสั่งรีสตาร์ททีละเครื่อง แล้วเช็คสถานะ cluster ได้จาก command ต่อไปนี้

curl -XGET http://ip:9200/_cluster/health?pretty
curl -XGET http://ip:9200/_cat/nodes?v