elasticsearch centos集群

前提请搭建好jdk

准备三个节点

192.168.1.99  192.168.1.100 192.168.1.102

下载

cd  /mnt/soft/
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.2.tar.gz
tar -zxvf   elasticsearch-5.5.2.tar.gz

每个节点执行

创建 elastic 用户
useradd -m elastic
创建数据目录
rm -rf /var/lib/elasticsearch
mkdir /var/lib/elasticsearch
chown elastic.elastic /var/lib/elasticsearch
创建日志目录
mkdir -p /var/log/elasticsearch
chown elastic.elastic  /var/log/elasticsearch
增加 vi /etc/sysctl.conf 配置,执行 sysctl -p 生效
vm.max_map_count = 262144
增加 vi /etc/security/limits.conf 配置
elastic soft nofile 65536
elastic hard nofile 65536
elastic soft memlock unlimited
elastic hard memlock unlimited


每个node 机器hosts命名   /etc/hosts
es1 192.168.1.99
es2 192.168.1.100
es3 192.168.1.102

es1
vim /mnt/soft/elastic-node1/config/elasitcsearch.yml 文件修改
cluster.name: es-cluster
node.name: es1
network.host: 192.168.1.99
#cluster.initial_master_nodes: ["es1","es2"]
#node.master: true
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
#bootstrap.memory_lock: true
discovery.zen.ping.unicast.hosts: ["192.168.1.99", "192.168.1.100", "192.168.1.102"]
#discovery.zen.minimum_master_nodes: 2
#gateway.recover_after_nodes: 2
network.bind_host: 0.0.0.0
discovery.zen.minimum_master_nodes: 1

## 如下配置是为了解决 Elasticsearch可视化工具 dejavu的跨域问题!若不用可视化工具则可省略之
#http.port: 9200
#http.cors.allow-origin: "http://192.168.199.76:1358"
#http.cors.enabled: true
#http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
#http.cors.allow-credentials: true

执行
chown -R elastic.elastic  /mnt/soft/elastic-node1
su elastic
sh /mnt/soft/elastic-node1/bin/elasticsearch -d

es2
vim /mnt/soft/elastic-node1/config/elasitcsearch.yml 文件修改
cluster.name: es-cluster
node.name: es2
network.host: 192.168.1.100
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
discovery.zen.ping.unicast.hosts: ["192.168.1.99", "192.168.1.100", "192.168.1.102"]
network.bind_host: 0.0.0.0
discovery.zen.minimum_master_nodes: 1

执行
chown -R elastic.elastic  /mnt/soft/elastic-node2
su elastic
sh /mnt/soft/elastic-node2/bin/elasticsearch -d

es3
vim /mnt/soft/elastic-node1/config/elasitcsearch.yml 文件修改
cluster.name: es-cluster
node.name: es3
network.host: 192.168.1.102
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
discovery.zen.ping.unicast.hosts: ["192.168.1.99", "192.168.1.100", "192.168.1.102"]
network.bind_host: 0.0.0.0
discovery.zen.minimum_master_nodes: 1

执行
chown -R elastic.elastic  /mnt/soft/elastic-node3
su elastic
sh /mnt/soft/elastic-node3/bin/elasticsearch -d

查看集群状态
curl http://192.168.1.99:9200/_cluster/state?pretty

elasticsearch centos集群

查看节点状态
curl http://192.168.1.99:9200/_cat/nodes?pretty
 

elasticsearch centos集群

 

参考

https://www.cnblogs.com/yueminghai/p/10824700.html

https://www.jianshu.com/p/1dc6f012cf9c