安装部署
创建程序目录
- 安装目录
-
mkdir /usr/local/elasticsearch
-
mkdir /usr/local/elasticsearch/6.4.3
-
mkdir /usr/local/elasticsearch/6.4.3/01 #第一个节点
-
mkdir /usr/local/elasticsearch/6.4.3/02 #第二个节点
-
mkdir /usr/local/elasticsearch/6.4.3/03 #第三个节点
- 数据目录
-
mkdir /data
-
mkdir /data/elasticsearch
-
mkdir /data/elasticsearch/01
-
mkdir /data/elasticsearch/01/data
-
mkdir /data/elasticsearch/01/logs
-
mkdir /data/elasticsearch/02
-
mkdir /data/elasticsearch/02/data
-
mkdir /data/elasticsearch/02/logs
-
mkdir /data/elasticsearch/03
-
mkdir /data/elasticsearch/03/data
-
mkdir /data/elasticsearch/03/logs
- 下载程序
3.1 下载Elasticsearch 6.4.3 tar
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.3.tar.gz
3.2 解压文件
-
tar -xvf elasticsearch-6.4.3.tar.gz
-
cd elasticsearch-6.4.3/
-
cp -rf * /usr/local/elasticsearch/6.4.3/01/
-
cp -rf * /usr/local/elasticsearch/6.4.3/02/
-
cp -rf * /usr/local/elasticsearch/6.4.3/03/
修改配置文件
- 01节点 vi /usr/local/elasticsearch/6.4.3/01/config/elasticsearch.yml
-
# ---------------------------------- Cluster -----------------------------------
-
#这个填写集群名称,集群中每个节点的名称必须一致,es节点是通过名称才来确定是否是同一个集群的
-
cluster.name: es-test
-
# ------------------------------------ Node ------------------------------------
-
#配置当前节点的名称,该名称在集群中唯一,不可重复
-
node.name: node01
-
# ----------------------------------- Paths ------------------------------------
-
path.data: /data/elasticsearch/01/data
-
path.logs: /data/elasticsearch/01/logs
-
# ----------------------------------- Memory -----------------------------------
-
#用于程序启动时建设内存是否足够存放heap size,测试版可以设成false
-
bootstrap.memory_lock: true
-
# ---------------------------------- Network -----------------------------------
-
#绑定IP地址
-
network.host: 0.0.0.0
-
#默认端口9200, 注:9300为es节点间TCP通讯使用,配置是请勿占用
-
http.port: 9201
-
# --------------------------------- Discovery ----------------------------------
-
#集群最小主节点数,为了防止脑裂,主节点数必须为奇数个,正式版建议采用 “总节点数/2 + 1”
-
discovery.zen.minimum_master_nodes: 1
- 02节点 $ vi /usr/local/elasticsearch/6.4.3/02/config/elasticsearch.yml
-
# ---------------------------------- Cluster -----------------------------------
-
#这个填写集群名称,集群中每个节点的名称必须一致,es节点是通过名称才来确定是否是同一个集群的
-
cluster.name: es-test
-
# ------------------------------------ Node ------------------------------------
-
#配置当前节点的名称,该名称在集群中唯一,不可重复
-
node.name: node02
-
# ----------------------------------- Paths ------------------------------------
-
path.data: /data/elasticsearch/02/data
-
path.logs: /data/elasticsearch/02/logs
-
# ----------------------------------- Memory -----------------------------------
-
#用于程序启动时建设内存是否足够存放heap size,测试版可以设成false
-
bootstrap.memory_lock: true
-
# ---------------------------------- Network -----------------------------------
-
#绑定IP地址
-
network.host: 0.0.0.0
-
#默认端口9200, 注:9300为es节点间TCP通讯使用,配置是请勿占用
-
http.port: 9202
-
# --------------------------------- Discovery ----------------------------------
-
#集群最小主节点数,为了防止脑裂,正式版建议采用 “总节点数/2 + 1”
-
discovery.zen.minimum_master_nodes: 1
- 03节点 $ vi /usr/local/elasticsearch/6.4.3/03/config/elasticsearch.yml
-
# ---------------------------------- Cluster -----------------------------------
-
#这个填写集群名称,集群中每个节点的名称必须一致,es节点是通过名称才来确定是否是同一个集群的
-
cluster.name: es-test
-
# ------------------------------------ Node ------------------------------------
-
#配置当前节点的名称,该名称在集群中唯一,不可重复
-
node.name: node03
-
# ----------------------------------- Paths ------------------------------------
-
path.data: /data/elasticsearch/03/data
-
path.logs: /data/elasticsearch/03/logs
-
# ----------------------------------- Memory -----------------------------------
-
#用于程序启动时建设内存是否足够存放heap size,测试版可以设成flase
-
bootstrap.memory_lock: true
-
# ---------------------------------- Network -----------------------------------
-
#绑定IP地址
-
network.host: 0.0.0.0
-
#默认端口9200, 注:9300为es节点间TCP通讯使用,配置是请勿占用
-
http.port: 9203
-
# --------------------------------- Discovery ----------------------------------
-
#集群最小主节点数,为了防止脑裂,正式版建议采用 “总节点数/2 + 1”
-
discovery.zen.minimum_master_nodes: 1
部署隔离完善
- 创建运行账户
-
groupadd elastic
-
useradd -g elastic elasticsearch
- 修改目录权限
-
chown -R elasticsearch:elastic /data/elasticsearch
-
chown -R /usr/local/elasticsearch/6.4.3
- 添加supervisor守护 $ vi /etc/supervisor/conf.d/elasticsearch.conf
-
[program:elasticsearch01]
-
command=/usr/local/elasticsearch/6.4.3/01/bin/elasticsearch
-
autostart=true
-
autorestart=true
-
startsecs=3
-
user=elasticsearch
-
redirect_stderr=true
-
stdout_logfile=/var/logs/supervisor/elasticsearch01.log
-
stdout_logfile_maxbytes=10MB
-
stdout_logfile_backups=10
-
[program:elasticsearch02]
-
command=/usr/local/elasticsearch/6.4.3/02/bin/elasticsearch
-
autostart=true
-
autorestart=true
-
startsecs=3
-
user=elasticsearch
-
redirect_stderr=true
-
stdout_logfile=/var/logs/supervisor/elasticsearch02.log
-
stdout_logfile_maxbytes=10MB
-
stdout_logfile_backups=10
-
[program:elasticsearch03]
-
command=/usr/local/elasticsearch/6.4.3/03/bin/elasticsearch
-
autostart=true
-
autorestart=true
-
startsecs=3
-
user=elasticsearch
-
redirect_stderr=true
-
stdout_logfile=/var/logs/supervisor/elasticsearch03.log
-
stdout_logfile_maxbytes=10MB
-
stdout_logfile_backups=10
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
解决办法:
编辑 /etc/security/limits.conf,追加以下内容;
* soft nofile 65536
* hard nofile 65536
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决办法:
编辑 /etc/sysctl.conf,追加以下内容:
vm.max_map_count=655360
保存后,执行:
sysctl -p
[3]: max number of threads [2048] for user [tongtech] is too low, increase to at least [4096]
错误原因:启动检查未通过
elasticsearch用户的最大线程数太低
解决办法:
vim /etc/security/limits.d/90-nproc.conf
将2048改为4096或更大
转载于:https://my.oschina.net/u/4008390/blog/2872979