.Net使用Elastic.Clients.Elasticsearch连接Elasticsearch8

文章目录


1、elasticsearch.yml配置

单一节点配置

yaml 复制代码
node.name: node-1

path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch

network.host: localhost
http.port: 9200

xpack.security.enabled: true
xpack.security.enrollment.enabled: true

xpack.security.http.ssl:
  enabled: true
  keystore.path: certs/http.p12
xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12

http.host: 0.0.0.0

2、生成证书指纹

bash 复制代码
cd /etc/elasticsearch/certs
openssl x509 -in http_ca.crt -sha256 -fingerprint | grep SHA256 | sed 's/://g'
复制代码
SHA256 Fingerprint=ABE1B0CEBA7D45461430B48A7804DFDC6ECB136CDF4523F01106D863F4826BD1

3、使用Elastic.Clients.Elasticsearch连接

csharp 复制代码
var settings1 = new ElasticsearchClientSettings(new Uri($"https://{_elasticModel.IP}:{_elasticModel.Port}"))
	.CertificateFingerprint("ABE1B0CEBA7D45461430B48A7804DFDC6ECB136CDF4523F01106D863F4826BD1")
	.Authentication(new BasicAuthentication(_elasticModel.UserName, _elasticModel.Password));

4、参考

https://www.elastic.co/guide/en/elasticsearch/client/net-api/8.13/connecting.html


相关推荐
Elasticsearch9 小时前
Elasticsearch:使用 AI Agent 来创建 workflows
elasticsearch
gll77311 小时前
RAG 检索层实战:Redis 缓存 + ES 混合检索 + BGE-Rerank 重排全链路落地与踩坑
elasticsearch
Elasticsearch13 小时前
ES 存日志很贵?我用 ES 9.5 把日志从 4.5G 压到 412M 压缩比11.2倍,日志硬扫每秒128万行!
elasticsearch
Elasticsearch15 小时前
Elasticsearch 作为统一平台:引入第二套数据系统究竟要付出什么代价
elasticsearch
Elastic 中国社区官方博客16 小时前
Elasticsearch:列式索引模式 - Columnar index mode
大数据·数据库·elasticsearch·搜索引擎·全文检索
Elasticsearch16 小时前
Elasticsearch 的批量查询阶段如何在大规模场景下提升搜索性能
elasticsearch
Ramboooooooo18 小时前
SkyWalking-10.4.0 Docker + Nacos + Elasticsearch 生产级部署手册
elasticsearch·docker·skywalking
互联网中的一颗神经元1 天前
04 — 安全撤销:改错了怎么退回去
大数据·安全·elasticsearch
Elasticsearch1 天前
Elasticsearch:列式索引模式 - Columnar index mode
elasticsearch
Elasticsearch2 天前
从 CrashLoopBackOff 到根本原因,只需几秒:使用 Elastic Observability 自动化 20 分钟的 Kubernetes 调查流
elasticsearch