1、机器准备
-
准备三台机器:4CPU 4G内存
-
修改三台机器的hostname分别为es1、es2、es3
-
配置host
vim /etc/hosts
10.0.0.11 es1
10.0.0.12 es2
10.0.0.13 es3
2、安装JDK
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
rpm -ivh jdk-8u231-linux-x64.rpm
3、创建相关安装目录
mkdir -p /opt/server/elasticsearch
mkdir -p /data/elasticsearch/data
mkdir -p /data/elasticsearch/logs
4、下载安装包
cd /opt/server/
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.1.zip
unzip elasticsearch-6.3.1.zip
mv elasticsearch-6.3.1 elasticsearch
5、修改Linux内核配置
切换到root用户修改配置/etc/sysctl.conf
su root
vim /etc/sysctl.conf
加入
vm.max_map_count=655360
然后使其生效
sysctl -p
切换到root用户修改/etc/security/limits.conf
su root
vim /etc/security/limits.conf
配置
root soft nofile 65536
root hard nofile 131072
* soft nofile 65536
* hard nofile 131072
6、修改elasticsearch.yml
vim elasticsearch.yml
cluster.name: es-clusters
node.name: es1
node.master: true
node.data: true
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
network.host: 0.0.0.0
http.port: 9200
discovery.zen.ping.unicast.hosts: ["172.16.10.219", "172.16.10.220", "172.16.10.221"]
discovery.zen.minimum_master_nodes: 2
gateway.recover_after_nodes: 2
7、创建elasticsearch用户并授权
useradd elasticsearch
chown -R elasticsearch:elasticsearch /opt/server/elasticsearch/
chown -R elasticsearch:elasticsearch /data/elasticsearch/data
chown -R elasticsearch:elasticsearch /data/elasticsearch/logs
8、启动
切换elasticsearch用户启动
su elasticsearch
./bin/elasticsearch -d
9、所有主机都启动之后,我们在任意主机上就可以查看到集群状态了,命令行如下:
curl -XGET 'http://localhost:9200/_cluster/state?pretty'