Linix
- 解压es安装包
tar -zxvf elasticsearch.tar.gz -C /usr/local/elasticsearch
- 配置ES_JAVA_HOME
vim /etc/profile # 添加 ES_JAVA_HOME = elasticsearch/jdk
source /etc/profile
# export ES_JAVA_HOME = elasticsearch/jdk
- 由于ES禁止使用root用户启动,需要创建一个普通用户来运行ES
useradd esuser
passwd esuser
groupadd -G es esuser
chown -R esuser.es elasticsearch/*
- 增加虚拟内存的设置
vi /etc/sysctl.conf # 添加vm.max_map_count=262144
sysctl -p # 刷新配置使其生效
- 修改配置
vim /usr/local/elasticsearch/config/elasticsearch.yml
networkhost=127.0.0.1
http.port:9200
discovery.type=single-node
- 启动ES服务
su esuser
cd /usr/local/elasticsearch/bin
nohup ./elasticsearch &
Windows
- 在所有节点的es config 目录下的elasticsearch.yml 文件新增如下配置,然后重启(进入bin目录elasticsearch)
xpack.security.enabled: true
- 在es的任一节点下生成p12文件,在es目录下执行命令
./bin/elasticsearch-certutil ca -out config/elastic-certificates.p12 -pass “”
-
生成p12文件后,将p12文件复制到其他节点的机器中,尽量保持p12的目录路径一致
-
在所有节点的es config 目录下的elasticsearch.yml 文件新增如下配置(注意p12文件的目录路径):
xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.keystore.path: p12文件的绝对目录路径
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.client_authentication: required
xpack.security.transport.ssl.keystore.path: p12文件的绝对目录路径
xpack.security.transport.ssl.truststore.path: p12文件的绝对目录路径
-
配置/自动生成密码,es中默认有5个用户
-
随机生成方式: 执行完记得保存好
./bin/elasticsearch-setup-passwords auto -
手动配置方式: 会提示每个密码都要输入两遍
./bin/elasticsearch-setup-passwords interactive
-
-
把es集群的均衡配置开启回来
将配置值 cluster.routing.allocation.enable 设置成true