.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


相关推荐
Elasticsearch1 小时前
使用 Elastic Agent 混合摄取加速 Otel 采用
elasticsearch
W***r262 小时前
SpringBoot整合easy-es
spring boot·后端·elasticsearch
それども2 小时前
ES KQL 支持词频统计吗
elasticsearch
zhyf1192 小时前
Max395(ubuntu24.04)AMD显卡GLM-4.7-UD-IQ1-M量化模型部署手册
大数据·elasticsearch·搜索引擎
学好statistics和DS4 小时前
Git 同步冲突
大数据·git·elasticsearch
chen<>1 天前
Git原理与应用
大数据·git·elasticsearch·svn
liuyunshengsir1 天前
Elasticsearch 高级查询must 多个条件同时满足
linux·服务器·elasticsearch
Cx330❀2 天前
Git 多人协作全攻略:从入门到高效协同
大数据·elasticsearch·搜索引擎·gitee·github·全文检索·gitcode
bigHead-2 天前
Git合并操作详解:安全高效地合并远程分支
git·安全·elasticsearch
奇树谦2 天前
FastDDS阿里云DDSRouter安装和使用(失败)
elasticsearch·阿里云·云计算