安装ElasticSearch
下载安装包
ES官网下载es和kibana:www.elastic.co/cn/start,并上传至服务器
运行ElasticSearch
解压两个tar包后,先进入elasticsearch输入命令
./bin/elasticsearch
启动es
linux启动时会看到如下命令行
✅ Elasticsearch security features have been automatically configured!
✅ Authentication is enabled and cluster connections are encrypted.
ℹ️ Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
_DmmGurIhw6H4mNs27wH
ℹ️ HTTP CA certificate SHA-256 fingerprint:
e5532ec5596cbeccbc6515f40a3e6cc486bfad12079e2ab0420f32deea002c23
ℹ️ Configure Kibana to use this cluster:
• Run Kibana and click the configuration link in the terminal when Kibana starts.
• Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
eyJ2ZXIiOiI4LjIuMCIsImFkciI6WyIxMC4wLjEyLjIzMDo5MjAwIl0sImZnciI6ImU1NTMyZWM1NTk2Y2JlY2NiYzY1MTVmNDBhM2U2Y2M0ODZiZmFkMTIwNzllMmFiMDQyMGYzMmRlZWEwMDJjMjMiLCJrZXkiOiJZQWpneTRBQktfRHFQQUFrSURUbTpnUlZpNEMySlRCYTlwZ045QzIwTVBRIn0=
ℹ️ Configure other nodes to join this cluster:
• On this node:
⁃ Create an enrollment token with `bin/elasticsearch-create-enrollment-token -s node`.
⁃ Uncomment the transport.host setting at the end of config/elasticsearch.yml.
⁃ Restart Elasticsearch.
• On other nodes:
⁃ Start Elasticsearch with `bin/elasticsearch --enrollment-token <token>`, using the enrollment token that you generated.
这里需要及时保存,用上述参数举例含义
elasticsearch超级管理员:elastic/_DmmGurIhw6H4mNs27wH
下面的JWTToken为kibana初始化认证时所需要,token设置为30分钟过期,如果token过期可以输入如下命令重新生成token
bin/elasticsearch-create-enrollment-token -s node
成功启动
浏览器输入地址
https://10.0.12.230:9200/
建议9200端口不要被占用,如果被占用,会导致Kibana启动异常麻烦
会提示这是个不安全的认证网站,谷歌浏览器,点击任意空白处
键盘输入thisisunsafe
回车即可成功启动ElasticSearch
错误排查
在启动时一般会遇到如下两种错误
- 内存不够
进入config目录中,vim jvm.options文件,修改jvm参数
- 不能使用root用户启动
按如下命令输入
# 新增用户
adduser elastic
# 设置密码
passwd elastic
输入密码:terra123
# 分配权限
chown -R elastic /opt/elasticsearch
# 切换用户
su elastic
# 进入es所在目录,启动es
./bin/elasticsearch
启动Kibana
参数配置
进入之前解压的kibana中,进入config目录,修改kibana的host地址,目的在于可以通过客户端浏览器访问到kibana地址,否则浏览器输入地址+端口访问无效
# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
server.host: "10.0.12.230"
./bin/kibana
启动Kibana
运行成功
Kibana初次启动后终端会打印如下地址
在浏览器输入地址即可进入Kibana页面,首次配置需要使用初次启动ElasticSearch中的JWT-Token,将token复制粘贴到输入框,即可完成Kibana的初始化配置
Kibana has not been configured.
Go to http://10.0.12.230:5601/?code=307455 to get started.