1.下载软件包
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.10.tar.gz
2.创建用户
useradd -m -d /home/es -s /bin/bash es
3.解压并修改属性信息
tar xf elasticsearch-6.8.10.tar.gz -C /home/es/
chown -R es:es /home/es/
4.创建相关目录并修改属性信息
mkdir -pv /es/{data,logs,tmp}
chown -R es:es /es
5.修改主机解析
echo '172.21.149.8 bj-p-es003
172.21.149.9 bj-p-es002
172.21.149.10 bj-p-es001' >> /etc/hosts
6.修改配置文件
vim /home/es/elasticsearch-6.8.10/config/elasticsearch.yml
cluster.name: es-data
node.name: bj-p-es002
path:
data: /es/data
logs: /es/logs
network.host: 0.0.0.0
http.port: 9200
discovery.zen.minimum_master_nodes:
- 172.21.149.10
- 172.21.149.9
- 172.21.149.8
discovery.zen.minimum_master_nodes: 2
node.master: true
node.data: true
node.ingest: true
注意修改集名称及节点名称
7.添加环境变量
export JAVA_HOME=/usr/local/java
export PATH=$PATH:$JAVA_HOME/bin
export ES_HOME="/home/es/elasticsearch-6.8.10"
export ES_JAVA_HOME="${JAVA_HOME}"
export ES_TMPDIR="/es/tmp"
8.修改内核参数
vim /etc/sysctl.conf
vm.max_map_count = 262144
9.启动es并测试
su - es
./elasticsearch-6.8.10/bin/elasticsearch -d
curl http://127.0.0.1:9200/_cat/nodes
curl http://127.0.0.1:9200