elasticsearch7.10.2集群部署带认证

安装elasticsearch

rpm包安装

下载地址
https://mirrors.aliyun.com/elasticstack/7.x/yum/7.10.2/

生成证书

bash 复制代码
#1.生成CA证书
# 生成CA证书,执行命令后,系统还会提示你输入密码,可以直接留空
cd /usr/share/elasticsearch/bin
./elasticsearch-certutil ca
 
#会在/usr/share/elasticsearch/下生成一个elastic-stack-ca.p12文件
ls -l /usr/share/elasticsearch/
-rw-------. 1 elastic elastic 2527 May 21 14:29 elastic-stack-ca.p12
 
#2.根据elastic-stack-ca.p12文件 生成elastic-certificates.p12
# 生成证书和私钥,系统还会提示你输入密码,你可以输入证书和密钥的密码,也可以留空
cd /usr/share/elasticsearch/
./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12

把生成的证书放到 /etc/elasticsearch/目录下,并授权

不加认证,启动集群模式

egrep -v "#|^$" /etc/elasticsearch/elasticsearch.yml

yaml 复制代码
cluster.name: es
node.name: es1
path.data: /app/es/data
path.logs: /app/es/log
network.host: 0.0.0.0
node.master: true
node.data: true
discovery.seed_hosts: ["172.17.13.10:9300", "172.17.13.11:9300", "172.17.13.12:9300"]
cluster.initial_master_nodes: ["es1", "es2", "es3"]
discovery.zen.minimum_master_nodes: 2
http.cors.enabled: true
http.cors.allow-origin: "*"
#xpack.security.enabled: true
#xpack.security.transport.ssl.enabled: true
#xpack.security.transport.ssl.verification_mode: certificate
#xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
#xpack.security.transport.ssl.truststore.path: elastic-stack-ca.p12
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

启动集群,查看状态

bash 复制代码
curl -XGET  "http://127.0.0.1:9200/_cat/nodes"

添加认证和证书,重启集群

egrep -v "#|^$" /etc/elasticsearch/elasticsearch.yml

yaml 复制代码
cluster.name: es
node.name: es1
path.data: /app/es/data
path.logs: /app/es/log
network.host: 0.0.0.0
node.master: true
node.data: true
discovery.seed_hosts: ["172.17.13.10:9300", "172.17.13.11:9300", "172.17.13.12:9300"]
#cluster.initial_master_nodes: ["es1", "es2", "es3"]
discovery.zen.minimum_master_nodes: 2
http.cors.enabled: true
http.cors.allow-origin: "*"
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-stack-ca.p12
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

设置口令

bash 复制代码
./bin/elasticsearch-setup-passwords interactive

查看集群信息

bash 复制代码
curl -XGET -u elastic:123456 "http://127.0.0.1:9200/_cluster/health?pretty"
curl -XGET -u elastic:123456 "http://127.0.0.1:9200/_cat/nodes"

kibana

vim /etc/kibana/kibana.yml

yaml 复制代码
server.port: 5601
server.host: 0.0.0.0
elasticsearch.hosts: ["http://192.168.0.11:9200","http://192.168.0.12:9200","http://192.168.0.13:9200"]
xpack.security.enabled: true
kibana.index: ".kibana"
i18n.locale: "zh-CN"
elasticsearch.username: "elastic"
elasticsearch.password: "123456"
相关推荐
Elasticsearch12 小时前
使用 Qoder 将 CSV 文件导入 Elasticsearch
elasticsearch
CANI_PLUS13 小时前
电脑文件共享
运维·服务器
Decay__13 小时前
15_MySQL 数据同步与迁移方案 —— 复制 / DataX / Canal / 异构同步(对标 Oracle GoldenGate)
运维·数据库·sql·mysql·架构
Linux界最忧郁之人13 小时前
华为云ECS&IMS&AS实战|弹性云服务器、私有镜像、弹性伸缩完整实验
linux·运维·服务器·centos·华为云·openstack
后台模板学习13 小时前
GitHub Actions 与 Jenkins 在日志监
运维·github·jenkins
whyutianict_vv14 小时前
零基础转 AI 运维:投入清单、技术路线与核对表
linux·运维·人工智能·ai
Elastic 中国社区官方博客14 小时前
AgentHack Shanghai|基于阿里云AI搜索 Elasticsearch x Qoder 构建AI Agent应用
大数据·人工智能·elasticsearch·搜索引擎·阿里云·云计算·全文检索
杨云龙UP14 小时前
Oracle 同义词(SYNONYM)详解及 Toad for Oracle SQL 智能补全配置实战
运维·数据库·sql·oracle·同义词·toad·toad for oracle
晨陌y15 小时前
Flare自托管导航页教程:Docker部署、多用户、API与公网访问
运维·docker·容器
Android系统攻城狮15 小时前
Linux FFmpeg深度解析之avcodec_parameters_copy调用流程与实战(二十五)
linux·运维·服务器·ffmpeg·音视频·车载音频