准备 3 台主机,均进行如下操作
- 更新系统以及关联软件
yum update
- 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
sed -i 's/enforcing/disabled/' /etc/selinux/config
setenforce 0
- 设置主机名
# lab10 主机设置为
hostnamectl set-hostname lab10# lab20 主机设置为
hostnamectl set-hostname lab20# lab30 主机设置为
hostnamectl set-hostname lab30
- 编辑本地域名解析
vim /etc/hosts
追加内容如下:
10.1.1.10 lab10
10.1.1.20 lab20
10.1.1.30 lab30
- 创建
software
目录
mkdir /opt/software
- 创建
module
目录
mkdir /opt/module
- 下载 Elasticsearch 文件
下载列表页面:https://www.elastic.co/cn/downloads/past-releases#elasticsearch
文件名称:elasticsearch-9.1.4-linux-x86_64.tar.gz
MD5:20DA05C3A2A7425A658A73D6D9AF8DFE
下载链接:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-9.1.4-linux-x86_64.tar.gz
-
拷贝到
/opt/software
下 -
解压
tar -zxvf /opt/software/elasticsearch-9.1.4-linux-x86_64.tar.gz -C /opt/module
- 创建
es
用户
useradd es
- 设置
es
用户密码
passwd es
- 创建
data
目录
mkdir /opt/module/elasticsearch-9.1.4/data
- 创建
certs
目录
mkdir /opt/module/elasticsearch-9.1.4/config/certs
- 进入
Elasticsearch
目录
cd /opt/module/elasticsearch-9.1.4
- 将
Elasticsearch
目录赋权给es
用户操作
chown -R es:es /opt/module/elasticsearch-9.1.4
lab10 主机操作
- 切换
es
用户
su es
- 签发 ca 证书
bin/elasticsearch-certutil ca
操作过程如下
Please enter the desired output file [elastic-stack-ca.p12]:【默认,回车】
Enter password for elastic-stack-ca.p12 :【默认,回车】
完成后证书在 /opt/module/elasticsearch-9.1.4/elastic-stack-ca.p12
- 用 ca 证书签发节点证书,设置集群多节点通信密钥
bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
操作过程如下
Enter password for CA (elastic-stack-ca.p12) :【默认,回车】
Please enter the desired output file [elastic-certificates.p12]:【默认,回车】
Enter password for elastic-certificates.p12 :【默认,回车】
完成后证书在 /opt/module/elasticsearch-9.1.4/elastic-certificates.p12
- 移动上述 2 个证书至
cert
目录
mv elastic-stack-ca.p12 elastic-certificates.p12 config/certs
- 设置集群多节点 HTTP 证书
bin/elasticsearch-certutil http
操作过程如下:
Generate a CSR? [y/N]N
Use an existing CA? [y/N]y
CA Path: 【certs/elastic-stack-ca.p12】
Password for elastic-certificates.p12:【默认,回车】
For how long should your certificate be valid? [5y] 【默认,回车】
Generate a certificate per node? [y/N]n
When you are done, press <ENTER> once more to move on to the next step.lab10
lab20
lab30
Is this correct [Y/n]Y
When you are done, press <ENTER> once more to move on to the next step.10.1.1.10
10.1.1.20
10.1.1.30
Is this correct [Y/n]Y
Do you wish to change any of these options? [y/N]N
Provide a password for the "http.p12" file: [<ENTER> for none]【默认,回车】
What filename should be used for the output zip file? [/opt/module/elasticsearch-9.1.4/elasticsearch-ssl-http.zip]【默认,回车】
完成后证书在 /opt/module/elasticsearch-9.1.4/elasticsearch-ssl-http.zip
- 移动上述 1 个压缩包至
cert
目录
mv elasticsearch-ssl-http.zip config/certs/
- 解压
unzip config/certs/elasticsearch-ssl-http.zip -d config/certs/elasticsearch-ssl-http
- 删除无用的压缩包
rm -rf /opt/module/elasticsearch-9.1.4/config/certs/elasticsearch-ssl-http.zip
- 编辑
elasticsearch.yml
文件
vim /opt/module/elasticsearch-9.1.4/config/elasticsearch.yml
追加内容如下
# 设置 ES 集群名称
cluster.name: es-cluster
# 设置集群中当前节点名称
node.name: es-node-1
# 设置数据,日志文件路径
path.data: /opt/module/elasticsearch-9.1.4/data
path.logs: /opt/module/elasticsearch-9.1.4/logs
# 设置网络访问节点
network.host: lab10
# 设置网络访问端口
http.port: 9200
# 初始节点
discovery.seed_hosts: ["lab10"]
# 安全认证
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:enabled: truekeystore.path: /opt/module/elasticsearch-9.1.4/config/certs/elasticsearch-ssl-http/elasticsearch/http.p12truststore.path: /opt/module/elasticsearch-9.1.4/config/certs/elasticsearch-ssl-http/elasticsearch/http.p12
xpack.security.transport.ssl:enabled: trueverification_mode: certificatekeystore.path: /opt/module/elasticsearch-9.1.4/config/certs/elastic-certificates.p12truststore.path: /opt/module/elasticsearch-9.1.4/config/certs/elastic-certificates.p12
# 此处需注意,es-node-1 为上面配置的节点名称
cluster.initial_master_nodes: ["es-node-1"]
http.host: [_local_, _site_]
ingest.geoip.downloader.enabled: false
xpack.security.http.ssl.client_authentication: none
- 启动
Elasticsearch
集群
bin/elasticsearch
-
重建会话,并使用 es 用户登录并且进入
/opt/module/elasticsearch-9.1.4
目录 -
重置
elastic
用户密码
bin/elasticsearch-reset-password -u elastic
操作过程如下
[root@lab10 elasticsearch-9.1.4]# su es
[es@lab10 elasticsearch-9.1.4]$ bin/elasticsearch-reset-password -u elastic
This tool will reset the password of the [elastic] user to an autogenerated value.
The password will be printed in the console.
Please confirm that you would like to continue [y/N]yPassword for the [elastic] user successfully reset.
New value: 1m+yge3yEAkwcetxua-o
[es@lab10 elasticsearch-9.1.4]$
- 使用浏览器访问:
https://10.1.1.10:9200
,默认账号为:elastic
,密码为1m+yge3yEAkwcetxua-o
,得到如下图所示
- 使用谷歌浏览器的
Elasticsearch Tools
插件查看 Elasticsearch 状态
- 使用谷歌浏览器的
Elasticvue
插件查看 Elasticsearch 状态
lab20 主机操作
-
将 lab10主机
/opt/module/elasticsearch-9.1.4/config/certs
目录拷贝至本机的/opt/module/elasticsearch-9.1.4/config/certs
目录 -
将
Elasticsearch
目录赋权给es
用户操作(需要root用户权限操作)
chown -R es:es /opt/module/elasticsearch-9.1.4
- 切换
es
用户
su es
- 编辑
elasticsearch.yml
文件
vim /opt/module/elasticsearch-9.1.4/config/elasticsearch.yml
追加内容如下
# 设置 ES 集群名称
cluster.name: es-cluster
# 设置集群中当前节点名称
node.name: es-node-2
# 设置数据,日志文件路径
path.data: /opt/module/elasticsearch-9.1.4/data
path.logs: /opt/module/elasticsearch-9.1.4/logs
# 设置网络访问节点
network.host: lab20
# 设置网络访问端口
http.port: 9200
# 初始节点
discovery.seed_hosts: ["lab10"]
# 安全认证
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:enabled: truekeystore.path: /opt/module/elasticsearch-9.1.4/config/certs/elasticsearch-ssl-http/elasticsearch/http.p12truststore.path: /opt/module/elasticsearch-9.1.4/config/certs/elasticsearch-ssl-http/elasticsearch/http.p12
xpack.security.transport.ssl:enabled: trueverification_mode: certificatekeystore.path: /opt/module/elasticsearch-9.1.4/config/certs/elastic-certificates.p12truststore.path: /opt/module/elasticsearch-9.1.4/config/certs/elastic-certificates.p12
# 此处需注意,es-node-1 为上面配置的节点名称
cluster.initial_master_nodes: ["es-node-1"]
http.host: [_local_, _site_]
ingest.geoip.downloader.enabled: false
xpack.security.http.ssl.client_authentication: none
- 进入
Elasticsearch
目录
cd /opt/module/elasticsearch-9.1.4
- 后台启动
Elasticsearch
集群
bin/elasticsearch -d
- 使用谷歌浏览器的
Elasticsearch Tools
插件查看 Elasticsearch 状态
- 使用谷歌浏览器的
Elasticvue
插件查看 Elasticsearch 状态
lab30 主机操作
-
将 lab10主机
/opt/module/elasticsearch-9.1.4/config/certs
目录拷贝至本机的/opt/module/elasticsearch-9.1.4/config/certs
目录 -
将
Elasticsearch
目录赋权给es
用户操作(需要root用户权限操作)
chown -R es:es /opt/module/elasticsearch-9.1.4
- 切换
es
用户
su es
- 编辑
elasticsearch.yml
文件
vim /opt/module/elasticsearch-9.1.4/config/elasticsearch.yml
追加内容如下
# 设置 ES 集群名称
cluster.name: es-cluster
# 设置集群中当前节点名称
node.name: es-node-3
# 设置数据,日志文件路径
path.data: /opt/module/elasticsearch-9.1.4/data
path.logs: /opt/module/elasticsearch-9.1.4/logs
# 设置网络访问节点
network.host: lab30
# 设置网络访问端口
http.port: 9200
# 初始节点
discovery.seed_hosts: ["lab10"]
# 安全认证
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:enabled: truekeystore.path: /opt/module/elasticsearch-9.1.4/config/certs/elasticsearch-ssl-http/elasticsearch/http.p12truststore.path: /opt/module/elasticsearch-9.1.4/config/certs/elasticsearch-ssl-http/elasticsearch/http.p12
xpack.security.transport.ssl:enabled: trueverification_mode: certificatekeystore.path: /opt/module/elasticsearch-9.1.4/config/certs/elastic-certificates.p12truststore.path: /opt/module/elasticsearch-9.1.4/config/certs/elastic-certificates.p12
# 此处需注意,es-node-1 为上面配置的节点名称
cluster.initial_master_nodes: ["es-node-1"]
http.host: [_local_, _site_]
ingest.geoip.downloader.enabled: false
xpack.security.http.ssl.client_authentication: none
- 进入
Elasticsearch
目录
cd /opt/module/elasticsearch-9.1.4
- 后台启动
Elasticsearch
集群
bin/elasticsearch -d
- 使用谷歌浏览器的
Elasticsearch Tools
插件查看 Elasticsearch 状态
- 使用谷歌浏览器的
Elasticvue
插件查看 Elasticsearch 状态
【【【 以上完成【安装 elasticsearch-9.1.4 - 集群】 】】】
【【【 以上完成【安装 elasticsearch-9.1.4 - 集群】 】】】
【【【 以上完成【安装 elasticsearch-9.1.4 - 集群】 】】】
lab10 主机操作
- 下载Kibana 文件
下载列表页面:https://www.elastic.co/cn/downloads/past-releases#elasticsearch
文件名称:kibana-9.1.4-linux-x86_64.tar.gz
MD5:188D1DEE8DE1AD02116C26404B877C16
下载链接:https://artifacts.elastic.co/downloads/kibana/kibana-9.1.4-linux-x86_64.tar.gz
-
拷贝到
/opt/software
下 -
解压
tar -zxvf /opt/software/kibana-9.1.4-linux-x86_64.tar.gz -C /opt/module/
- 进入
Elasticsearch
目录
cd /opt/module/elasticsearch-9.1.4
- 在 ES 服务器中生成证书
bin/elasticsearch-certutil csr -name kibana -dns lab10
操作过程
Please enter the desired output file [csr-bundle.zip]: 【默认配置,回车】
生成成功后的证书路径在 /opt/module/elasticsearch-9.1.4/csr-bundle.zip
- 移动证书至
/opt/module/kibana-9.1.4/config
mv /opt/module/elasticsearch-9.1.4/csr-bundle.zip /opt/module/kibana-9.1.4/config/
- 解压
unzip /opt/module/kibana-9.1.4/config/csr-bundle.zip -d /opt/module/kibana-9.1.4/config/csr-bundle
- 删除无用的压缩包
rm -rf /opt/module/kibana-9.1.4/config/csr-bundle.zip
- 进入证书目录
cd /opt/module/kibana-9.1.4/config/csr-bundle/kibana
- 生成 crt 文件
openssl x509 -req -in kibana.csr -signkey kibana.key -out kibana.crt
- 编辑
kibana.yml
文件
vim /opt/module/kibana-9.1.4/config/kibana.yml
内容如下
# 服务端口
server.port: 5601
# 服务主机名
server.host: "lab10"
# 国际化 - 中文
i18n.locale: "zh-CN"
# ES 服务主机地址
elasticsearch.hosts: ["https://lab10:9200"]
# 访问 ES 服务的账号密码
elasticsearch.username: "kibana"
# 需要使用es用户,使用命令 bin/elasticsearch-reset-password -u kibana 获取密码
elasticsearch.password: "hloTe9BBk-4gB8DUwmbY"
elasticsearch.ssl.verificationMode: none
elasticsearch.ssl.certificateAuthorities: [ "/opt/module/elasticsearch-9.1.4/config/certs/elasticsearch-ssl-http/kibana/elasticsearch-ca.pem" ]
server.ssl.enabled: true
server.ssl.certificate: /opt/module/kibana-9.1.4/config/csr-bundle/kibana/kibana.crt
server.ssl.key: /opt/module/kibana-9.1.4/config/csr-bundle/kibana/kibana.key
- 将
/opt/module/kibana-8.1.0/
目录给es
用户赋予权限
chown -R es:es /opt/module/kibana-9.1.4/
- 切换
es
用户
su es
- 切换工作目录
cd /opt/module/kibana-9.1.4/
- 启动 kibana
bin/kibana
或者
nohup /opt/module/kibana-9.1.4/bin/kibana >kibana.log 2>&1 &
- 浏览器访问
https://10.1.1.10:5601/
,默认账号为elastic
,默认密码为控制台输出为准,成功登录后的图片
【【【 以上完成【kibana-9.1.4】 】】】
【【【 以上完成【kibana-9.1.4】 】】】
【【【 以上完成【kibana-9.1.4】 】】】