本文以elasticsearch8.6.2为例详述linux集群离线部署步骤,以 官网部署教程为基础,针对部署过程中可能的疑问作说明。
因为项目安全等的原因,很多时候我们要部署的目标机器是不能访问互联网的。本文是个人离线部署过程记录,希望也能帮助到有同样需要的同学。
elasticsearch版本的更新迭代很快,8.x相较7.x , 6.x不仅性能有了大的提升,安全成为必要选项,还增加了许多新的功能。如果纯粹是新项目考虑使用elasticsearch,建议直接考虑8.x版本。
本文选择了当前最新的稳定版本8.6.2,后期会再出一个8.6.2版本对于常用功能的支持和限制的评估清单,有需要的朋友可以关注下
elasticsearch 8.6.2有内置的jdk,使用内置自带jdk即可,elasticsearch集群无特别依赖软件,我部署的linux版本CentOS Linux release 7.3.1611 (Core) 。1
开发环境资源有限,所以在一台服务器部署伪集群,避免冲突设置为不同端口。有资源的情况下可以部署到不同的多台机器,http端口默认9200,tcp端口默认9300
ip | 端口 | 节点名称 |
---|---|---|
192.168.56.100 | http:9201 tcp:9301 | node-1 |
192.168.56.100 | http:9202 tcp:9302 | node-2 |
192.168.56.100 | http:9203 tcp:9303 | node-3 |
下载地址
# 上传服务器
rz
# 解压
tar -xzf elasticsearch-8.6.2-linux-x86_64.tar.gz
elasticsearch不能以root账号启动,所以需要先创建非root账号,并赋权
# 创建新用户es
useradd -m -s /bin/bash es
# 设置密码
passwd xxx
# 赋权,这里赋予了dwrx所有权限,如果有限制可以降低权限
chmod -R 777 elasticsearch-8.6.2
# 进入安装目录
cd elasticsearch-8.6.2/
# 启动,退出Ctrl+z
./bin/elasticsearch
elasticsearch8.x系列默认需要密码验证和https,查看启动日志可以看到elasticsearch自动为超级管理员 elastic 生成了密码,还会生成cert认证文件到 elasticsearch-8.6.2/config/certs/目录。
这意味着该elasticsearch服务使用http协议连接时只能使用https,且需要账号/密码。比如上面说的elastic账号和自动生成的密码
The generated password for the elastic built-in superuser is:
<password>
The enrollment token for Kibana instances, valid for the next 30 minutes:
<enrollment-token>
The hex-encoded SHA-256 fingerprint of the generated HTTPS CA DER-encoded certificate:
<fingerprint>
You can complete the following actions at any time:
Reset the password of the elastic built-in superuser with
'bin/elasticsearch-reset-password -u elastic'.
Generate an enrollment token for Kibana instances with
'bin/elasticsearch-create-enrollment-token -s kibana'.
Generate an enrollment token for Elasticsearch nodes with
'bin/elasticsearch-create-enrollment-token -s node'.

bin/kibana --enrollment-token <enrollment-token>
启动成功日志的最后会打印出一个code,记录该code
浏览器访问http://192.168.56.100:5601
首先会提示输入一个类似激活码的,就把上面记录的code录入;然后会弹出登录界面,输入elastic超级管理员的账密即可登入
至此kibana已成功安装并连接elasticsearch集群
使用token方式连接集群成功后也是会自动生成一些认证的文件,和添加相应的配置到kibana.yml中。查看kibana.yml可以看到连接到的节点可能只有一个,可以加入其他两个节点
cat config/kibana.yml
# xpack.fleet.outputs:中的hosts同理配置
elasticsearch.hosts: ['https://192.168.56.100:9201','https://192.168.56.100:9202', 'https://192.168.56.100:9203']
查看命令 cat /etc/redhat-release) ↩︎