测试环境:centos7
本次部署的版本:elasticsearch8.0.0和kibana8.0.0
centos7安装elasticsearch8.0.0
ElasticSearch 8.0,和其他低版本最大的区别就是,默认开启安全防护。kibana访问时需要token访问。
首次启动Elasticsearch时,默认情况下会启用并配置安全功能。以下安全配置将自动进行:
- 启用身份验证和授权,并为弹性内置超级用户生成密码。
- 为传输层和HTTP层生成TLS的证书和密钥,并使用这些密钥和证书启用和配置TLS。
- 为Kibana生成一个注册令牌,有效期为30分钟。
1.elasticsearch下载
$wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.0.0-linux-x86_64.tar.gz
2.创建ES用户
#不可使用root用户直接启动elasticsearch,需要创建一个用户来启动ES。
$ groupadd es
$ useradd -g es es
$passwd es
3.将下载好的es解压到es的home目录,并改变所属用户和组为es
#解压缩
$tar -zxvf elasticsearch-8.0.0-linux-x86_64.tar.gz
#移动到/home/es下
$mv elasticsearch-8.0.0 /home/es/elasticsearch-8.0.0
#授权给es用户组和es用户
$chown -R es:es /home/es/elasticsearch-8.0.0
4.启动ES
4.1.切换ES账号
$su es
4.2.jvm.options配置
默认情况下,Elasticsearch告诉JVM使用堆的最小值和最大值的2GB。切换到生产时,保证Elasticsearch有足够的可用堆是非常重要的。
Elasticsearch将通过jvm.options中的Xms(堆的最小值)与Xmx(堆的最大值)设置来分配堆的大小。
$cd /config
修改jvm.options配置
-Xms1g
-Xmx1g
参考:https://www.kancloud.cn/apachecn/elasticsearch-doc-zh/1944980
4.3.启动es
#进入es/bin目录
$cd /home/es/elasticsearch-8.0.0/bin
#启动es
$./elasticsearch
备注:启动elasticsearch8时有以下提示
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`):
9Gh137X+s+vQGS1KfR4h
ℹ️ HTTP CA certificate SHA-256 fingerprint:
1c62f3f7464153b5c629add3bf6d903076e47b157617477d3aef5ad16f9ffddd
ℹ️ 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):
eyJ2ZXIiOiI4LjAuMCIsImFkciI6WyIxMC4xLjEuMTk3OjkyMDEiXSwiZmdyIjoiMWM2MmYzZjc0NjQxNTNiNWM2MjlhZGQzYmY2ZDkwMzA3NmU0N2IxNTc2MTc0NzdkM2FlZjVhZDE2ZjlmZmRkZCIsImtleSI6ImY4UERZMzhCNVl5WFBqRm5DcUdfOnprbUFfQXM3VFFDWWFWckFfU0w0QUEifQ==
ℹ️ 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.
5.远程浏览器访问es
https://10.1.1.197:9200
使用elastic和默认密码elastic/9Gh137X+s+vQGS1KfR4h登录:
参考:
https://www.jianshu.com/p/8d91ded7a3f0
https://blog.csdn.net/u013810234/article/details/123028697
Centos7安装Kibanna8.0.0并访问ES
1.kibana下载
$wget https://artifacts.elastic.co/downloads/kibana/kibana-8.0.0-linux-x86_64.tar.gz
2.创建kibana用户
#创建用户组
$groupadd kibana
#在kibana组创建用户
$useradd -m -g kibana kibana
#给用户设置密码
$passwd kibana
3.将下载好的kibana解压,并移动到kibana的home目录,并改变所属用户和组为kibana
#解压缩
$tar -zxvf kibana-8.0.0-linux-x86_64.tar.gz
#移动到/home/kibana下
$mv kibana-8.0.0 /home/kibana/kibana-8.0.0
#授权给es用户组和kibana用户
chown -R kibana:kibana /home/kibana/kibana-8.0.0
4.启动kibana
4.1.切换到kibana用户
$su kibana
4.2.修改配置文件kibana.yml
server.port: 5601
server.host: "0.0.0.0"
server.name: "kibana"
4.3.启动kibana
$cd /home/kibana/kibana-8.0.0/bin
$./kibana
5.访问kibana
Kibana访问需要token,这个跟其他版本有区别。
1、输入token 2、输入kibana的验证值 3、输入ES的账号密码
5.1、访问http://10.1.1.197:5601
输入第一次启动ES时自动生成的token
如果token过期,需要到ES中为kibana重新生成token:
bash-4.4$ ./elasticsearch-create-enrollment-token -s kibana
warning: ignoring JAVA_HOME=/home/java_all/java64/jdk1.8.0_221; using bundled JDK
eyJ2ZXIiOiI4LjAuMCIsImFkciI6WyIxMC4xLjEuMTk3OjkyMDAiXSwiZmdyIjoiMWM2MmYzZjc0NjQxNTNiNWM2MjlhZGQzYmY2ZDkwMzA3NmU0N2IxNTc2MTc0NzdkM2FlZjVhZDE2ZjlmZmRkZCIsImtleSI6InBaZVBaMzhCZFVYQkhsV0hCT0lNOnJmSlVDZTUwVGRDVXlPdVdiZnRkMFEifQ==
5.2、输入kibana验证值
在kibana/bin目录中生成步骤:
./kibana-verfication-code
5.3、Kibana访问页面,输入账号密码登录
elastic/9Gh137X+s+vQGS1KfR4h 登录成功。
备注:查看kibana的配置文件,自动生成以下配置信息
# This section was automatically generated during setup.
elasticsearch.hosts: ['https://10.1.1.197:9200']
elasticsearch.serviceAccountToken: AAEAAWVsYXN0aWMva2liYW5hL2Vucm9sbC1wcm9jZXNzLXRva2VuLTE2NDY3MDk5NjkyOTQ6cVQwNGRRS3lTdi1jWk12YXBVc2wtdw
elasticsearch.ssl.certificateAuthorities: [/home/kibana/kibana-8.0.0/data/ca_1646709970397.crt]
xpack.fleet.outputs: [{id: fleet-default-output, name: default, is_default: true, is_default_monitoring: true, type: elasticsearch, hosts: ['https://10.1.1.197:9200'], ca_trusted_fingerprint: 1c62f3f7464153b5c629add3bf6d903076e47b157617477d3aef5ad16f9ffddd}]
这里如果配置不用证书:
那么需要加上:
elasticsearch.ssl.verificationMode: "none"
6、kibana8.0.0访问ES8.0.0遇到以下问题
6.1、无法远程访问
原因:防火墙原因
解决方法:停止防火墙 或开放5601端口
#查询防火墙状态,是否开启着
systemctl status firewalld
#停止防火墙
$service firewalld stop
6.2、Kibana8连接ElasticSearch8的enrollment token过期
使用E lasticSearch 自带的工具: /bin/elasticsearch-create-enrollment-token ,重新手动生成 Kibana 连接 ElasticSearch 的 enrollment token 。
生成如下:
bash-4.4$ ./elasticsearch-create-enrollment-token -s kibana
warning: ignoring JAVA_HOME=/home/java_all/java64/jdk1.8.0_221; using bundled JDK
eyJ2ZXIiOiI4LjAuMCIsImFkciI6WyIxMC4xLjEuMTk3OjkyMDAiXSwiZmdyIjoiMWM2MmYzZjc0NjQxNTNiNWM2MjlhZGQzYmY2ZDkwMzA3NmU0N2IxNTc2MTc0NzdkM2FlZjVhZDE2ZjlmZmRkZCIsImtleSI6Imt3dFFaMzhCMURJTmJGS3RpejdJOlhpNzc2aExBU1RHUXU2UnRzdjRrMlEifQ==
7、kibana启动命令和停止进程
kibana命令
#后台启动
$nohup ./kibana &
#查看kibana进程
$ps -ef|grep node
#查看端口
$netstat -tunlp|grep 5601
#停止进程
$kill -9 24527